I'm using pySerial successfully to connect to a USB port and talk to a custom device. The difficulty I'm having is if I should happen to lose my connection (the cable is pulled out from the port) once the connection is re-established I can not clear everything and reconnect, I have to clear everything, unplug the cable and then plug it back in. Nothing software related seems to help and I continue to get this message:
serial.serialutil.SerialException: could not open port COM5: [Error 2] The system cannot find the file specified.
until I unplug and plug it back in.