LowPowerLab Forum

Hardware support => Moteino => Topic started by: Kitsibas on September 23, 2014, 12:15:14 PM

Title: Communication moteino by serial to raspberry pi
Post by: Kitsibas on September 23, 2014, 12:15:14 PM
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

Title: Re: Communication moteino by serial to raspberry pi
Post by: ColinR on September 24, 2014, 03:49:42 PM
Incorporate some error-handling. See here:

https://github.com/iinnovations/iicontrollibs/blob/master/mote/serialhandler.py