author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 26 Feb 2016 21:53:19 +0000 (22:53 +0100) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 26 Feb 2016 21:53:19 +0000 (22:53 +0100) |
1 | 2 | |||
---|---|---|---|---|
configure.ac | patch | | diff1 | | diff2 | | blob | history |
src/apache.c | patch | | diff1 | | diff2 | | blob | history |
src/collectd.conf.in | patch | | diff1 | | diff2 | | blob | history |
src/modbus.c | patch | | diff1 | | diff2 | | blob | history |
diff --cc configure.ac
Simple merge
diff --cc src/apache.c
Simple merge
diff --cc src/collectd.conf.in
Simple merge
diff --cc src/modbus.c
index 97b98b7c96c9f32feeda38122ab1c5970cd55b23,7349dc564976b2a91aa44b7bb760e8d33a9bf4e0..c04b308d81728e74f4621737b64fb394eb47430d
--- 1/src/modbus.c
--- 2/src/modbus.c
+++ b/src/modbus.c
if (host->connection != NULL)
return (0);
- if ((host->port < 1) || (host->port > 65535))
- host->port = MODBUS_TCP_DEFAULT_PORT;
+ if (host->conntype == MBCONN_TCP)
+ {
+ if ((host->port < 1) || (host->port > 65535))
+ host->port = MODBUS_TCP_DEFAULT_PORT;
- DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
- host->node, host->port);
+ DEBUG ("Modbus plugin: Trying to connect to \"%s\", port %i.",
+ host->node, host->port);
- host->connection = modbus_new_tcp (host->node, host->port);
- if (host->connection == NULL)
+ host->connection = modbus_new_tcp (host->node, host->port);
+ if (host->connection == NULL)
+ {
+ ERROR ("Modbus plugin: Creating new Modbus/TCP object failed.");
+ return (-1);
+ }
+ }
+ else
{
- ERROR ("Modbus plugin: Creating new Modbus/TCP object failed.");
- return (-1);
+ DEBUG ("Modbus plugin: Trying to connect to \"%s\", baudrate %i.",
+ host->node, host->baudrate);
+
+ host->connection = modbus_new_rtu (host->node, host->baudrate, 'N', 8, 1);
+ if (host->connection == NULL)
+ {
+ ERROR ("Modbus plugin: Creating new Modbus/RTU object failed.");
+ return (-1);
+ }
}
+ #if COLLECT_DEBUG
modbus_set_debug (host->connection, 1);
+ #endif
/* We'll do the error handling ourselves. */
modbus_set_error_recovery (host->connection, 0);