I have a program using pyserial and I want to test it without using a real serial port device.
On Windows, I use com0com, and on linux, I know that there is a way to create a virtual serial port pair without using an additional program.
so I'm looking for guidance and found pts, / dev / ptmx, but I donβt know how to create a pair by following the guidelines, can anyone give me an example?
I tried (in python):
f = open("/dev/ptmx", "r")
and it works, / dev / pts / 4 is created.
and I tried:
f = open("/dev/4", "w")
and the result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 5] Input/output error: '/dev/pts/4'
edit: I found a solution (workround) using socat.
socat PTY,link=COM8 PTY,link=COM9
then COM8 COM9 are created as a pair of virtual serial ports.