Hi all,<br><br>I also stumbled across the modbus segfault (collectd 5.0.1 / libmodbus 3.0.1 / gentoo, both i386 & x86_64).<br><br>The problem is that host->connection is simply never initialized in mb_read_data() before being passed to libmodbus.<br>
The only place mb_init_connection() is called is from within the reconnection loop below.<br><br>Adding this before the call to modbus_set_slave() makes the crash go away:<br><br> if (host->connection == NULL)<br> {<br>
status = mb_init_connection (host);<br> if (status != 0)<br> {<br> ERROR ("Modbus plugin: mb_init_connection (%s/%s) failed. ",<br> host->host, host->node);<br> return (-1);<br>
}<br> }<br><br>As I'm reading float values I also had to modify mb_register_to_float() to get what I was expecting.<br>But not sure whether this is due to running on a 64bit machine or just my PLC being backwards.<br>
What I'm doing is<br><br>static float mb_register_to_float (uint16_t hi, uint16_t lo) /* {{{ */<br>{<br> union<br> {<br> uint8_t b[4];<br> uint16_t s[2];<br> float f;<br> } conv;<br><br>#if BYTE_ORDER == LITTLE_ENDIAN<br>
conv.s[0] = hi;<br> conv.s[1] = lo;<br>#else<br>...<br><br>-- <br>Cheers, Stefan<br>