Win32/Python serial port event character problem

Derek Basch dbasch at yahoo.com
Sat Jun 29 18:39:08 EDT 2002


Chris,
It is funny that you wrote me. I just spent the last
hour looking at pySerial. I dug into it some more and
I think that using the event character is only usefull
for driving the serial port polling function
('ReadFile' in this case). It is not usefull for
breaking the serial data into logical units (ie..lines
that end with '\n').

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwbgen/html/msdn_serial.asp

The 'caveat' section of this paper almost answers my
question. 

> and read the characters in a separate receiver
> thread. that thread can then 
> trigger on any character or sequence (e.g. using a
> Queue to communicate 
> with other threads)

Yeah, I think that is what will work best as a
solution. Thanks for the suggestion.

Also, I have been using the 'cbInQue' member of the
COMSTAT structure returned by 'ClearCommError' to
figure out how many characters are waiting in the
serial buffer. I see that you are pre-allocating a
buffer, using 'win32file.AllocateReadBuffer', based
upon the size of 'cbInQue' for the subsequent
'ReadFile' operation. According to Mark Hammond I
should be doing the same too.:

http://starship.python.net/crew/mhammond/win32/RecentChangeHistory.html
(section 108)

If anyone reads this and can show me a better way to
work with serial event characters in win32 please feel
free to :) 

Thanks for the help,
Derek Basch

> > Sorry to post this again but it didn't get any
> > responses. Maybe better luck this time.
> 
> well 14hrs isn't that much time on a weekend... some
> people only look into 
> news once per week.
> 
> > I use the following code to read data from the
> serial
> > port when a certain event character ('\n') is
> > received:
> ...
> > Has anyone ever dealt with this? Is using the
> event
> > character not a reliable method in windows?
> 
> no sorry, i haven't used the event mode.
> 
> ....
> > This is driving me batty so any help is greatly
> > appreciated.
> 
> <shaemles plug>
> my tip is: use http://pyserial.sf.net
> 
> and read the characters in a separate receiver
> thread. that thread can then 
> trigger on any character or sequence (e.g. using a
> Queue to communicate 
> with other threads)
> </shaemles plug>


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Python-list mailing list