mirror of
https://gitlab.com/manzerbredes/ina260-zmq-publisher.git
synced 2025-04-07 04:16:26 +02:00
Minor changes
This commit is contained in:
parent
5f0585f4d4
commit
0c08c2f0d8
1 changed files with 4 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#include <stdio.h>
|
||||||
#include <zmq.h>
|
#include <zmq.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
@ -39,7 +40,7 @@ typedef struct record {
|
||||||
|
|
||||||
typedef struct queue {
|
typedef struct queue {
|
||||||
int length;
|
int length;
|
||||||
int interval;
|
long interval;
|
||||||
record records[RECORD_MAX];
|
record records[RECORD_MAX];
|
||||||
} queue;
|
} queue;
|
||||||
|
|
||||||
|
@ -149,13 +150,14 @@ void publish(int queue_id){
|
||||||
// Build message header:
|
// Build message header:
|
||||||
char buffer[ZMQ_MSG_SIZE];
|
char buffer[ZMQ_MSG_SIZE];
|
||||||
sprintf(buffer,"%s\n%s\n%s\n%ld\n",ZMQ_TOKEN,__key,__client,queues[queue_id].interval);
|
sprintf(buffer,"%s\n%s\n%s\n%ld\n",ZMQ_TOKEN,__key,__client,queues[queue_id].interval);
|
||||||
|
printf(buffer);
|
||||||
int msglen=strlen(buffer);
|
int msglen=strlen(buffer);
|
||||||
|
|
||||||
// Put every lines in the buffer and send it
|
// Put every lines in the buffer and send it
|
||||||
char line[STATIC_LEN];
|
char line[STATIC_LEN];
|
||||||
for(int record=0;record<queues[queue_id].length;record++){
|
for(int record=0;record<queues[queue_id].length;record++){
|
||||||
*line='\0';
|
*line='\0';
|
||||||
sprintf(line,"%d,%ld,%d",queues[queue_id].records[record].secs,queues[queue_id].records[record].nsecs,queues[queue_id].records[record].power);
|
sprintf(line,"%ld,%ld,%d",queues[queue_id].records[record].secs,queues[queue_id].records[record].nsecs,queues[queue_id].records[record].power);
|
||||||
int linelength=strlen(line);
|
int linelength=strlen(line);
|
||||||
if((linelength+msglen) <ZMQ_MSG_SIZE){
|
if((linelength+msglen) <ZMQ_MSG_SIZE){
|
||||||
strcat(buffer,line);
|
strcat(buffer,line);
|
||||||
|
|
Loading…
Add table
Reference in a new issue