The importance of communicationOur cubieboard have enough connection to control almost of our sensors, using I2C.
But in my case I'll have a few more analogical sensors, and I want to avoid that, and the cubieboard doesn't have to work with the simplest things.
For this, my cubieboard will be a brain, the arduino will be then the senses, and the connection will be made over a serial connection
I could make using I2C but the arduino is working with it as master for the sensors, and could get more complicated. (by the moment :) )
The arduino part.(Serial vs SoftwareSerial)Arduino has a serial port inside of it, you can access through the USB, or the digital pins (Rx-0,Tx-1).
This option gave me two problems.
1º The USB - Serial driver (ftdi_sio) does not exit in my version of raspbian (Linux raspberrypi 3.4.24-a10-aufs+), and it's necessary to upgrade (I made it, but also it's necessary to install again the OpenCV, lib-jpeg-turbo, etc. This option is completely necessary if you don't want to work with arduinos sketches (to slow :( at the cubieboard )
2º The other issue is more a problem of design. I'm learning who to make drones, and if I want to debug the arduinos part and don't worry about the cubieboard, I should to make through the USB serial, but if it's used by the cubieboard, I could'nt have access to it.
Arduino give us a solution, and it's to use a software serial.
It's possible to use two different digital pin to serial communication.
Here it's an useful example (http://www.arduino.cc/en/Reference/SoftwareSerialExample)
Here it's a code it's a modification of the arduino example.
//Define for the new pins for the Software-serial
#define rxPin 2
#define txPin 3
String buffer="";// In this buffer I'll receive the commands
// Create a new serial port
SoftwareSerial miSerie = SoftwareSerial(rxPin, txPin);
Serial.println("USB SERIAL UP");
// Stablish the serial port
miSerie.println("SOFT SERIAL UP");
//isBufferComplete is to retrieve complet commands
if (isBufferComplete())//this function read the date from my serial (softserial)
//From the arduino to the cubieboard (throught SoftSerial)
if (Serial.available())//Just read from the USB serial
//This function read from the softserial
//In this function we recieve each caracter till
// arrive ";" wich means end of command
boolean completa =false;
char inChar = (char)miSerie.read();
buffer += inChar;
if (inChar ==';') completa=true;
note: SerialEvent from the arduino, doesn't works with software-serial
At the next post will be the code for the cubieboard.