I have a problem on win7 with pyserial 2.6.
Sometimes I get an exception with the following code:
self._ser = serial.Serial() self._ser.close() # should not be needed but it does not hurt self._ser.timeout=0 self._ser.baudrate = 800000 self._ser.port = "COM8" # this is a FTDI USB-Serial adapter self._ser.open()
I get the following exception (serialwin32.py line 59):
could not open port COM8: [Error 5] Zugriff verweigert
When I try to close, delete and instantiate a new serialobject with the same code, I get on the same open() call the following exception.
Cannot configure port, some setting was wrong. Original message: [Error 995] Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen.
This exception is in the _reconfigurePort() function (line 186) called from the open() function.
A following close() does not free the hComPort because the self._isOpen is not yet set.
And even deleting the object does not free the handle.
If I delete the serial Object, and try to create a new one, I will not be able to open the port again. I have to close my programm completely to release the handle. Even other programs can not open the port.
after that exception if the handle is still open, I close it by hand with
self._ser.close() if self._ser.hComPort is not None: serial.serialwin32.win32.CloseHandle(self._ser.hComPort)
Now I can reopen the serial port and work with it.
Log in to post a comment.