Serial device paths more than 10 chars long (eg. /dev/ttyUSB0) don't fit to modbus_param_t -> device char[11] var.

Bug #161989 reported by Konstantinos Togias on 2007-11-11
Affects Status Importance Assigned to Milestone
Status tracked in Trunk
Fix Released
Stéphane Raimbault
Fix Released
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.

Stéphane Raimbault (sra) wrote :

Thanks for your bug report!
Fix released in 1.2.2.

Changed in libmodbus:
assignee: nobody → sra
importance: Undecided → Medium
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers