vtty
vtty copied to clipboard
read from slave as regular serial device
I created two simple test programs in Python to send and receive data:
Write to master send.py
:
#!/usr/bin/env python3
import serial
import time
if __name__ == '__main__':
# causes: termios.error: (25, 'Inappropriate ioctl for device')
# serial_port = serial.Serial(
# port='/dev/vtmx',
# baudrate=100000,
# parity=serial.PARITY_EVEN,
# stopbits=serial.STOPBITS_TWO,
# bytesize=serial.EIGHTBITS)
serial_port = open('/dev/vtmx', 'w')
while True:
try:
for i in range(10):
msg = str(i)
serial_port.write(msg)
serial_port.flush()
print(f"sent {msg}")
time.sleep(0.5)
except KeyboardInterrupt:
break
serial_port.close()
Read from slave recv.py
:
#!/usr/bin/env python3
import serial
if __name__ == '__main__':
serial_port = serial.Serial(
port='/dev/ttyV0',
baudrate=100000,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.EIGHTBITS)
print(f"serial port open: {serial_port.is_open}")
while True:
byte = serial_port.read()
print(chr(byte))
serial_port.close()
However, instantiating the serial port gets stuck somewhere at termios.tcsetattr
.
How do I configure the master device such that I can read from the slave like a regular serial device?
This must be a bug. I've checked this now on two random machines - it works on one (kernel 5.15) but fails on the other (kernel 5.4).