5

I have network device that serves up a telnet/RFC2217 (virtual serial port) interface. On Linux, how do I create a virtual tty that connects to this thing? If I understand correctly, socat doesn't really support telnet and does not support RFC2217.

2
  • Maybe mention what programs you're expecting to use with that virtual tty. I'm asking because a pty solution (whatever socat-like / user-mode) will not work with programs that try to do serial ioctls (eg. TIOCMSET) on the port. And instead of writing a kernel driver, a LD_PRELOAD hack (that will trick the program into believing it's writing to a real serial port) may work just as well.
    – user313992
    Feb 3, 2019 at 4:28
  • Thanks @mosvy - The intent is to support existing customer applications that connect to a tty. These days the tty is typically USB-CDC or BT SPP (and not an RS232 connection), so I think we won't see applications doing ioctls to the tty. Possibly a named pipe would work as well as a virtual tty. Feb 4, 2019 at 14:39

1 Answer 1

3

Please have a look at the ttynvt driver [1]. It supports RFC2217, ioctls and tty line disciplines (tty and PPP).

[1] https://gitlab.com/lars-thrane-as/ttynvt

2
  • This works properly, tested with pyserial 3.5 on WSL2 in Windows store Debian.
    – RGD2
    Jul 14, 2022 at 0:13
  • pyserial 3.5, FWIW, fails to connect if the served port won't allow mode changes. This is incorrect behaviour under rfc2217, it should instead respect that, read back the settings, and adapt accordingly. This is what happens with an Advantech EKI-1524 serial port server, when accessed directly from pyserial. If using lars-thrane-as/ttynvt , at least if the ports are set to be consistent with the settings pyserial defaults to, pyserial works.
    – RGD2
    Jul 14, 2022 at 0:18

You must log in to answer this question.

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