LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Python serial output seems strange (http://www.linuxquestions.org/questions/programming-9/python-serial-output-seems-strange-721863/)

edM 04-26-2009 05:18 PM

Python serial output seems strange
 
Hi,

I have a temperature sensor circuit, which sends temps up an rs232 cable to my pc.

the format is this:

HEX:...2B 32 34 2E 30 2 6F 43 20 0A
ASCII: + 2 4 . 0 SPACE o C SPACE LF

obviously the +24.0 change.

Ive used realterm and hyperterm to test it, and am writing a simple data logger in python, but the data coming out of the end is odd.

Code:

import serial
ser = serial.Serial('/dev/ttyUSB0', 1200, bytesize=8, parity='N', stopbits=1, xonxoff=0, timeout=1)

while (1):
     
        line = ser.read(1)
        data = line.split()
        print data

OUTPUT>
['x']
['\xf8']
['\x86']
['f']
['\x18']
['\x98']
['\x9e']
['\x1e']
['\x06']
['\x18']
['\x06']
['\x9e']
['\x86']
['\x18']
['\x98']
['x']
['\xf8']
['\x86']
['f']
['\x18']
['\x98']
['\x9e']
['\xf1']
['\x00']
['\x9e']
['\x1e']
['\x06']
['\x18']
['\x06']
['\x9e']
['\x86']
['\x18']
['\x98']
['x']
['\xf8']
['\x86']
['f']
etc....

Can any tell me whats going on, and how can convert it into friendly ascii?

thanks

theNbomr 04-26-2009 07:09 PM

Looks to me like your baud rate is not set correctly. Just a guesstimate, but I would say that you are sampling about 4 times faster than the sender is sending, ie baud rate too high by factor of four.
--- rod.

edM 04-27-2009 04:54 AM

hmm, the baud rate on the temp circuit transmission side si set to 1200 as well.


All times are GMT -5. The time now is 01:43 PM.