ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
|
#include <arpirobot/arduino/iface/BaseArduinoInterface.hpp>
Public Member Functions | |
BaseArduinoInterface (const BaseArduinoInterface &other)=delete | |
BaseArduinoInterface & | operator= (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 |
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.
void arpirobot::BaseArduinoInterface::addDevice | ( | ArduinoDevice & | device | ) |
Add a device to this arduino interface instance. You cannot add devices after BaseArduinoInterface::begin is called
device | The ArduinoDevice instance to add. Referenced object must stay in scope. |
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
device | The ArduinoDevice instance to add. |
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.
|
protected |
Using the complete dataset in read_dataset, calculates the CRC and reads the CRC Compares the two
bool arpirobot::BaseArduinoInterface::isReady | ( | ) |
Returns true when the arduino is ready to process sensor data (after BaseArduinoInterface::begin is successful)
|
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
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.
deviceId | The sending/receiving device's ID |
data | The data to send |
|
protected |
Writes a message to the arduino using proper escape sequences This funcion will throw exceptions from lower level I/O functions