#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#include <time.h>
#include <unistd.h>
#include <modbus.h>
va_end(args);
}
-static void mqtt_log_callback(struct mosquitto *mosq UNUSED, void *obj UNUSED, int level, const char *message)
+static void mqtt_log_callback(struct mosquitto *mosq UNUSED, void *obj UNUSED, int level UNUSED, const char *message UNUSED)
{
// msg(L_INFO, "MQTT(%d): %s", level, message);
}
if (modbus)
return true;
- // FIXME: Find the right device. Reconnect if needed.
- modbus = modbus_new_rtu("/dev/ttyUSB0", 9600, 'N', 8, 1);
+ modbus = modbus_new_rtu("/dev/modbus-power", 9600, 'N', 8, 1);
if (!modbus) {
mb_error("open");
return false;
}
mb_is_open = true;
+ return true;
}
/*** Main loop ***/
static u16 mb_regs[22];
-s32 get_s32(uint i)
+static s32 get_s32(uint i)
{
if (mb_regs[i+1] < 0x8000)
return (mb_regs[i+1] << 16) | mb_regs[i];