Sending null byte to serial port in Windows using PySerial?
sundae
sundae1888 at hotmail.com
Sat Nov 2 03:33:11 EST 2002
> > com = serial.Serial("COM1", 9600, timeout=1)
>
> sidenote: i sugest to use numbers i.e. 0 <-> "COM1" that makes it easier if
> you want to run the prog on other platforms or with jython.
Portability isn't a big concern for this application (yet), with the
ActiveX I'm using, but I'll take your advice.
> > com.write(chr(0))
>
> well i'm reading and writing null characters en masse. so no problem. the
> port is configured for binary data transmition on all platforms.
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).
> > The device should reply a single byte upon receiving this byte, but I
> > never got anything in reply.
>
> well i suspect that something is wrong with your setup. you're sure your
> device is connected to the right port and listening with the same baudrate?
> you're reading from the port as you expect, you use a timeout. does the
> read function return before your device answers?
Hm.. then either a) the protocol (including baudrate, etc) is not the
same as the manufacturer's specification states; or b) the port
timeout before I read... the device is "supposed to be working" in the
"other-apps-can-access-it" sense.
Since it's easier to test case (b), my question is, would inWaiting()
detect a byte even if the timeout is too fast?
Thank you again!
More information about the Python-list
mailing list