diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2024-02-02 13:24:18 +0100 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2024-02-02 13:24:18 +0100 |
| commit | aedbeb3bc5f260c9a233767b813a11ffb657fffc (patch) | |
| tree | 6028f428492c29bf2600b41a1da77eb6c9b5b7b2 /src | |
| parent | 4224cb1d6c5cfa267095213d6a69c408d2adbe82 (diff) | |
Minor changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/publisher.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/publisher.c b/src/publisher.c index 769ff27..b3945f5 100644 --- a/src/publisher.c +++ b/src/publisher.c @@ -19,9 +19,6 @@ unsigned char __stop = 0; unsigned char __stop_zmq_thread = 0; -/// @brief Path of the break file (if found, publisher will stop publishing) -char __break_file[STATIC_LEN]; - /** * @brief Stop process properly on SIGINT * @@ -36,14 +33,14 @@ void sighandler(int signo) { void *publisher(void *zmq_publisher); -void askforbreak(){ +void askforbreak(char *break_file){ FILE * file; - file = fopen(__break_file, "r"); + file = fopen(break_file, "r"); while(file){ printf("I am doing a break for %ds", BREAK_DURATION); usleep(BREAK_DURATION * 1000); fclose(file); - file = fopen(__break_file, "r"); + file = fopen(break_file, "r"); } } @@ -76,11 +73,12 @@ int main(int argc, char *argv[]) { strcat(regpower, "/"); strcat(regpower, INA260_POWER_OUTPUT); - // __break_file - strcat(__break_file, "publisher_"); - strcat(__break_file, key); - strcat(__break_file, "_break"); - printf("%s\n",__break_file); + // Path of the break file (if found, publisher will stop publishing) + char break_file[STATIC_LEN]; + strcat(break_file, "publisher_"); + strcat(break_file, key); + strcat(break_file, "_break"); + printf("Create to following file to stop publishing (max wakeup latency will be %ds): %s\n",BREAK_DURATION,break_file); //----- Sanity checks signal(SIGINT, sighandler); @@ -124,7 +122,7 @@ int main(int argc, char *argv[]) { printf("Logger started [client=%s,interval=%ds]\n", client, loginterval); while (!__stop) { // Check whether logging must be stopped - askforbreak(); + askforbreak(break_file); // Busy wait: while (queues[queue_id].issending) {} // Get current interval |
