Menu

#60 recover after serialException

v1.0 (example)
closed
None
5
2014-08-04
2013-01-25
StephenD
No

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.

Thanks,
Stephen

Discussion

  • StephenD

    StephenD - 2013-01-25
     
  • Chris Liechti

    Chris Liechti - 2013-10-11
    • status: open --> pending
    • assigned_to: Chris Liechti
    • Group: --> v1.0 (example)
     
  • Chris Liechti

    Chris Liechti - 2013-10-11

    I think that is a problem with the OS, that keeps the old device active while it is still in use by a program, even if the hardware is removed. When the hardware is re-attached, it may event get assigned a different COM port.

    The only solution I have is trying to close the serial port in case of an error, so that the device is no longer in use when the cable is plugged in again.

     
  • Chris Liechti

    Chris Liechti - 2014-08-04
    • status: pending --> closed
     

Log in to post a comment.