chirag
Posts: 18
Joined: Fri Dec 14, 2012 1:04 pm

Reading serial data

Thu Feb 06, 2014 2:35 pm

Hi, im reading serial data form a device from the USB port of raspberry but im just getting the line feed im not getting any characters can i know the reason for this?
here is my python code running on my raspberry

Code: Select all

import serial
while 1:
#       port=serial.Serial(self.serialport,self.baudrate,self.timeout)
        port=serial.Serial('/dev/ttyUSB0',9600,timeout=1)
        line=port.read()
        print line



User avatar
DougieLawson
Posts: 39120
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Reading serial data

Thu Feb 06, 2014 8:58 pm

Is the other end sending at 9600 8N1?

Mis-matched baud rates are the common cause.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Troubleshooting”