From 0a398d572017613327b266328f46713536916b6f Mon Sep 17 00:00:00 2001 From: "leon.bohnwagner" <leon.bohnwagner@informatik.hs-fulda.de> Date: Fri, 14 Feb 2025 15:14:17 +0100 Subject: [PATCH] docs: add file headers --- clients/cpu_temp/src/cpu_temp.c | 18 ++++++++++++++++++ clients/dummy/src/dummy.c | 17 +++++++++++++++++ clients/mem_usage/src/mem_usage.c | 18 ++++++++++++++++++ common/include/measurement.h | 7 +++++++ common/include/userspace_comm.h | 9 +++++++++ common/src/measurement.c | 7 +++++++ common/src/userspace_comm.c | 8 ++++++++ daemon/include/receive.h | 9 +++++++++ daemon/include/send.h | 7 +++++++ daemon/src/main.c | 14 ++++++++++++++ daemon/src/receive.c | 8 ++++++++ daemon/src/send.c | 8 ++++++++ kernel/kmod.c | 21 +++++++++++++++++++++ 13 files changed, 151 insertions(+) diff --git a/clients/cpu_temp/src/cpu_temp.c b/clients/cpu_temp/src/cpu_temp.c index 10d8c20..b98f728 100644 --- a/clients/cpu_temp/src/cpu_temp.c +++ b/clients/cpu_temp/src/cpu_temp.c @@ -1,3 +1,21 @@ +/* + * cpu_temp.c - Reads CPU temperature and sends it via message queue + * + * This client reads the CPU temperature from + * `/sys/class/thermal/thermal_zone0/temp`, converts it, and sends it as a + * floating-point measurement using a message queue. + * + * Usage: + * ./cpu_temp <id> <delay_ms> + * + * Parameters: + * <id> - Unique identifier for the measurement + * <delay_ms> - Delay between measurements in milliseconds + * + * Example: + * ./cpu_temp 1 250 + */ + #include "../../../common/include/measurement.h" #include "../../../common/include/userspace_comm.h" #include <errno.h> diff --git a/clients/dummy/src/dummy.c b/clients/dummy/src/dummy.c index 2db5e23..c9a047b 100644 --- a/clients/dummy/src/dummy.c +++ b/clients/dummy/src/dummy.c @@ -1,3 +1,20 @@ +/* + * dummy_client.c - Generates sine wave data and sends it via message queue + * + * This client simulates sensor data by generating a sine wave value and + * sending it as a floating-point measurement using a message queue. + * + * Usage: + * ./dummy <id> <delay_ms> + * + * Parameters: + * <id> - Unique identifier for the measurement + * <delay_ms> - Delay between measurements in milliseconds + * + * Example: + * ./dummy 1 250 + */ + #include "../../../common/include/measurement.h" #include "../../../common/include/userspace_comm.h" #include <errno.h> diff --git a/clients/mem_usage/src/mem_usage.c b/clients/mem_usage/src/mem_usage.c index c54f8fa..ddceb99 100644 --- a/clients/mem_usage/src/mem_usage.c +++ b/clients/mem_usage/src/mem_usage.c @@ -1,3 +1,21 @@ +/* + * mem_usage.c - Reads memory usage and sends it via message queue + * + * This program reads memory information using the `sysinfo` system call, + * calculates the used memory, and sends it as an unsigned integer measurement + * via a message queue. + * + * Usage: + * ./mem_usage <id> <delay_ms> + * + * Parameters: + * <id> - Unique identifier for the measurement + * <delay_ms> - Delay between measurements in milliseconds + * + * Example: + * ./mem_usage 1 250 + */ + #include "../../../common/include/measurement.h" #include "../../../common/include/userspace_comm.h" #include <errno.h> diff --git a/common/include/measurement.h b/common/include/measurement.h index ec241d1..308cc64 100644 --- a/common/include/measurement.h +++ b/common/include/measurement.h @@ -1,3 +1,10 @@ +/* + * measurement.h - Defines data structures and types for measurement handling + * + * This header file provides type definitions and structures for representing + * measurement data. + */ + #pragma once #if defined(__KERNEL__) diff --git a/common/include/userspace_comm.h b/common/include/userspace_comm.h index d52b116..f10e423 100644 --- a/common/include/userspace_comm.h +++ b/common/include/userspace_comm.h @@ -1,3 +1,12 @@ +/* + * userspace_comm.h - Message queue communication for sending userspace + * measurement data + * + * This header file provides functions and structures for message queue + * interprocess communication. It allows sending measurement data from userspace + * applications. + */ + #pragma once #include "measurement.h" diff --git a/common/src/measurement.c b/common/src/measurement.c index ad63997..fbcf134 100644 --- a/common/src/measurement.c +++ b/common/src/measurement.c @@ -1,3 +1,10 @@ +/* + * measurement.c - Implementation of measurement functions + * + * This file provides the implementation of the functions declared in + * measurement.h. + */ + #include "../include/measurement.h" size_t measurement_data_type_size(measurement_data_type_t type) { diff --git a/common/src/userspace_comm.c b/common/src/userspace_comm.c index e3999d7..cfa209a 100644 --- a/common/src/userspace_comm.c +++ b/common/src/userspace_comm.c @@ -1,3 +1,11 @@ +/* + * userspace_comm.c - Implementation of message queue communication functions + * + * This file provides the implementation of the functions declared in + * userspace_comm.h. + * + */ + #include "../include/userspace_comm.h" #include <sys/ipc.h> #include <sys/msg.h> diff --git a/daemon/include/receive.h b/daemon/include/receive.h index a3f9778..97a7931 100644 --- a/daemon/include/receive.h +++ b/daemon/include/receive.h @@ -1,3 +1,12 @@ +/* + * receive.h - Message queue communication for receiving userspace measurement + * data + * + * This header file provides functions and structures for message queue + * interprocess communication. It allows receiving measurement data from + * userspace applications. + */ + #pragma once #include "../../common/include/measurement.h" diff --git a/daemon/include/send.h b/daemon/include/send.h index a596c96..7e3b5ce 100644 --- a/daemon/include/send.h +++ b/daemon/include/send.h @@ -1,3 +1,10 @@ +/* + * send.h - Communication with the kernel device for measurement data + * + * This header file provides functions and structures to send measurement data + * to the kernel through the `/dev/sibyl` device. + */ + #pragma once #include "../../common/include/measurement.h" diff --git a/daemon/src/main.c b/daemon/src/main.c index 2c28f61..ba7f322 100644 --- a/daemon/src/main.c +++ b/daemon/src/main.c @@ -1,3 +1,17 @@ +/* + * main.c - Daemon for receiving, processing, and sending measurement data + * + * This file implements a daemon that receives measurement data from a userspace + * message queue, processes the data, and sends it to the kernel via a character + * device. + * + * The daemon continuously runs in an infinite loop, receiving measurement data + * from userspace through a message queue. Upon receiving each measurement, it + * processes and compares the data with cached values to detect any updates or + * changes. If any updates are found, the daemon sends the new data to the + * kernel module. + */ + #include "../../common/include/measurement.h" #include "../../common/include/userspace_comm.h" #include "../include/receive.h" diff --git a/daemon/src/receive.c b/daemon/src/receive.c index 3fe463f..b37c6e3 100644 --- a/daemon/src/receive.c +++ b/daemon/src/receive.c @@ -1,3 +1,11 @@ +/* + * receive.c - Implementation of message queue communication functions + * + * This file provides the implementation of the functions declared in + * receive.h. + * + */ + #include "../include/receive.h" #include "../../common/include/measurement.h" #include "../../common/include/userspace_comm.h" diff --git a/daemon/src/send.c b/daemon/src/send.c index 9ed81e7..8a72d18 100644 --- a/daemon/src/send.c +++ b/daemon/src/send.c @@ -1,3 +1,11 @@ +/* + * send.c - Implementation for sending measurement data to the kernel + * + * This file provides the implementation of the functions declared in + * send.h. + * + */ + #include "../include/send.h" #include <fcntl.h> #include <unistd.h> diff --git a/kernel/kmod.c b/kernel/kmod.c index 15fa5be..8dbb96c 100644 --- a/kernel/kmod.c +++ b/kernel/kmod.c @@ -1,3 +1,24 @@ +/* + * kmod.c - Kernel module for receiving, processing, and sending measurement + * data + * + * This kernel module provides functionality to communicate with userspace by + * receiving measurement data, preparing it for transmission, and sending it + * via GPIO pins at a specified baud rate. It integrates with a userspace + * application through a character device interface. + * + * The module operates in fixed time slots for data transmission, managed by a + * high-resolution timer. Upon receiving data from userspace, the module + * calculates a CRC checksum, prepares the data packet, and writes it into a + * send buffer. This data preparation occurs outside of the time slot but is + * triggered when new data is written to the device. + * + * The transmission itself happens in fixed time slots. The high-resolution + * timer triggers regular intervals, and during each time slot, when it's the + * systems turn, the data stored in the send buffer is transmitted bit-by-bit + * using GPIO, simulating UART-like communication with start and stop bits. + */ + #include "../common/include/measurement.h" #include <linux/cdev.h> #include <linux/crc32.h> -- GitLab