sending ctrl chars using sio module
Fredrik Lundh
fredrik at pythonware.com
Mon Oct 11 14:58:04 EDT 1999
CHale <chale at texas.net> wrote:
> I tried using Serial.Port.cmd(self, str) - where str is a decimal list of
> bytes [4,124].
not sure I follow here (you didn't include
the traceback, so I don't know why that
line offends you ;-).
but I suspect you're looking for a way
to create a binary string from a set of
character values? (unless the docs says
so, the chances that the "cmd" function
will do this for you is quite small).
here are a few ways to do this:
str = chr(1) + chr(2) + chr(3)
import struct
str = struct.pack("3B", 1, 2, 3)
import string
str = string.join(map(chr, [1, 2, 3]), "")
import array
str = array.array("B", [1, 2, 3]).tostring()
hope this helps!
</F>
coming soon:
http://www.pythonware.com/people/fredrik/librarybook.htm
More information about the Python-list
mailing list