
I am having a problem reading/writing to a serial port after the port has been disconnected. I can successfully connect to my device and communicate with it. Then I execute a voluntary disconnect, I reopen the port but I am unable to write/read. Is it possible to reload the port without restarting the script?
The ttyACM* port has an active symlink connection in /etc/udev/rules.d/99-usb-serial.rules:
The ttyACM* port has an active symlink connection in /etc/udev/rules.d/99-usb-serial.rules:
SUBSYSTEM=="tty", ATTRS{idVendor}=="1234", ATTRS{idProduct}=="5678", SYMLINK+="ttyACM_dev0"To open the port:
#!/usr/bin/python3 python3 # -*- coding: utf-8 -*- import serial global ser0 # open the dev0 serial port try: ser0 = serial.Serial("/dev/ttyACM_dev0") ser0.isOpen() except serial.serialutil.SerialException: ser0 = None else: print (ser0.name, 'port opened successfully')The error usually is like:
Error:ser1.flushOutput() # Clear output buffer
File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 587, in flushOutput
self.reset_output_buffer()
File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 604, in reset_output_buffer
termios.tcflush(self.fd, termios.TCOFLUSH)
termios.error: (5, 'Input/output error')