Hi I'm trying to use the hello world example of ZMQ over a serial radio using ser2net. However, when binding to the port it complains "port is already in use", the only other application using that is ser2net which, from my understanding, is providing that port. The client works as expected, its just the server that complains.
How would I configure ser2net over two serial ports say /dev/ttyUSB0 and /dev/ttyUSB1 such that zmq can properly bind to the provided ports. My ser2net.conf file:
localhost,5557:raw:0:/dev/ttyUSB0:57600 8DATABITS NONE 1STOPBIT
localhost,5556:raw:0:/dev/ttyUSB1:57600 8DATABITS NONE 1STOPBIT
The zmq client and server are: server.py
import time
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
socket.bind("tcp://*:5557")
while True:
# Wait for next request from client
message = socket.recv()
print(f"Received request: {message}")
# Do some 'work'
time.sleep(1)
# Send reply back to client
socket.send_string("World")
client.py:
import zmq
context = zmq.Context()
# Socket to talk to server
print("Connecting to hello world server...")
socket = context.socket(zmq.REQ)
socket.connect("tcp://localhost:5556")
# Do 10 requests, waiting each time for a response
for request in range(10):
print(f"Sending request {request} ...")
socket.send_string("Hello")
# Get the reply.
message = socket.recv()
print(f"Received reply {request} [ {message} ]")
thanks to @larsks comment. ser2net is not used for this application. Using pppd instead. I also had to use two separate computers for this test as routing was direct if both serial ports were connected to the one computer
pppd configure: Terminal 1:
Terminal 2:
If I run ifconfig these two interfaces show up:
So reconfigure my server and client (just showing the line that changed): Server.py
client.py