EasyTransferPi – EasyTransfer for RaspberryPi

EasyTransfer is commonly popular among Arduino developers.It simplifies the communication between two Arduinos.But if you want to communicate with a different device for example a RaspberryPi , there is no version of this library to work on other devices.So EasyTransfer for RaspberryPi is developed for that reason.

On your Arduino you should use EasyTransfer and at the other side (probably on your RaspberryPi) you should use EasyTransferPi.With that you can exchange structs between Arduino and RaspberryPi.

If you haven’t use EasyTransfer(Arduino) probably it is a good idea that you check out Bill Porter’s examples.

There are three classes that makes it simple for RaspberryPi:

-EasyTransferPi

-SerialPortManager

-ActionHandler

ActionHandler class is where you take actions according to data communications.So you can define your message structs in ActionHandler:

EasyTransferPi is a little different than Arduino’s EasyTransfer.EasyTransferPi is based on SIGNAL and SLOT logic.

You must create EasyTransferPi object and connect the eventReadyToSend() SIGNAL to some SLOT. This event call indicates that the connection between RaspberryPi and Arduino is established.

ActionHandler class has three methods named onDataArrived(),onReadyToSend(),startConnection().Their names are simply enough,onDataArrived is called whenever data is received from Arduino,onReadyToSend indicates that connection is established and startConnection must be called to start connection probably from your main.cpp.My main.cpp looks like:

Start sending data after onReadyToSend  is called.

Receiving data will be parsed for the struct you specified at :

And when data is received , onDataArrived will be called to inform you.Now it is ready to use:

BaudRate is set in ActionHandler class.If you want to set further arguments about serial port for example parity bits,flow control, stop bits please check out serialportmanager.cpp.

Also keep in mind that this library seeks for an Arduino while opening the port if you want to connect some other device try changing these lines for your need :

Source Code available on Github project pages.

 

Leave a Reply

Your email address will not be published. Required fields are marked *