#include <arduino_interface.hpp>
Public Member Functions | |
ArduinoInterface (std::string dev_port) | |
The arduino hardware interface. Each arduino connected to your computer needs its own instance of this class. The Serial number is the manner by which we differentiate between arduino devices. | |
std::string | getID () |
bool | initialize () |
ssize_t | read (int device_address, interface_protocol protocol, int frequency, int *flags, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
bool | supportedProtocol (interface_protocol protocol) |
Returns true if the input protocol is supported by the hardware interface. | |
ssize_t | write (int device_address, interface_protocol protocol, int frequency, int *flags, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
~ArduinoInterface () | |
destructor | |
Private Member Functions | |
ssize_t | arduinoAdcRead (uint8_t pin, uint8_t *data) |
ssize_t | arduinoAdcWrite (uint8_t *voltage) |
ssize_t | arduinoEncoderRead (int *pin, uint8_t *data) |
ssize_t | arduinoEncoderWrite (int *flags, uint8_t *data) |
ssize_t | arduinoGpioRead (uint8_t flags, uint8_t pin, uint8_t *value) |
ssize_t | arduinoGpioWrite (uint8_t pin, bool value) |
ssize_t | arduinoI2cRead (uint8_t device_address, uint32_t frequency, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
ssize_t | arduinoI2cWrite (uint8_t device_address, uint32_t frequency, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
ssize_t | arduinoPwmWrite (uint32_t frequency, uint8_t reg_address, uint8_t data) |
ssize_t | arduinoSpiRead (uint8_t frequency, uint8_t flags, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
ssize_t | arduinoSpiWrite (uint8_t frequency, uint8_t flags, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
bool | waitOnBytes (int num_bytes) |
Private Attributes | |
uint16_t | _reference_voltage |
stores the selected reference voltage for the ADC in milli volts [mV] | |
int | baud_rate_ |
Baud rate at which the serial communication takes place. | |
bool | connection_failure_ |
uint8_t | data_packet_ |
Contains used protocol and whether or not a read or write command is about to be requested. | |
int | file_descriptor_ |
The file descriptor that handles serial communications. | |
bool | is_initialized_ |
True if hardware has already been initialized to prevent re-opening the serial port. | |
std::string | port_name_ |
uniserial * | serial_port_ |
Serial port where the Arduino can be found. | |
double | timeout_ |
The time to wait (in seconds) for acknowledgement of a serial command by the Arduino. |
Definition at line 53 of file arduino_interface.hpp.
ArduinoInterface::ArduinoInterface | ( | std::string | dev_port | ) |
The arduino hardware interface. Each arduino connected to your computer needs its own instance of this class. The Serial number is the manner by which we differentiate between arduino devices.
An instance of this class will relay information from the program to the Arduino and vice versa. Specifically: inputs: communication protocol (only when first initializing a sub20_interface.) address, read or write command to the sensor outputs: raw data (in bytes) from the sensor. constructor
std::string | dev_port the name of the port from the /dev directory. |
Definition at line 44 of file arduino_interface.cpp.
destructor
Definition at line 61 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoAdcRead | ( | uint8_t | pin, |
uint8_t * | data | ||
) | [private] |
Definition at line 813 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoAdcWrite | ( | uint8_t * | voltage | ) | [private] |
Definition at line 888 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoEncoderRead | ( | int * | pin, |
uint8_t * | data | ||
) | [private] |
Definition at line 664 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoEncoderWrite | ( | int * | flags, |
uint8_t * | data | ||
) | [private] |
Definition at line 699 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoGpioRead | ( | uint8_t | flags, |
uint8_t | pin, | ||
uint8_t * | value | ||
) | [private] |
Definition at line 583 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoGpioWrite | ( | uint8_t | pin, |
bool | value | ||
) | [private] |
Definition at line 529 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoI2cRead | ( | uint8_t | device_address, |
uint32_t | frequency, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) | [private] |
Definition at line 419 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoI2cWrite | ( | uint8_t | device_address, |
uint32_t | frequency, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) | [private] |
Definition at line 284 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoPwmWrite | ( | uint32_t | frequency, |
uint8_t | reg_address, | ||
uint8_t | data | ||
) | [private] |
Definition at line 476 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoSpiRead | ( | uint8_t | frequency, |
uint8_t | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) | [private] |
Definition at line 379 of file arduino_interface.cpp.
ssize_t ArduinoInterface::arduinoSpiWrite | ( | uint8_t | frequency, |
uint8_t | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) | [private] |
Definition at line 340 of file arduino_interface.cpp.
std::string ArduinoInterface::getID | ( | ) | [virtual] |
Implements bosch_drivers_common::bosch_hardware_interface.
Definition at line 251 of file arduino_interface.cpp.
bool ArduinoInterface::initialize | ( | ) | [virtual] |
Implements bosch_drivers_common::bosch_hardware_interface.
Definition at line 70 of file arduino_interface.cpp.
ssize_t ArduinoInterface::read | ( | int | device_address, |
interface_protocol | protocol, | ||
int | frequency, | ||
int * | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) |
Definition at line 104 of file arduino_interface.cpp.
bool ArduinoInterface::supportedProtocol | ( | interface_protocol | protocol | ) |
Returns true if the input protocol is supported by the hardware interface.
interface_protocol | protocol the input protocol. |
Definition at line 224 of file arduino_interface.cpp.
bool ArduinoInterface::waitOnBytes | ( | int | num_bytes | ) | [private] |
Definition at line 260 of file arduino_interface.cpp.
ssize_t ArduinoInterface::write | ( | int | device_address, |
interface_protocol | protocol, | ||
int | frequency, | ||
int * | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) |
Definition at line 160 of file arduino_interface.cpp.
uint16_t ArduinoInterface::_reference_voltage [private] |
stores the selected reference voltage for the ADC in milli volts [mV]
Definition at line 190 of file arduino_interface.hpp.
int ArduinoInterface::baud_rate_ [private] |
Baud rate at which the serial communication takes place.
Definition at line 160 of file arduino_interface.hpp.
bool ArduinoInterface::connection_failure_ [private] |
Definition at line 162 of file arduino_interface.hpp.
uint8_t ArduinoInterface::data_packet_ [private] |
Contains used protocol and whether or not a read or write command is about to be requested.
This information allows the Arduino to prepare to send the following data according to the input parameters of data_packet_ . The read/write flag is saved in the lowest bit while the upper 7 bits are reserved for the used protocol
Definition at line 185 of file arduino_interface.hpp.
int ArduinoInterface::file_descriptor_ [private] |
The file descriptor that handles serial communications.
Definition at line 151 of file arduino_interface.hpp.
bool ArduinoInterface::is_initialized_ [private] |
True if hardware has already been initialized to prevent re-opening the serial port.
Definition at line 174 of file arduino_interface.hpp.
std::string ArduinoInterface::port_name_ [private] |
Definition at line 146 of file arduino_interface.hpp.
uniserial* ArduinoInterface::serial_port_ [private] |
Serial port where the Arduino can be found.
This is the serial port that the particular Arduino uses to communicate with the computer.
Definition at line 145 of file arduino_interface.hpp.
double ArduinoInterface::timeout_ [private] |
The time to wait (in seconds) for acknowledgement of a serial command by the Arduino.
Definition at line 168 of file arduino_interface.hpp.