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

feat: add systemd services and client start logging

parent 9555d8ac
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,11 @@ int main(int argc, char *argv[]) {
double cpu_temp;
char buffer[6];
int id = atoi(argv[1]);
int sleep_ms = atoi(argv[2]);
printf("Started cpu temp (id: %d, delay: %dms)\n", id, sleep_ms);
while (1) {
if (pread(file_fd, buffer, sizeof(buffer), 0) == -1) {
perror("Failed to read file");
......@@ -42,7 +45,7 @@ int main(int argc, char *argv[]) {
measurement_t measurement = {
.data.float64 = cpu_temp,
.datatype = FLOAT64,
.id = atoi(argv[1]),
.id = id,
};
if (send_userspace_message(&userspace_send_handle, measurement) == -1) {
......
......@@ -23,13 +23,16 @@ int main(int argc, char *argv[]) {
double step = 0.0;
int id = atoi(argv[1]);
int sleep_ms = atoi(argv[2]);
printf("Started dummy (id: %d, delay: %dms)\n", id, sleep_ms);
while (1) {
measurement_t measurement = {
.data.float64 = sin(step),
.datatype = FLOAT64,
.id = atoi(argv[1]),
.id = id,
};
if (send_userspace_message(&userspace_send_handle, measurement) == -1) {
......
......@@ -27,8 +27,8 @@ int send_userspace_message(userspace_send_handle_t *handle,
.measurement = measurement,
};
int read = msgsnd(handle->msg_queue_id, &message_queue_message, sizeof(measurement_t),
0);
int read = msgsnd(handle->msg_queue_id, &message_queue_message,
sizeof(measurement_t), 0);
if (read == -1) {
return -1;
}
......
[Unit]
Description=CPU Temp
After=daemon.service
[Service]
ExecStart=/usr/bin/cpu-temp 2 250
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=Dummy
After=daemon.service
[Service]
ExecStart=/usr/bin/dummy 1 250
Restart=always
[Install]
WantedBy=multi-user.target
[Unit]
Description=Daemon
After=network.target
[Service]
ExecStart=/usr/bin/daemon
Restart=always
[Install]
WantedBy=multi-user.target
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment