I'd like to run unit-test-server tcp on one R-pi and unit-test-client tcp on another but the unit-tests are only set up for loopback tests.

232 views
Skip to first unread message

Bob Kruse

unread,
Mar 1, 2017, 5:23:58 PM3/1/17
to libmodbus
Hello,

I'm evaluating hardware for a system where a master pi3 would communicate with a slave dsp board over Ethernet, likely as not with Modbus tcp.

I followed the steps at https://github.com/stephane/libmodbus/wiki/Libmodbus-on-Raspberry-pi, it built and the unit tests ran nicely between two windows on the same pi.

I added avahi-daemon and avahi-auto-ipd and connected the PIs together.
ifconfig told me the addresses, and I can ping between them.
I edited unit-test-server.c on one pi and unit-test-client.c on the other.
I changed the line "ctx = Modbus_new_tcp("127.0.0.1",1502);" in each PI to use the correct IP address for the other PI.

sudo make install in both ~/libmodbus folders.

When I run ./unit-test-server  tcp in the one PI the response is
"Waiting for a indication"
But when I ran ./unit-test-client tcp on the other I get
"Connecting to 169.254.162.182:1502 
Connection failed: Connection refused"

I thought maybe johnneren's patch (https://github.com/johnneren/libmodbus) would help, but I got the same result.

Can anyone suggest how I can run the unit tests between a libmodbus server on one PI and a libmodbus client on another PI?
 
Thank you,
Bob

Bob Kruse

unread,
Mar 2, 2017, 9:28:10 AM3/2/17
to libmodbus
I received the suggestion that I change the :
-server.c line "ctx = Modbus_new_tcp("127.0.0.1",1502);" to line "ctx = Modbus_new_tcp("0.0.0.0",1502);"
-client.c line to "ctx = Modbus_new_tcp("addr",1502);" where addr is the address reported by the servers ifconfig.

This worked and ran unit-test-client on one pi and unit-test-server on the other.

Stéphane Raimbault

unread,
Mar 2, 2017, 10:48:20 AM3/2/17
to libm...@googlegroups.com

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "libmodbus".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse libmodbus+unsubscribe@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages