stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.42k stars 1.74k forks source link

Set response timeout causes segmentation fault #403

Closed IlhanSeven closed 6 years ago

IlhanSeven commented 6 years ago

Platform: Beaglebone Black Angstrom linux libmodbus: latest version

ctx = modbus_new_rtu("/dev/ttyO4", 9600, 'N', 8, 1); modbus_rtu_set_serial_mode(ctx, MODBUS_RTU_RS485); modbus_set_slave(ctx, 2); modbus_set_debug(ctx, 1); modbus_set_response_timeout(ctx, 0, 200000);

Commenting out the last line -> no seg fault.

What could be the reason? Thanks for this work. It is quite useful. Ilhan

stephane commented 6 years ago

The API has changed between http://libmodbus.org/docs/v3.0.6/modbus_set_response_timeout.html http://libmodbus.org/docs/v3.1.4/modbus_set_response_timeout.html

Could you really check you use the latest version by printing it? You could find an example here: https://github.com/stephane/libmodbus/blob/master/tests/version.c

IlhanSeven commented 6 years ago

Hi,

I could not compile it I am sorry. This is the output:

versionn.c:6:85: error: 'LIBMODBUS_MAJOR_VERSION' undeclared (first use in this function) versionn.c:6:85: note: each undeclared identifier is reported only once for each function it appears in versionn.c:6:85: error: 'LIBMODBUS_MINOR_VERSION' undeclared (first use in this function) versionn.c:6:85: error: 'LIBMODBUS_MICRO_VERSION' undeclared (first use in this function)

By the way I installed the library with opkg by opkg install libmodbus5

Thanks Ilhan

zzeroo commented 6 years ago

@IlhanSeven I bet this is libmodbus version 3.0.6. You have to use this API then: http://libmodbus.org/docs/v3.0.6/modbus_set_response_timeout.html

Because: https://reposcope.com/package/libmodbus5

IlhanSeven commented 6 years ago

Thanks guys, I figured my version is 3.0.3. It was a version collision. Issue now can be closed. Although my CRC error, timeout issues persist.

Cheers.

stephane commented 6 years ago

Could you close it, please?

Le 27 sept. 2017 21:02, "Ilhan Seven" notifications@github.com a écrit :

Thanks guys, I figured my version is 3.0.3. It was a version collision. Issue now can be closed. Although my CRC error, timeout issues persist.

Cheers.

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/stephane/libmodbus/issues/403#issuecomment-332623276, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAHF8JMFySPpfSKNpVKCeJNRWaGh2krks5smpvhgaJpZM4PlBs2 .

IlhanSeven commented 6 years ago

Thanks