Hi,
I try to connect moteino to rapberry pi by serial. i connect moteino pins - gnd, tx power to raspberry gpio pins. i do configurations in raspberry to unblock /dev/ttyAMA0 and i write little python script to read data.
void loop() {
if (radio.receiveDone())
{
for (byte i = 0; i < radio.DATALEN; i++) {
Serial.print((char)radio.DATA[i]);
}
Serial.println("");
if (radio.ACKRequested())
{
radio.sendACK();
}
Blink(LED,3);
}
}
Of course i do initialize serial in setup like this:
Serial.begin(115200);
my python code bellow:
#!/usr/bin/python
import serial
import urllib2
import json
import datetime
ser = serial.Serial(port='/dev/ttyAMA0', baudrate=115200, timeout=1)
while 1 :
try:
data = ser.readline()
print data
except Exception, e:
print 'exception', e
continue
But this script work only few seconds... after return only messages from exception:
exception device reports readiness to read but returned no data (device disconnected?)
anybody can help me?
Thanks
Tom
Incorporate some error-handling. See here:
https://github.com/iinnovations/iicontrollibs/blob/master/mote/serialhandler.py