Public Member Functions | Private Member Functions | Private Attributes
Sub20Interface Class Reference

The sub20 hardware interface. More...

#include <sub20_interface.hpp>

Inheritance diagram for Sub20Interface:
Inheritance graph
[legend]

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

Sub20Interface::Sub20Interface ( std::string  sub20_serial_number = "null")

constructor, which takes in an optional argument, which is the sub20's 4-digit serial number.

Parameters:
std::stringsub20_serial_number
Note:
if no argument is passed to the constructor, the constructor will simply get a handle on the first sub20 it finds that is plugged in. Furthermore, this method prints the serial number to the screen. This is an excellent way of finding out the 4-digit serial number of your sub20 if you do not already know it.
Knowing the sub20 serial number is only relevant for a sensor configuration that involves multiple sub20s connected to the same computer.
Warning:
the string "null" is a magic value also used in the cpp file because static const std::strings cannot be created in headers.

Definition at line 43 of file sub20_interface.cpp.

destructor

Definition at line 55 of file sub20_interface.cpp.


Member Function Documentation

std::string Sub20Interface::getID ( ) [virtual]
Returns:
the way the sensor identifies itself.

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.

Returns:
the number of devices connected via this particular sub20 instance.

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

Parameters:
intdevice_address the way that the sensor identifies itself
interface_protocolprotocol the defined protocol
intfrequency the frequency of the interface protocol
int*flags additional information necessary to read from that particular interface protocol.
uint8_treg_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_tnum_bytes the number of bytes to be read from the sensor.
Returns:
num_bytes or a value less than zero, if the read failed.

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.

returns true if the input protocol is supported by the hardware interface.

Parameters:
interface_protocolprotocol the input protocol.
Returns:
true, if the hardware interface supports reading and writing on that particular 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

Parameters:
intdevice_address the way that the sensor itentifies itself
interface_protocolprotocol the defined protocol
intfrequency the frequency of the interface protocol
int*flags additional information necessary to read from that particular interface protocol.
uint8_treg_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_tnum_bytes the number of bytes to be written to the sensor.
Returns:
num_bytes or a value less than zero, if the read failed.

Definition at line 231 of file sub20_interface.cpp.


Member Data Documentation

Definition at line 176 of file sub20_interface.hpp.

sub_handle Sub20Interface::handle_ [private]

Definition at line 177 of file sub20_interface.hpp.

Definition at line 182 of file sub20_interface.hpp.

Definition at line 180 of file sub20_interface.hpp.

Definition at line 175 of file sub20_interface.hpp.

std::string Sub20Interface::serialNumber_ [private]

Definition at line 179 of file sub20_interface.hpp.

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.


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


sub20_interface
Author(s): Joshua Vasquez and Philip Roan. Maintained by Philip Roan
autogenerated on Mon Oct 6 2014 10:09:57