Forwarding linux terminal from serial port to TCP with socat

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.