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?
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.
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
Read Terms of Service upon submitting. 投稿する前に利用規約をお読みください。