mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-05 11:26: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);
|
||||
// Log current interval
|
||||
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';
|
||||
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);
|
||||
// Monitor:
|
||||
while((TIMESTAMP()-interval)<__loginterval){
|
||||
if(__stop)
|
||||
break;
|
||||
|
@ -114,6 +115,7 @@ int main (int argc, char *argv [])
|
|||
fgets(buffer,STATIC_LEN,regptr);
|
||||
// Get power measurement timestamp:
|
||||
clock_gettime(CLOCK_REALTIME,&power_ts);
|
||||
// Write measurement into msg buffer:
|
||||
char line[MAX_RECORD_LEN];
|
||||
if((queues[queue_id].size+MAX_RECORD_LEN)>ZMQ_MSG_SIZE){
|
||||
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){
|
||||
printf("Publishing...\n");
|
||||
printf("Publishing...");
|
||||
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