I have a program, using pyserial, and I want to test it without using a real serial port device.
In windows, I use com0com, and in linux, I know there is a method to create virtual serial port pair without using additional program.
so I look up the manual, and found pts, /dev/ptmx, but I don't know how to create a pair by following the manual, can anyone give me a 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 is:
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 virtual serial port pair.