1
votes

I have a library (PyModbus) I would like to use that requires a tty device as it will be communicating with a device using serial connection. However, the device I am going to talk to is going to be behind a modem that supports serial over tcp (the device plugs into a com port on the modem).

Without the modem in the way it would be trivial. I would connect a usb serial cable to the device and the other end to the computer. With the modem in the way, the server has to connect to a tcp port on the modem and pump serial data through that. The modem passes the data received to the device connected to the com port.

In linux, whats the best way to create a fake tty from the "serial over tcp connection" for momentary use and then be destroyed. This would happen periodically, and an individual linux server may have 10~500 of these emulated device open at any given time.

1
I don't have a full answer for you, but the pty module from the standard library might be a good place to start looking. It will let you set up a pseudo tty device that you can feed from a standard file descriptor.James Henstridge
Doesn't PyModbus support using TCP?JeffS
@JeffS PyModbus does, but TCP modbus is different than serial modbus on a protocol level. So starting with tcp modbus and spitting it out on a serial device doesn't quite work. However, it looks like you can force TCP modbus to use the RTU (binary serial modbus) frame. That might work.michael

1 Answers

1
votes

if i do understand, you need make a connection of this manner:

[pyModbus <-(fake serial)->process]<-(tcp/ip)->[modem<-(serial)->device]

I suggest use socat for this