Hi
I'm trying to use PySerial and I'm getting "Access Denied". I don't know if this is a bug from PySerial library or I'm doing something totally stupid :-)
Specification:
Windows XP pro SP3
PySerial-2.5.win32 (Installed from binary)
Python 2.7.1 (I know it's a bit old :-))
from serial import Serial, SerialException
class Test(object):
def __init__(self):
pass
def tst_serial(self):
port = Serial()
port.port = 3
port.baudrate = 19200
port.open()
port.timeout = 1
try: port.open()
except SerialException: pass
port.close()
# Up to here everything is fine. NOW
port.open() # Here is the problem
port.timeout = 0.50
if __name__ == "__main__":
t = Test()
t.tst_serial()
Error that I'm getting is:
could not open port COM4: [Error 5] Access is denied.
I checked the port with Portmon while I was running that script to make sure that the port gets closed and it is.
So somehow try and except to open the already opened port messed up the object. I also tried to destroy the object and create it again and I got the same error.
Does any know if this is a bug or am I doing something wrong.
Thanks
--
Mark