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

feat: add dummy client

parent dcf30472
No related branches found
No related tags found
No related merge requests found
add_subdirectory(cpu_temp)
add_subdirectory(dummy)
add_executable(dummy
src/dummy.c
)
target_link_libraries(dummy
PRIVATE common
m
)
#include "../../../common/include/measurement.h"
#include "../../../common/include/userspace_comm.h"
#include <fcntl.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
if (argc < 3 || argc > 3) {
printf("Invalid arguments provided");
return EXIT_FAILURE;
}
userspace_send_handle_t userspace_send_handle;
if (create_userspace_send_handle(&userspace_send_handle) == -1) {
perror("Failed to open message queue");
return EXIT_FAILURE;
}
double step = 0.0;
int sleep_ms = atoi(argv[2]);
while (1) {
measurement_t measurement = {
.data.float64 = sin(step),
.datatype = FLOAT64,
.id = atoi(argv[1]),
};
send_userspace_message(&userspace_send_handle, measurement);
step += 0.01;
if (step >= 2.0 * M_PI) {
step = 0.0;
}
usleep(sleep_ms * 1000);
}
destroy_userspace_send_handle(&userspace_send_handle);
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment