March 27, 2024, 14:02
python import serial import time import termios uart_channel = serial.Serial('/dev/ttyS0', 9600, timeout=0.25) def main(): data = uart_channel.read(16) print(data) while True: try: main() except (serial.SerialException, termios.error) as e: print(f"SerialException: {e}") break time.sleep(1) finally: try: uart_channel.flushInput() except termios.error as e: print(f"Termios error: {e}")
SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?) Termios error: (5, 'Input/output error')