[Tutor] Python Serial Communication

Steven D'Aprano steve at pearwood.info
Mon Sep 29 15:23:14 CEST 2014


On Sun, Sep 28, 2014 at 05:32:26PM +0800, m.v gautam wrote:
> Hi,
> I am trying out serial communication between raspberry pi and atmega 32 using pyserial module . I have tried serial communication between two atmega and it is working.
> But when I try it rpi and atmega I get blank lines as output. My python code is 
> 
> import serial
> ser = serial.Serial('/dev/ttyAMA0',38400,timeout = 10)
> while True:
>         print "try"
>         val = ser.read(10)
>         print val

According to this Stackoverflow question, you need to use keyword 
arguments. Try this:

    val = ser.read(size=10)

http://stackoverflow.com/questions/19143360/python-writing-to-and-reading-from-serial-port


-- 
Steven


More information about the Tutor mailing list