The sub20 hardware interface. More...
#include <sub20_interface.hpp>
Public Member Functions | |
std::string | getID () |
bool | initialize () |
finds the sub20 specified by the 4-digit serial in the constructor (or the first sub20, if no serial is specified) and establishes a connection with it. | |
int | numDevices () |
ssize_t | read (int device_address, interface_protocol protocol, int frequency, int *flags, uint8_t reg_address, uint8_t *data, size_t num_bytes) |
reads num_bytes from the requested device on the specified protocol at the specified protocol frequency | |
Sub20Interface (std::string sub20_serial_number="null") | |
constructor, which takes in an optional argument, which is the sub20's 4-digit serial number. | |
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) |
reads num_bytes from the requested device on the specified protocol at the specified protocol frequency | |
~Sub20Interface () | |
destructor | |
Private Member Functions | |
bool | spiConfigRoutine (int frequency, int flags) |
Private Attributes | |
int | error_code |
sub_handle | handle_ |
bool | is_initialized_ |
int | num_devices_ |
interface_protocol | protocol_ |
std::string | serialNumber_ |
int | spi_configuration_ |
sub_device | subdev_ |
sub20 device handle |
The sub20 hardware interface.
Each sub20 connected to your computer needs its own instance of this class! The Serial number is the manner by which we differentiate between sub20 devices.
An instance of this class will relay information from the program to the sub20 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. NOTE: You can initialize multiple sensors on the same sub20 by calling this method for each sensor's device_address. There are some constraints: devices can't have the same address.
Definition at line 74 of file sub20_interface.hpp.
Sub20Interface::Sub20Interface | ( | std::string | sub20_serial_number = "null" | ) |
constructor, which takes in an optional argument, which is the sub20's 4-digit serial number.
std::string | sub20_serial_number |
Definition at line 43 of file sub20_interface.cpp.
destructor
Definition at line 55 of file sub20_interface.cpp.
std::string Sub20Interface::getID | ( | ) | [virtual] |
Implements bosch_drivers_common::bosch_hardware_interface.
Definition at line 306 of file sub20_interface.cpp.
bool Sub20Interface::initialize | ( | ) | [virtual] |
finds the sub20 specified by the 4-digit serial in the constructor (or the first sub20, if no serial is specified) and establishes a connection with it.
Implements bosch_drivers_common::bosch_hardware_interface.
Definition at line 62 of file sub20_interface.cpp.
int Sub20Interface::numDevices | ( | ) |
Definition at line 314 of file sub20_interface.cpp.
ssize_t Sub20Interface::read | ( | int | device_address, |
interface_protocol | protocol, | ||
int | frequency, | ||
int * | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) |
reads num_bytes from the requested device on the specified protocol at the specified protocol frequency
int | device_address the way that the sensor identifies itself |
interface_protocol | protocol the defined protocol |
int | frequency the frequency of the interface protocol |
int* | flags additional information necessary to read from that particular interface protocol. |
uint8_t | reg_address the starting address of the data in the sensor. |
uint8_t* | data the name of the array where the data will be stored. |
uint8_t | num_bytes the number of bytes to be read from the sensor. |
Definition at line 137 of file sub20_interface.cpp.
bool Sub20Interface::spiConfigRoutine | ( | int | frequency, |
int | flags | ||
) | [private] |
Definition at line 322 of file sub20_interface.cpp.
bool Sub20Interface::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 287 of file sub20_interface.cpp.
ssize_t Sub20Interface::write | ( | int | device_address, |
interface_protocol | protocol, | ||
int | frequency, | ||
int * | flags, | ||
uint8_t | reg_address, | ||
uint8_t * | data, | ||
size_t | num_bytes | ||
) |
reads num_bytes from the requested device on the specified protocol at the specified protocol frequency
int | device_address the way that the sensor itentifies itself |
interface_protocol | protocol the defined protocol |
int | frequency the frequency of the interface protocol |
int* | flags additional information necessary to read from that particular interface protocol. |
uint8_t | reg_address the starting address in the sensor's registers where the data will be written to. |
uint8_t* | data the name of the array where the data will be output from. |
uint8_t | num_bytes the number of bytes to be written to the sensor. |
Definition at line 231 of file sub20_interface.cpp.
int Sub20Interface::error_code [private] |
Definition at line 176 of file sub20_interface.hpp.
sub_handle Sub20Interface::handle_ [private] |
Definition at line 177 of file sub20_interface.hpp.
bool Sub20Interface::is_initialized_ [private] |
Definition at line 182 of file sub20_interface.hpp.
int Sub20Interface::num_devices_ [private] |
Definition at line 180 of file sub20_interface.hpp.
interface_protocol Sub20Interface::protocol_ [private] |
Definition at line 175 of file sub20_interface.hpp.
std::string Sub20Interface::serialNumber_ [private] |
Definition at line 179 of file sub20_interface.hpp.
int Sub20Interface::spi_configuration_ [private] |
Definition at line 181 of file sub20_interface.hpp.
sub_device Sub20Interface::subdev_ [private] |
sub20 device handle
Definition at line 178 of file sub20_interface.hpp.