Final exam of this course
You have to implement a transmitting part of a serial communication to a device. The device has a specific exact command set. You need to create a module which has the following functions:
- init with serial port (max 30 character), speed (int)
returns with EXIT_SUCCESS or EXIT_FAILURE
- deinit
returns with EXIT_SUCCESS or EXIT_FAILURE
- add pointer to the given command structure
returns with EXIT_SUCCESS or EXIT_FAILURE
- the modul must use pool architecure to store the incoming commands. Use the sys/queue.h to implement queues for pool. The size of the pool defined in the header file as POOL_SIZE
- your module must be thread safe, that's why you have to control the availability of the function with a semaphore
- you have to check every incoming commands validity (command range, parameters range), you can add valid commands only to the pool.
- module must use syslog to logging everything happened normal actions to LOG_INFO, invalid parameters to LOG_WARNING
- create a unit tests for every functions by cUnit or cMocka
- create a documentation for this project with Doxygen (Don't forget that, you don't need to upload generated documentation to git repository!)
- upload your project to gitlab and share it with me as developer
- dead line is the end of 2nd week of exam period. (24/05/24 12:00AM)
- I will call you to code review when you uploaded your job
-
radiation meter
- commands
- start measurement (byte: 0xfa)
- channel byte 0..7
- measurement time unit: byte: 0=sec, 1=minute, 2=hour
- measurement time: word 1..3600
- stop measurement (byte: 0xfb)
-
- alarm (byte: 0xfc)
- target: byte 1=sound, 2=light
- sound frequency (if target is sound): word 25..16000
- colour (if target is light): RGB (3 bytes)
- alarm acknowledge (byte: 0xfd)
-
PLC
- commands
- read input register (4)
- write output register (6)
- address byte: 0..0x3f
- data word: 0..0xffff
- read device information(0x2b)
- reset (0x10)
- mode byte, 0: warm, 1:cold
-
Heat pump
- commands
- mode settings (0x25)
- modes byte: 1=heating, 2=freezing, 3=standby
- set params (0x26)
- heating threshold byte: 25..40
- freezing threshold byte: 10..25
- switch to alternative heating Celsius byte: 0..-10
- read temperature (0x26)
- source byte: 0: water, 1:outdoor temperature
-
Transit device
- commands
- reset (0x76)
- start(0x80)
- device byte: 0..3
- direction byte: 0..1
- additional devices byte: 0..0xff
- stop(0x81)
- emergency stop (0xff)
-
Entering system
- commands
- add user (0x23)
- name: null terminated string max 30 chars
- password: null terminated string max 30 chars
- valid from: 4 bytes date
- invalidate user (0x24)
- reason byte: 0=delete, 1=inactivate, 2=disable
- name: null terminated string max 30 chars
- change password (0x25)
- name: null terminated string max 30 chars
- old password: null terminated string max 30 chars
- new password: null terminated string max 30 chars
-
Microscope
- commands
- zoom(0x67)
- direction byte: 0..1
- steps byte: 0..50
- unit word: 0..10000
- light (0x68)
- lumen word: 0..1000
- colour 3 bytes: RGB
- start/stop(0x56)
- action byte: 0: start, 1: stop
-
disco lamp
- commands
- on/off (0x29)
- set colour (0x30)
- R byte: 0..0xff
- G byte: 0..0xff
- B byte: 0..0xff
- alpha byte: 0..0xff
- set position (0x31)
- X byte: 0..0x7f
- Y byte: 0..0x7f
- Z byte: 0..0x7f
-
multi channel battery charger
- commands
- set params (0x63)
- min level percent byte: 0..100
- max level percent byte: 0..100
- max charging time minutes byte: 1..240
- on/off (0x64)
- on/off byte: 0=off, 1=on
- channel byte: 0..7
- emergency (0x65)
-
led cube
- commands
- set point(0x36)
- X byte: 0..7
- Y byte: 0..7
- Z byte: 0..7
- R byte: 0..255
- G byte: 0..255
- B byte: 0..255
- set plane (0x37)
- plane byte: 0..7
- R byte: 0..255
- G byte: 0..255
- B byte: 0..255
- reset (0x40)