LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-26-2009, 05:18 PM   #1
edM
Member
 
Registered: Nov 2003
Location: U.K.
Distribution: Slackware-12
Posts: 137

Rep: Reputation: 15
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
 
Old 04-26-2009, 07:09 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 04-27-2009, 04:54 AM   #3
edM
Member
 
Registered: Nov 2003
Location: U.K.
Distribution: Slackware-12
Posts: 137

Original Poster
Rep: Reputation: 15
hmm, the baud rate on the temp circuit transmission side si set to 1200 as well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Craeting a serial program with Python jabfinger Programming 0 12-31-2008 11:40 AM
python shell doesn't run idle output me_lax Linux - Newbie 3 09-13-2008 11:55 PM
Serial PIC programmer, but no serial output on my laptop simopal6 Linux - Hardware 1 08-21-2008 03:04 PM
strange serial port problem..can you help? djsroknrol Linux - Software 6 06-28-2006 04:28 PM
python read output from seperate script? bendeco13 Programming 1 02-01-2005 10:38 PM


All times are GMT -5. The time now is 11:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration