summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2024-02-02 13:17:07 +0100
committerLoic Guegan <loic.guegan@mailbox.org>2024-02-02 13:17:07 +0100
commit72d6ef9ec6893f98630e46c70cf8cefba4c4fa80 (patch)
treeff6675e4c87aa91e981bc66880839b3e9ed54314 /src
parent1e8c15ca87a6df0305396dacc267ba65d28c8631 (diff)
Minor changes
Diffstat (limited to 'src')
-rw-r--r--src/publisher.c12
-rw-r--r--src/utils.h3
2 files changed, 12 insertions, 3 deletions
diff --git a/src/publisher.c b/src/publisher.c
index db93e63..309cf6b 100644
--- a/src/publisher.c
+++ b/src/publisher.c
@@ -37,7 +37,13 @@ void sighandler(int signo) {
void *publisher(void *zmq_publisher);
void askforbreak(){
-
+ FILE * file;
+ file = fopen(__break_file, "r");
+ while(file){
+ usleep(BREAK_DURATION * 1000);
+ fclose(file);
+ file = fopen(__break_file, "r");
+ }
}
typedef struct queue {
@@ -70,7 +76,7 @@ int main(int argc, char *argv[]) {
strcat(regpower, INA260_POWER_OUTPUT);
// __break_file
- strcat(__break_file, "/publisher_");
+ strcat(__break_file, "publisher_");
strcat(__break_file, key);
strcat(__break_file, "_break");
printf("%s\n",__break_file);
@@ -116,6 +122,8 @@ int main(int argc, char *argv[]) {
//----- Start logging
printf("Logger started [client=%s,interval=%ds]\n", client, loginterval);
while (!__stop) {
+ // Check whether logging must be stopped
+ askforbreak();
// Busy wait:
while (queues[queue_id].issending) {}
// Get current interval
diff --git a/src/utils.h b/src/utils.h
index 1932f11..fbade91 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -12,6 +12,7 @@
#define STATIC_LEN 255
#define MAX_RECORD_LEN 100
#define CSV_HEADER "timestamp,nsecs,power"
+#define BREAK_DURATION 10
#ifndef MAX_QUEUES
#define MAX_QUEUES 1
@@ -38,4 +39,4 @@
#define DIR_EXISTS(path) (dir_exists(path))
void mkdirp(char *path);
-unsigned char dir_exists(char *path); \ No newline at end of file
+unsigned char dir_exists(char *path);