ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Protected Member Functions | Friends | List of all members
arpirobot::BaseArduinoInterface Class Referenceabstract

#include <arpirobot/arduino/iface/BaseArduinoInterface.hpp>

Inheritance diagram for arpirobot::BaseArduinoInterface:
arpirobot::ArduinoUartInterface

Public Member Functions

 BaseArduinoInterface (const BaseArduinoInterface &other)=delete
 
BaseArduinoInterfaceoperator= (const BaseArduinoInterface &other)=delete
 
bool begin ()
 
void addDevice (ArduinoDevice &device)
 
void addDevice (std::shared_ptr< ArduinoDevice > device)
 
bool isReady ()
 
void sendFromDevice (uint8_t deviceId, std::vector< uint8_t > data)
 

Protected Member Functions

void run ()
 
uint16_t calcCCittFalse (const std::vector< uint8_t > &data, size_t len)
 
void writeData (const std::vector< uint8_t > &data)
 
bool readData ()
 
bool checkData ()
 
std::vector< uint8_t > waitForMessage (const std::vector< uint8_t > &prefix, int timeoutMs)
 
virtual void open ()=0
 
virtual void close ()=0
 
virtual bool isOpen ()=0
 
virtual int available ()=0
 
virtual uint8_t readOne ()=0
 
virtual std::vector< uint8_t > readAll ()=0
 
virtual void write (const uint8_t &b)=0
 
virtual std::string getDeviceName ()=0
 

Friends

class ArduinoDevice
 

Detailed Description

Common base class (communication protocol agnostic) for an arduino (or other microcontroller) sensor coprocessor. This class handles all the high-level data between the arduino and pi, without implementing a specific communication protocol. See the below classes for different communication protocols.

Member Function Documentation

◆ addDevice() [1/2]

void arpirobot::BaseArduinoInterface::addDevice ( ArduinoDevice device)

Add a device to this arduino interface instance. You cannot add devices after BaseArduinoInterface::begin is called

Parameters
deviceThe ArduinoDevice instance to add. Referenced object must stay in scope.

◆ addDevice() [2/2]

void arpirobot::BaseArduinoInterface::addDevice ( std::shared_ptr< ArduinoDevice device)

Add a device to this arduino interface instance. You cannot add devices after BaseArduinoInterface::begin is called

Parameters
deviceThe ArduinoDevice instance to add.

◆ begin()

bool arpirobot::BaseArduinoInterface::begin ( )

Create devices (as needed) and start processing sensor data. After this is called devices can no longer be added to this arduino using BaseArduinoInterface::addDevice.

◆ checkData()

bool arpirobot::BaseArduinoInterface::checkData ( )
protected

Using the complete dataset in read_dataset, calculates the CRC and reads the CRC Compares the two

◆ isReady()

bool arpirobot::BaseArduinoInterface::isReady ( )

Returns true when the arduino is ready to process sensor data (after BaseArduinoInterface::begin is successful)

Returns
true if ready, else false

◆ readData()

bool arpirobot::BaseArduinoInterface::readData ( )
protected

This method blocks until at least one byte is available. One byte is then read and stored in the workingBuffer. Escape, start, and end sequences are handled appropriately. When a full dataset has been read into the workingBuffer it is moved into the read_dataset. Then, this method return true. Otherwise it returns false This function will throw exceptions from lower level I/O functions

◆ sendFromDevice()

void arpirobot::BaseArduinoInterface::sendFromDevice ( uint8_t  deviceId,
std::vector< uint8_t >  data 
)

Send a message from a specific device. THIS SHOULD NOT BE USED FROM USER CODE. Sends a message to the associated device instance on the arduino.

Parameters
deviceIdThe sending/receiving device's ID
dataThe data to send

◆ writeData()

void arpirobot::BaseArduinoInterface::writeData ( const std::vector< uint8_t > &  data)
protected

Writes a message to the arduino using proper escape sequences This funcion will throw exceptions from lower level I/O functions


The documentation for this class was generated from the following file: