[Tutor] Pyserial and invalid handle

Emile van Sebille emile at fenx.com
Tue Nov 30 00:56:06 CET 2010


On 11/29/2010 3:25 PM John Smith said...
>
> On 11/29/2010 4:20 PM, Emile van Sebille wrote:
>> On 11/29/2010 1:44 PM John Smith said...
>>> But, when I tried it in Python, I got the same as before:
>>>
>>>
>>> >>> import serial
>>> >>> ser = serial.Serial(0, timeout = 1)
>>
>> out of curiosity, if you change the timeout above to 5....
>>
>>> >>> ser
>>> Serial<id=0x225c240, open=True>(port='COM1', baudrate=9600, bytesize=8,
>>> parity='N', stopbits=1, timeout=1, xonxoff=False, rtscts=False,
>>> dsrdtr=False)
>>> >>> ser.read()
>>
>> ... does the delay before printing the traceback below take about 5
>> seconds?
>>
>
>
> No. There is no delay regardless of the timeout setting.
>
 >>
 >> Traceback (most recent call last):
 >> File "<pyshell#3>", line 1, in <module>
 >> ser.read()
 >> File "E:\Python27\lib\site-packages\serial\serialwin32.py", line
 >> 236, in read
 >> raise SerialException("ReadFile failed (%s)" % ctypes.WinError())
 >> SerialException: ReadFile failed ([Error 6] The handle is invalid.)
 >>  >>>

Hmmm... any chance you don't have administrative rights on the account 
performing this?  I never got to Win7 (having stopped at XP) but I know 
it's got a reputation for excessive permission asking.

Otherwise, I'd take this up on the main list.  Chris Liechti, the 
[author|current maintainer|significant contributor] of pyserial monitors 
that list and would probably be interested in diagnosing what you're 
describing.  You could also ask him as per the 'send me a message' link 
on his sourceforge page at

http://sourceforge.net/sendmessage.php?touser=403744

Emile



More information about the Tutor mailing list