Serial device paths more than 10 chars long (eg. /dev/ttyUSB0) don't fit to modbus_param_t -> device char[11] var.
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
libmodbus | Status tracked in Trunk | |||||
1.2 |
Fix Released
|
Medium
|
Stéphane Raimbault | |||
Trunk |
Fix Released
|
Medium
|
Stéphane Raimbault |
Bug Description
I use your libmodbus library for a project of mine. In order to test the code at my laptop that does not provide a native serial port I bough a USB2Serial converter. The device that this gadget creates is /dev/ttyUSB0 (/dev/ttyUSB1 etc for more USB2Serial converters connected). When I tryed test-modbus I got errors at opening the port telling that the device path doesn't exist... After some debugging I found out that the cause of the problem was the declaration of device var of struct _modbus_param_t in modbus.h line 93:
char device[11];
As it is obvious the string "/dev/ttyUSB0" is 12 chars long and thus it does not fit into modbus_param_t -> device . I augmented the size of modbus_param_t -> device to 20 that is a more safe (IMHO) number. All the tests I performed with device[20] and ttyS* and ttyUSB* serial devices where successful. So I find changing the device size to 20 (or some smaller but at least more than 12 number) at next version of the lib should be good.
Thanks for your bug report!
Fix released in 1.2.2.