Serial port gotcha with win32all
Isaac Barona
ibarona at tid.es
Tue Oct 23 07:03:23 EDT 2001
On Sat, 20 Oct 2001 10:01:13 GMT, Mark Hammond <MarkH at ActiveState.com>
wrote:
>Markus Demleitner wrote:
>
>> Hi,
Hi Markus!!!
>>
>> I'm getting increasingly desperate. All I'm trying to do is
>> attach a little serial gizmo that runs just fine when talked
>> to from a linux box (using some homegrown python software) to
>> a machine plagued by Windows 2000.
>>
>> Realizing that termios doesn't buy me much in win32, I soon
>> ran across uspp which basically acts as a wrapper around the
>> win32all or termios modules on the respective platforms.
I am uspp's author, so I hope to help you.
>>
>> Under linux, uspp worked quite as well as my own termios-based
>> code (perhaps not too surprisingly). Under win32, however,
>> write()s seem to work but read()s consistently fail with a
>> "incorrect paramater" exception in a call to win32file.ReadFile.
>>
>> Now, clearly the OpenFile succeded, and the handle didn't change
>> between the open and the read, the error is not in the number
>> of bytes to read (passing some weird object there causes a
>> ParameterError, as expected), and in general I've not been
>> able to gain any clue as to what is going on. The win32all
>> sources seem somewhat intimidating, at least for me with
>> no knowledge of the win32 API whatsoever.
It seems that the interface in the overlapped I/O mode to the
win32file.ReadFile function has changed in new versions.
Harald Angelo sent me this patch that seems to correct the problem
(not using overlapped I/O).
self.__handle=CreateFile (dev,
win32con.GENERIC_READ|win32con.GENERIC_WRITE,
0, # exclusive access
None, # no security
win32con.OPEN_EXISTING,
win32con.FILE_ATTRIBUTE_NORMAL
# |win32con.FILE_FLAG_OVERLAPPED
,
None)
Just now I am working in a new release of the library but in the
meantime apply this patch and see what happend.
Let me know the results.
Greetings from Spain,
Isaac.
>>
>> So -- can anyone give me a hint where to start getting a
>> grip on this one?
>
>Look at the
>
>win32comport_demo.py sample - it seems to work just fine. Failing that, post the smallest possible code snippet you can come up with that demonstrates the problem.
>
>
>Mark.
>
>
>
More information about the Python-list
mailing list