Dec 1, 2019

Linux ser2net: no connection to /dev/ttyUSB0

If you are running some java application on a Linux box (especially ARM architecture) and this application accesses the serial interface (/dev/ttyUSB0, /dev/ttyUSB1 or just /dev/ttyX), then a easy way to do this, is running ser2net.

For all who are not familiar with the serial port:

But there is one tricky thing, you have to consider when using ser2net:

Inside ser2net.conf you will find some lines like this here:
15000:raw:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT 
This means: on port tcp 15000 you can access the serial port /dev/ttyUSB0 (if you have a USB to serial adapter in place).

If this does not work, check the ports with
root@ubuntu:/home/ubuntu/dfld# netstat -lntup |grep ser2net
tcp6       0      0 :::15000                :::*                    LISTEN      1361/ser2net        
As you can see, it only listens on TCP6. So you have to reconfigure this to,15000:raw:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT
If you only want to access this on localhost (which is very nice security enhancement ;-) ).
And after a restart of ser2net everything works like expected:

root@ubuntu:/home/ubuntu/dfld# netstat -lntup |grep ser2net

tcp        0      0*               LISTEN      

No comments:

Post a Comment