Linux serial port software loop

Currently, I need to develop a program that will communicate with cisco devices on a serial line. I want to create a test environment on my linux development machine. So, I found a dynamic cisco emulator. This emulator can provide an interface via a serial line with the -U / dev / ttyS0 option. Well, this makes the speakers open the hardware serial port and exchange data through it. I can connect to this hardware serial port from another Linux device with a serial client like minicom.

However, since I use virtual boxing for both Linux machines, I bind serial ports using the virtual boxing feature to forward the serial port to the named pipe. This circuit seems to work, but is very rich. I am looking for a method to run dynamips and minicom on the same Linux machine.

I found that pseudo-terminals can be useful in my case. But I tried to run dynamips using "-U / dev / ptmx" and then connect using minicom to the created / dev / pts / ... port and vice versa. In both cases, I have an I / O error on both sides.

+4
source share
1 answer

Unfortunately, modern pseudo-terminals are not so simple. After opening the wizard using posix_openpt() or open("/dev/ptmx") , you must call grantpt() and unlockpt() on the main FD in front of it and its corresponding slave. (Utilities of the openpty() function, etc. Simplify this.)

Socat may be useful as a workaround.

  # terminal 1
 socat pty: link = $ PWD / pts unix-l: $ PWD / ptm-pipe &
 dynamips -U $ PWD / pts

 # terminal 2
 socat unix: $ PWD / ptm-pipe -
+6
source

Source: https://habr.com/ru/post/1300184/


All Articles