Sending null byte to serial port in Windows using PySerial?
Chris Liechti
cliechti at gmx.net
Sat Nov 2 06:06:50 EST 2002
sundae1888 at hotmail.com (sundae) wrote in
news:49f4e27a.0211020033.6d7b66ac at posting.google.com:
>> > com = serial.Serial("COM1", 9600, timeout=1)
>> > com.write(chr(0))
> So that *is* the way to send a null byte? I was wondering if I
> screwed up there (and/or that WriteFile() doesn't support null byte).
yes if you have a longer string with other data you can also insert a null
byte with "\0" or "\x00" etc. it's all the same.
> Since it's easier to test case (b), my question is, would inWaiting()
> detect a byte even if the timeout is too fast?
inWaiting() return the number of characters in the buffer that the OS has.
characters disapear from the buffer if you read them or if you flush the
buffer. so yes, if your read() call would return too fast and characters
arrived after that and then you did a inWaiting() it should return a
nonzero value.
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list