7

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.

3
  • I think it is an echo. Can you please try to disable echo in socat command and test again? Feb 15, 2012 at 13:30
  • I've tried that already, but it won't work. I'm closer to the solution a bit: I now use shorter socat command: socat tcp-l:54321,reuseaddr,fork file:/dev/ttyACM0,echo=0,raw,echo=0,crnl,icanon=1. Now there are no ^M's, but there is a double echo effect-for every command i enter with telnet I get two empty root@arm:~#
    – Wookie88
    Feb 15, 2012 at 13:54
  • What about another serial redirection solution like "remserial" (see Serial port forwarding over TCP/IP) ?
    – Ouki
    Feb 15, 2012 at 17:18

1 Answer 1

4

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.

2
  • Just to check. Have you tried socat without crnl and crlf options or combination of them. And try it with nc instead of telnet like nc 192.168.1.222 2020
    – Manwe
    Feb 18, 2012 at 13:44
  • Thanks for your comment, I have tried both crnl/crlf combinations and connecting with netcat with no better effects.
    – Wookie88
    Feb 20, 2012 at 17:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .