[python-win32] Exception whilst using pySerial & Win32

Andy Atkinson andy.atkinson at hydrix.com
Mon Oct 22 05:54:22 CEST 2007


Hi All,

I am running Python 2.5 on Windows and I have an issue/problem whilst accessing/using a serial port. I have a piece of test equipment that needs a control line to enable/disable its power. So I have connected the DTR of a serial port to my equipment and I can happily control power by opening the serial port and then enabling/disabling the DTR line (using pySerial). However, occasionally I get an exception raised (win32file.EscapeCommFunction (self.hCommPort, win32file.SETDTR), pywintypes.error : (5, 'EscapeCommFunction', 'Access is Denied') ) From what I can gather, this exception is raised when the resource in question (in this case my serial port) if already in use by another entity. Now that's fine, but no other process / application on the machine is (to the best of my knowledge) accessing this serial port. My application is single threaded.

The frequency with which this issue occurs also leaves me little in the way of clues - I can run the SW for 3 days or so until it happens or it will run for only about 12-hours before I run into trouble.

Can anyone offer any insights into this either in terms of telling me why this may be happening or suggest how I may gather some info from the system as to who or what currently has the serial port 'locked'.

As the serial port is giving me 'access denied' I am also a little unsure of what is a sensible course of action. If the port is not under my control, then I may not be able to close it. If I can't close it then I may be in a spot of bother regarding a path for recovery from this situation.

Any help appreciated.

Regards

Andy Atkinson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20071022/037a2d78/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Andy Atkinson.vcf
Type: text/x-vcard
Size: 487 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20071022/037a2d78/attachment.vcf 


More information about the python-win32 mailing list