shawn bright wrote:
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 did not realize there was a Weird character set. I'd have expected
ASCII characters. (chuckle?)
When you say "weird" I guess you mean unexpected. What exactly did you
get and what exactly did you expect?
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.
Well of course. Writing to a file and then reading it should give the
same results. Again what did you expect and why does this surprise you?
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
That's good. It tells us that msg is a character string.
so, what am i supposed to be doing to get real values out of this
stream of bytes?
Depends again on what you are expecting. What do you mean by "real"?
--
Bob Gailer
Chapel Hill NC
919-636-4239
When we take the time to be aware of our feelings and
needs we have more satisfying interatctions with others.
Nonviolent Communication provides tools for this awareness.
As a coach and trainer I can assist you in learning this process.
What is YOUR biggest relationship challenge?
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor