[Tutor] how to read over serial port
shawn bright
nephish at gmail.com
Sun Nov 2 03:45:12 CET 2008
Hey there all,
I have a gps device that talks to the computer over a serial port.
i am using the pyserial module and getting values in.
Here is my delima,
i am supposed to read a message in that starts with a $ (this is all ascii).
but when i do a ser.read(16) and i try to print it to a screen, it is
all just weird characters.
i had it write each byte to a file like
f = open('test', 'wb')
msg = ser.read(16)
for i in msg:
f.write(i)
f.close()
then when i open it with python and do
f = open('test', 'rb')
and read it it is the same weird characters.
when i add a line to print the type after reading like this:
for i in msg:
print str(type(i))
i consistantly get type str
so, what am i supposed to be doing to get real values out of this
stream of bytes?
thanks all
shawn
More information about the Tutor
mailing list