From 08801ea922ad6b2cf23ae52c891e2324442b05fa Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 10 Feb 2021 16:17:39 +0100 Subject: [PATCH] fixes --- sink/Makefile | 2 +- sink/sink20169.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sink/Makefile b/sink/Makefile index a98f1be..f196ca7 100644 --- a/sink/Makefile +++ b/sink/Makefile @@ -12,7 +12,7 @@ C_INCLUDES = \ CC = gcc CFLAGS = $(C_INCLUDES) -Wall -Werror -std=c99 -LDFLAGS = -lconfig +LDFLAGS = -lconfig -lcurl TARGET = sink20169 UNAME_S := $(shell uname -s) diff --git a/sink/sink20169.c b/sink/sink20169.c index 158f1a0..b2768ef 100644 --- a/sink/sink20169.c +++ b/sink/sink20169.c @@ -223,17 +223,17 @@ int forwardMinuteBuffer(t_forwarderHandle *handle, t_minuteBuffer *buf) { int frequency_before_point = buf->s.events[j].frequency / 1000; int frequency_behind_point = buf->s.events[j].frequency - (frequency_before_point * 1000); - char buf[256]; - int res = snprintf(buf, sizeof(buf), - "%s,valid=1,location=%s,host=%s freq=%d.%d %lu", + char payload[256]; + int res = snprintf(payload, sizeof(payload), + "%s,valid=1,location=%s,host=%s freq=%d.%03d %lu", handle->influxMeasurement, buf->s.location, buf->s.deviceId, frequency_before_point, frequency_behind_point, buf->s.events[j].timestamp); - if (res > sizeof(buf)) { + if (res > sizeof(payload)) { logmsg(LOG_ERR, "payload buffer to small"); return -1; } - logmsg(LOG_INFO, "Payload: %s", buf); + logmsg(LOG_INFO, "Payload: %s", payload); } return 0;