I'm working on embedded ARM platform, Slackware. I'm using G24 Java modem which is configured to forward data between ports /dev/ttyS1
and /dev/ttyACM0
, so anything that goes onto any of these ports is then visible on the other. I want to set terminal on one of these ports, /dev/ttyS1
and forward the other port, /dev/ACM0
to the TCP port, so it can be accessed from other machine via LAN.
First of all, I configured /etc/inittab
:
s2:12345:respawn:/sbin/agetty -L ttyS1 115200 vt100
Then I'm trying to use socat with following command:
socat -d -d -d TCP-l:2020,reuseaddr,fork /dev/ttyACM0,raw,nonblock,waitlock="/var/run/ttyACM0.lock",b115200,echo=1,icanon=1,crnl
Then I'm trying to connect with telnet 192.168.1.222 2020
from other machine, the result is not quite good, I see from the client side that terminal is asking for login, but then there is an immediate answer which I haven't typed in: ^M^M^M
... etc., the terminal is answering that the login is incorrect and then again and again the same thing.
I know that ^M
means carriage return sign, but I'm not quite sure how to fix that problem.
I have tried different configurations of socat, but none of them worked correctly.
After few more hours of intensive research and testing many different options I came with a solution.
First of all, I had to enable terminal by adding line:
ttyS1
in file
/etc/securetty
.Without this you cannot login to terminal at
/dev/ttyS1
.Secondly, I tested many different socat configurations and the following command works:
/usr/local/bin/socat tcp-l:2020,reuseaddr,fork,crlf file:/dev/ttyACM0,echo=0,b115200,raw,crnl,icanon=1
However, this solution isn't perfect. Terminal breaks line after every command prompt so the user input is typed in the next line. Furthermore, after executing each command appears an empty command prompt (like I had entered empty command immediately after the one I had really entered).
I suppose that I should configure
/dev/ttyACM0
properly with stty, but I'm still researching the topic.