TCP Server not working on Raspi

57 views
Skip to first unread message

Dnr Sys

unread,
Feb 17, 2021, 1:39:14 PM2/17/21
to libmodbus
Hi,

I'm currently trying ton integrate a modbus server on a raspberry pi 3B+ on raspbian.

I successfully used libmodbus to create a TCP client connecting to a remote display.

But I can't find a way to make TCP server work, wether I specify the acccepted ip address
with modbus_new_tcp or not.
It always blocks on modbus_tcp_listen. And when I try to connect to the server using Qt modbus-master example, it indicates that my request was rejected.

Even make check fails (see the log below) whereas "sudo netstat -lptu" returns tcp        0      0 127.0.0.0:1502          0.0.0.0:*               LISTEN      15193/unit-test-ser :

===========================================
   libmodbus 3.1.6: tests/test-suite.log
===========================================

# TOTAL: 1
# PASS:  0
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

FAIL: ./unit-tests.sh
=====================

Starting server
Starting client
unit-test-server: no process found
FAIL unit-tests.sh (exit status: 255)

Is there something I did wrong, or anything else to check to find a way out of this ?
Thanks in advance,
Thibault

ZipperSnake

unread,
Feb 19, 2021, 7:55:13 AM2/19/21
to libm...@googlegroups.com
Hi,

I can't see if anybody answered yet on this, but here are my two cents:
Do you have a firewall going? Then it may stop you from connecting, not sure how it looks like when setting up a listen socket though.

Only root user may open ports below a certain number, don't remember where it starts, but look it up.
Try the sudo in front as with netstat?

I also don't remember how the tcp server works, maybe it should block on listen - until somebody connects (and here the firewall may block that)? That is common in other servers, I think:
Listen
Somebody connects
Accept connection
"fork off" that connection on another socket/port, have it run in a separate thread
Go back to Listen to handle multiple requests/connections concurrently

Hope it helps some,
   Hans


--
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+...@googlegroups.com.
Cette discussion peut être lue sur le Web à l'adresse https://groups.google.com/d/msgid/libmodbus/c6086dc9-6309-4fd6-9b79-35555cc13a47n%40googlegroups.com.

Dnr Sys

unread,
Feb 22, 2021, 10:28:56 AM2/22/21
to libmodbus
Hi,

Thanks for your reply.

I didn't setup no firewalls on my pi, so i don't think it could be why it doesn't work.

I've tried changing uni-tests.sh, adding sudo to its command line launching both server and client before calling it with sudo sh. But nothing changed from my previous results.

Does anyone has another idea to help me getting out of this ?
Reply all
Reply to author
Forward
0 new messages