mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-06 03:46:25 +02:00
Minor changes
This commit is contained in:
parent
a6a3304fed
commit
11c495d26f
1 changed files with 5 additions and 3 deletions
|
@ -103,10 +103,11 @@ int main (int argc, char *argv [])
|
||||||
interval=INTERVAL(__loginterval);
|
interval=INTERVAL(__loginterval);
|
||||||
// Log current interval
|
// Log current interval
|
||||||
queue_id=(queue_id+1)>=MAX_QUEUES ? 0 : (queue_id+1);
|
queue_id=(queue_id+1)>=MAX_QUEUES ? 0 : (queue_id+1);
|
||||||
printf("Queue id %d",queue_id);
|
// Write msg header:
|
||||||
*queues[queue_id].msg='\0';
|
*queues[queue_id].msg='\0';
|
||||||
sprintf(queues[queue_id].msg,"%s\n%s\n%s\n%ld\n",ZMQ_TOKEN,__key,__client,interval);
|
sprintf(queues[queue_id].msg,"%s\n%s\n%s\n%ld\n",ZMQ_TOKEN,__key,__client,interval);
|
||||||
queues[queue_id].size=strlen(queues[queue_id].msg);
|
queues[queue_id].size=strlen(queues[queue_id].msg);
|
||||||
|
// Monitor:
|
||||||
while((TIMESTAMP()-interval)<__loginterval){
|
while((TIMESTAMP()-interval)<__loginterval){
|
||||||
if(__stop)
|
if(__stop)
|
||||||
break;
|
break;
|
||||||
|
@ -114,6 +115,7 @@ int main (int argc, char *argv [])
|
||||||
fgets(buffer,STATIC_LEN,regptr);
|
fgets(buffer,STATIC_LEN,regptr);
|
||||||
// Get power measurement timestamp:
|
// Get power measurement timestamp:
|
||||||
clock_gettime(CLOCK_REALTIME,&power_ts);
|
clock_gettime(CLOCK_REALTIME,&power_ts);
|
||||||
|
// Write measurement into msg buffer:
|
||||||
char line[MAX_RECORD_LEN];
|
char line[MAX_RECORD_LEN];
|
||||||
if((queues[queue_id].size+MAX_RECORD_LEN)>ZMQ_MSG_SIZE){
|
if((queues[queue_id].size+MAX_RECORD_LEN)>ZMQ_MSG_SIZE){
|
||||||
printf("To many measurements to publish. Please increase ZMQ_MSG_SIZE\n");
|
printf("To many measurements to publish. Please increase ZMQ_MSG_SIZE\n");
|
||||||
|
@ -140,7 +142,7 @@ int main (int argc, char *argv [])
|
||||||
|
|
||||||
|
|
||||||
void publish(int queue_id, void* publisher){
|
void publish(int queue_id, void* publisher){
|
||||||
printf("Publishing...\n");
|
printf("Publishing...");
|
||||||
zmq_send(publisher,queues[queue_id].msg,queues[queue_id].size,0);
|
zmq_send(publisher,queues[queue_id].msg,queues[queue_id].size,0);
|
||||||
printf("Done\n");
|
printf("done\n");
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue