psSerial: how to write a single byte value to the serial port?

Diez B. Roggisch deetsNOSPAM at web.de
Wed Nov 17 15:01:06 EST 2004


> I assume the string print ser.write() will append null characters to the
> end.

Why do you assume that? Its not said anywhere, and its wrong. A string
consists only of the characters you can "see" - if python usues C
convention for 0-termination or othear means is an implementation detail
none of your concern.

> byte = chr(0x40)
> ser.write(byte)

>>> type(byte)
<type 'str'>

Its a string as well.


-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list