[Tutor] how to read over serial port
nephish at gmail.com
Sun Nov 2 05:23:25 CET 2008
First, thanks for you time with me on this.
When i said weird characters, i meant that they were not characters
you would find on a keyboard.
Like one of them is a black diamond with a question mark in it. there
are some weird block characters, occationally a letter, etc..
did not clarify why i wrote it to a file.
It is running in a thread, so i captured a few of the messages on a
file, and moved them to a different computer that is not running our
company so i could work with this stuff there.
the output is supposed to be a mix of mostly numbers and some letters
and commas that seperate the fields of data.
thanks for any suggestions on this.
On Sat, Nov 1, 2008 at 11:02 PM, bob gailer <bgailer at gmail.com> wrote:
> 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
>> 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:
>> 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?
More information about the Tutor