Arexx Data Logger Daemon
- (c) 2011--2018 Martin Mares <mj@ucw.cz>
+ (c) 2011--2020 Martin Mares <mj@ucw.cz>
You can use and distribute this program under the terms of GPLv2.
This package contains a daemon (arexxd), which watches USB and whenever the
data logger is connected, it downloads all data points from its memory and
continues fetching all further measurements in real time. Also, it synchronizes
-the clock of the logger to the system time. The data points are stored in a RRD
-database (see http://oss.oetiker.ch/rrdtool/), but you can easily tweak the
-source to process the data in any way you like.
+the clock of the logger to the system time.
+
+The data points can be stored in a RRD database (see http://oss.oetiker.ch/rrdtool/)
+or sent to InfluxDB (this is configured rather crudely in the source code).
+You can easily tweak the source to process the data in any way you like.
This program is not supported or endorsed by AREXX in any way. Also, there is
no warranty on what it does or does not. However, if you have any bug reports
/*
* Linux Interfece for Arexx Data Loggers
*
- * (c) 2011-2018 Martin Mares <mj@ucw.cz>
+ * (c) 2011-2020 Martin Mares <mj@ucw.cz>
*/
#include <stdio.h>
#define MAX_FUTURE_TIME 300
#define IGNORE_UNKNOWN_SENSORS
+#undef LOG_TO_RRD
+#undef LOG_TO_MQTT
+
typedef unsigned char byte;
typedef unsigned int uint;
static libusb_context *usb_ctxt;
/*** MQTT interface ***/
+#ifdef LOG_TO_MQTT
+
#include <mosquitto.h>
static struct mosquitto *mosq;
mqtt_publish(topic, "%.3f %lld", val, (long long) t);
}
+#endif
+
/*** RRD interface ***/
+#ifdef LOG_TO_RRD
+
#include <rrd.h>
#define MAX_ARGS 20
}
}
+#endif
+
/*** Transforms ***/
#define TIME_OFFSET 946681200 // Timestamp of 2000-01-01 00:00:00
}
data_point_counter++;
+#ifdef LOG_TO_RRD
rrd_point(t, name, val2, unit);
+#endif
+#ifdef LOG_TO_MQTT
mqtt_point(t, name, val2, unit);
+#endif
}
static void raw_point(uint t, uint id, int raw, int q)
use_syslog = 1;
}
+#ifdef LOG_TO_MQTT
mqtt_init();
+#endif
struct sigaction sa = { .sa_handler = sigterm_handler };
sigaction(SIGTERM, &sa, NULL);