Have trouble reading from the signal from /dev/ttyAMA0

Hi, I am following the instruction here,
http://wiki.rapiro.com/page/installing_distance_sensor/

I loaded oga's firmware. (it is confirmed because the "#M00" - "#M10" commands are working)
From raspberry pi's python console (With sudo), I will the following

{{{
import sys
import time
import serial
import colorsys

# config
SENSOR_PIN = 6
RAPIRO_TTY = '/dev/ttyAMA0'
rapiro = serial.Serial(RAPIRO_TTY, 57600, timeout = 10)
value = 0

# version check
rapiro.write("#V")
time.sleep(0.05)
version = ""
while rapiro.inWaiting():
version += rapiro.read(1)

print(version)
}}}
it prints nothing.

If I run a "$ sudo last -f /dev/ttyAMA0" in another terminal,
I got a error message right after the rapiro.write("#V")
last: seek failed!

Any idea?

posted by luzhuomi on 2014-07-06 10:36

Trying shutting down the Pi and using Usb to Arduino connection, I am able to read with "#A6" command. Hence it seems to be a reading problem between the Pi and Arduino.

posted by luzhuomi on 2014-07-06 14:52

After some googling, I've figured it out. Here is the step I missed out before python can read from the ttyAMA0

http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port

posted by luzhuomi on 2014-07-06 18:24

( Allowed tags: <b> <s> <code> <blockquote> <img> . Automatic URL link.)

Uploaded image is placed to the bottom of the post. To add multiple images, make post once then edit the post.

Read Terms of Service upon submitting. 投稿する前に利用規約をお読みください。