Skip to content
Snippets Groups Projects
Commit c11f0e91 authored by Leon Bohnwagner's avatar Leon Bohnwagner :crab:
Browse files

docs: update deprecated documentation

parent 36777756
Branches
No related tags found
No related merge requests found
......@@ -2,46 +2,25 @@
## Building
### Kernel Module
```bash
cd kernel
make
sudo make install
```
### Userspace
```
```sh
mkdir build && cd build
cmake ..
make
```
The binaries will be in:
- `build/daemon/daemon`
The compiled binaries can be found in following directories:
- `build/daemon/daemon` (for the daemon binary)
- `build/clients/*` (for the client binaries)
- `build/clients/*`
### Kernel module
```sh
cd kernel
make
```
## Communication
### Userspace
The client programs that aggregate the desired system data may send them to the daemon process.
This is done via a simple packet, `daemon_measurement_t` which is defined in [`common/include/protocol.h`](common/include/protocol.h):
```c
#define MAX_DAEMON_PACKET_SIZE PIPE_BUF
#define DAEMON_PACKET_HEADER_SIZE sizeof(uint8_t) + sizeof(uint16_t)
#define MAX_DAEMON_PACKET_DATA_SIZE MAX_DAEMON_PACKET_SIZE - DAEMON_PACKET_HEADER_SIZE
typedef struct {
uint8_t measurement_id;
uint16_t size;
uint8_t data[MAX_DAEMON_PACKET_DATA_SIZE];
} daemon_measurement_t;
```
The packet size equals to the size of `PIPE_BUF` (4096).
The communication to the deamon is implemented via a named pipe, the size ensure that the packet is atomic, i.e. it is written to the pipe in one go.
- The first byte contains the measurement id, so the maximum number of different measurements client is 255.
- The second and third bytes contain the size of the data in the packet.
- All following bytes contain the data.
### Kernel module
......@@ -17,6 +17,12 @@ typedef s64 int64_t;
#include <stdint.h>
#endif
/**
* typedef data_t - Structure for sending measurement messages to the kernel module.
* @sensor_id: The sensor ID of the system.
* @count: The number of measurement messages.
* @values: A pointer to an array of measurement messages.
*/
typedef struct data {
uint8_t sensor_id;
uint8_t count;
......
......@@ -15,6 +15,9 @@ typedef s64 int64_t;
#include <stdint.h>
#endif
/**
* enum message_data_type - Enum to define the data types used for measurement data.
*/
enum message_data_type {
INT8,
UINT8,
......@@ -27,8 +30,15 @@ enum message_data_type {
FLOAT32,
FLOAT64
};
/**
* typedef message_data_type_t - Alias for uint32_t representing the message data types.
*/
typedef uint32_t message_data_type_t;
/**
* typedef message_data_t - Union to hold different types of measurement data.
*/
typedef union message_data {
int8_t int8;
uint8_t uint8;
......@@ -44,14 +54,9 @@ typedef union message_data {
/**
* typedef message_t - Structure to hold a message with a measurement.
* @measurement_id: The id of the measurement. Every sender should have a unique
* id.
* @daemon_measurement_datatype: Datatype of the data. All values in `data` must
* be of this type.
* @length: How many types of `datatype` are in `data`. Must not exceed
* (`length` * daemon_measurement_datatype_size(`datatype`)) >
* MAX_DAEMON_PACKET_DATA_SIZE.
* @data: The measurement data.
* @datatype: The data type of the data.
* @measurement_id: The id of the measurement. Every sender should have a unique id.
*/
typedef struct message {
message_data_t data;
......@@ -66,13 +71,3 @@ typedef struct message {
* Returns the size.
*/
size_t message_data_type_size(message_data_type_t type);
/**
* message_check() - Check if a `message_t` is correct.
* @arg1: Message to check.
*
* Checks if the datatype size * length not exceeds MAX_DAEMON_PACKET_DATA_SIZE.
*
* Returns 0 on success, -1 on error.
*/
int message_check(message_t *message);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment