Patches for FreeBSD

Bug #457200 reported by Norbert Koch
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libmodbus
Fix Released
Low
Stéphane Raimbault

Bug Description

As I would like to use libmodbus under FreeBSD I did some testing today.
With the attached patches I can run the programs under tests/
on the following systems:

FreeBSD 4.11 / gcc 2.95.4
FreeBSD 8.0RC1 / gcc 4.2.1

So far I did only test local host network communication,
not serial communication.

Related branches

Revision history for this message
Norbert Koch (nkoch) wrote :
Revision history for this message
Norbert Koch (nkoch) wrote :

FYI, I did some modbus-rtu tests:

Operating systems
Unit1: Windows XP COM1
Unit2: FreeBSD 4.11, /dev/cuaa0 (COM1)
Unit3: FreeBSD 4.11, /dev/cuaa0 (COM1)

Software:
Sw1: QModbus 0.1.1 @ Unit1 (libmodbus-based)
Sw2: random-test-master(rtu, "/dev/cuaa0", 9600BpS) @ Unit2
Sw3: random-test-slave(rtu, "/dev/cuaa0", 9600BpS) @ Unit3
Sw4: known-to-work modbus slave software @ Unit3 (not libmodbus-based)
Sw5: 'cat /dev/cuaa0 | hd' @ Unit3

1: Sw1 --> Sw4 : ok
2: Sw1 --> Sw3 : not ok, Timeout
3: Sw2 --> Sw3: not ok, Timeout
4: Sw2 --> Sw4: not ok, Timeout
5: Sw2 --> Sw5: I can see correct request messages arriving

I compared termios settings to serial.cpp in
platform independant library CommonC++
which is used in Sw4:
1. They first open with O_RDWR|O_NDELAY
2. They set HUPCL in c_cflag.
3. They set c_cc[VMIN]=1, NOT to 0.
4. They set c_cc[VEOL]=c_cc[VEOL2] = 0
5. After tcsetattr they do fcntl ~O_NDELAY
But as, they do poll (=select) before reading,
I see no reason why this should make a
difference.

Revision history for this message
Stéphane Raimbault (sra) wrote :

Your patch is cool, committed on trunk (I've used IPPROTO_IP under linux too, it's only used as level).

<rant>
The QModbus author has chosen to copy libmodbus inside his project and he didn't contact me so his project doesn't contain bugfixes or new features from upstream. Even more, he has found a bug in the lib and he didn't report it to libmodbus project (we've found it by ourselves in the meantime).
</rant>

I don't have the hardware the test RTU (it isn't so hard to find USBserial, old pc etc but I need free time too), so sw3 doesn't exist (the API on slave is more clear on trunk)! The slave mode works only for TCP connection, I think it's not too hard and I'll happy to include that feature for the 2.2.0 release.

Revision history for this message
Norbert Koch (nkoch) wrote : Re: [Bug 457200] Re: Patches for FreeBSD

Stéphane Raimbault schrieb:
> Your patch is cool, committed on trunk (I've used IPPROTO_IP under linux
> too, it's only used as level).
>
> <rant>
> The QModbus author has chosen to copy libmodbus inside his project and he didn't contact me so his project doesn't contain bugfixes or new features from upstream. Even more, he has found a bug in the lib and he didn't report it to libmodbus project (we've found it by ourselves in the meantime).
> </rant>
>
> I don't have the hardware the test RTU (it isn't so hard to find
> USBserial, old pc etc but I need free time too), so sw3 doesn't exist
> (the API on slave is more clear on trunk)! The slave mode works only for
> TCP connection, I think it's not too hard and I'll happy to include that
> feature for the 2.2.0 release.
>
>
Hello,
thanks for committing my patches.
For me, it is important that Modbus TCP works under FreeBSD.

But you can contact me if you need a tester for Modbus RTU.
We still have enough hardware with RS232 interfaces and our
own Modbus RTU master/slave implementations as reference.

Changed in libmodbus:
status: New → Fix Released
importance: Undecided → Low
assignee: nobody → Stéphane Raimbault (sra)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.