CARMA C++
|
This namespace contains all canbus library related code. More...
Classes | |
struct | busStatusStruct |
Bus Status type. More... | |
class | CanDio |
Class to control the CARMA specialized Janz CAN/DIO card. More... | |
class | CanIo |
CanIo interface. More... | |
class | CanOutput |
CanOutput interface. More... | |
class | Device |
Abstract base class for all CAN Bus devices. More... | |
class | DeviceNames |
Completely static class to retrieve string names of CAN devices based on API Id. More... | |
class | Dio |
Dio abstract base class. More... | |
class | DirectCan |
The DirectCan class is intended for use as a way to access the CANbus from multiple separate processes in conjunction with a process implementing the DO model. More... | |
class | GpioDio |
GpioDio class for use with gpio framework. More... | |
class | InetCan |
InetCan class. More... | |
class | JanzCanIo |
JanzCanIo class. More... | |
class | JanzDio |
Dio class for use with Janz char driver. More... | |
class | JanzMessage |
This class encapsulate a Janz CAN message. More... | |
class | Master |
Carma Canbus Master class. More... | |
class | MasterOfNone |
Carma CAN MasterOfNone class. More... | |
class | Message |
Class to encapsulate a CAN message. More... | |
class | SocketCan |
Implements the CanIo interface using the socketcan framework. More... | |
Typedefs | |
typedef unsigned short | apiType |
Carma API id type. More... | |
typedef unsigned short | boardType |
Carma Board Type id type. More... | |
typedef unsigned short | busIdType |
Carma Bus Id type. More... | |
typedef enum carma::canbus::busStateEnum | busStateType |
Bus State type. More... | |
typedef std::map< busIdType, busStatusType > | BusStatusMap |
Map to hold bus status for multiple busses. More... | |
typedef struct carma::canbus::busStatusStruct | busStatusType |
Bus Status type. More... | |
typedef unsigned char | BYTE_t |
typedef unsigned char | byteType |
Base raw CAN byte. More... | |
typedef ::std::vector < ::carma::canbus::byteType > | DataVector |
Alias for CAN data. More... | |
typedef enum carma::canbus::deviceStateEnum | deviceStateType |
typedef unsigned int | idType |
Type for full 29 bit CAN id. More... | |
typedef unsigned int | keyType |
Unique key identifier for each device. More... | |
typedef enum carma::canbus::modeTypeEnum | modeType |
Mode type. More... | |
typedef ::std::map < ::carma::canbus::msgType,::std::string > | MsgBriefMap |
Alias for message descriptions keyed by message id. More... | |
typedef ::std::map < ::carma::canbus::msgType,::std::string > | MsgIdInfoMap |
Alias for an ::std::map containing a string description of a message id, keyed by the described carma::canbus::msgType message id. More... | |
typedef unsigned short | msgType |
Carma Message id type. More... | |
typedef unsigned short | nodeType |
Carma Node Type id type. More... | |
typedef unsigned short | portType |
Port id type for multi-port boards. More... | |
typedef unsigned short | serialNumberType |
Carma Serial Number type. More... | |
Enumerations | |
enum | busStateEnum { NO_ERRORS = 0, ERROR_ACTIVE = 1, ERROR_PASSIVE = 2, BUS_OFF = 3 } |
Bus State type. More... | |
enum | deviceStateEnum { OFFLINE, STARTING, ONLINE, SIMULATED } |
Device state type enumeration. More... | |
enum | modeTypeEnum { ENGINEERING = 1, APPLICATION = 0 } |
Mode type. More... | |
enum | txPriorityType { HIGH = 1, NORMAL = 2, LOW = 3 } |
CAN Tx priority type. More... | |
Functions | |
timespec | calculateTimeToNextHalfSec () |
Calculate the time to the next half second boundary. More... | |
timespec | calculateTimeToNextSlowBoundary () |
Calculate the time to the next five second boundary. More... | |
idType | createEngId (bool host, boardType board, serialNumberType serialNumber, msgType mid) |
Produce a CAN message from a board type and serial number (engineering message). More... | |
idType | createId (bool host, apiType api, nodeType node, msgType mid) |
Create a CAN id from api, node and mid. More... | |
double | dataToDouble (std::vector< byteType > &data) |
Convert data vector to IEEE double. More... | |
float | dataToFloat (std::vector< byteType > &data) |
Convert data vector to IEEE float. More... | |
long | dataToLong (std::vector< byteType > &data) |
Convert data vector to signed long integer. More... | |
short | dataToShort (std::vector< byteType > &data) |
Convert data vector to signed short integer. More... | |
unsigned char | dataToUbyte (std::vector< byteType > &data) |
Convert data vector to unsigned byte. More... | |
unsigned long | dataToUlong (std::vector< byteType > &data) |
Convert data vector to unsigned long integer. More... | |
unsigned short | dataToUshort (std::vector< byteType > &data) |
Convert data vector to unsigned short integer. More... | |
void | doubleToData (std::vector< byteType > &data, double value) |
Convert a IEEE 754-1990 double float (8 bytes) into raw CAN bytes. More... | |
busIdType | extractBusId (std::string filename) |
Extract the busId from a string containing the device filename. More... | |
void | floatToData (std::vector< byteType > &data, float value) |
Convert a IEEE 754-1990 float (4 bytes) into raw CAN bytes. More... | |
void | fromEngId (boardType &bt, serialNumberType &sn, msgType &mid, idType engId) |
Convert a raw CAN id to board type, serial number and mid. More... | |
void | fromId (apiType &api, nodeType &node, msgType &mid, idType id) |
Convert a raw CAN id to api code, node location and mid. More... | |
modeType | getMode (idType id) |
Extract the address mode from a 29 bit can id. More... | |
bool | isToHost (idType id) |
Extract the host bit from a 29 bit CAN id. More... | |
MAKE_DERIVED_ERROR_EXCEPTION (SystemException) | |
MAKE_DERIVED_ERROR_EXCEPTION (TxBufferFullException) | |
MAKE_DERIVED_ERROR_EXCEPTION (BadDataSizeException) | |
MAKE_DERIVED_ERROR_EXCEPTION (BadParameterException) | |
MAKE_DERIVED_ERROR_EXCEPTION (BufferOverflowException) | |
MAKE_DERIVED_ERROR_EXCEPTION (JanzFailException) | |
MAKE_DERIVED_ERROR_EXCEPTION (PthreadFailException) | |
void | padWithZeros (std::vector< byteType > &data) |
Pad an input vector with up to 8 bytes of zeros. More... | |
void | sLongToData (std::vector< byteType > &data, long value) |
Convert a signed long integer (4 bytes) into raw CAN bytes. More... | |
void | sShortToData (std::vector< byteType > &data, short value) |
Convert a signed short integer (2 bytes) into raw CAN bytes. More... | |
void | uByteToData (std::vector< byteType > &data, unsigned char value) |
Convert a unsigned char into raw CAN bytes. More... | |
void | uLongToData (std::vector< byteType > &data, unsigned long value) |
Convert an unsigned long integer (4 bytes) into raw CAN bytes. More... | |
void | uShortToData (std::vector< byteType > &data, unsigned short value) |
Convert an unsigned short integer (2 bytes) into raw CAN bytes. More... | |
int | validateModulbusNo (int modulbusNo) |
Validate a modulbusNo. More... | |
int | validateSlotNo (int slotNo) |
Validate slot number for CANbus slot. More... | |
Variables | |
const busIdType | ALL_BUSSES = 0xffff |
Specifies that a message should be sent to ALL_BUSSES. More... | |
const std::string | CAN_INPUT_IPQ = "/can-input.ipq" |
const std::string | CAN_OUTPUT_IPQ = "/can-output.ipq" |
const apiType | DUMMY_PKT_API = 0xFF |
Dummy packet api. More... | |
const msgType | DUMMY_PKT_MID = 0x3FF |
Dummy packet message id. More... | |
const long | IPQ_BUFFER_SIZE = 150000 |
DirectCan IPQ buffer sizes. More... | |
const int | NANOSECS_PER_SEC = 1000000000 |
const bool | TO_HOST = true |
Constant for bool host parameter of createId indicating that the message is to be addressed to the linux host. More... | |
const bool | TO_NODES = false |
Constant for bool host parameter of createId indicating that the message is to be addressed to the can nodes on the bus. More... | |
This namespace contains all canbus library related code.
typedef unsigned short carma::canbus::apiType |
typedef unsigned short carma::canbus::boardType |
typedef unsigned short carma::canbus::busIdType |
typedef enum carma::canbus::busStateEnum carma::canbus::busStateType |
Bus State type.
The Bus states are standard CAN bus states which are defined by the number of rx or tx errors recorded by the CAN controller.
typedef std::map< busIdType, busStatusType > carma::canbus::BusStatusMap |
typedef struct carma::canbus::busStatusStruct carma::canbus::busStatusType |
Bus Status type.
Bus status contains variables useful for determining the health of the bus. They are maintained by CanIo
typedef unsigned char carma::canbus::byteType |
typedef ::std::vector< ::carma::canbus::byteType> carma::canbus::DataVector |
typedef unsigned int carma::canbus::idType |
typedef unsigned int carma::canbus::keyType |
typedef enum carma::canbus::modeTypeEnum carma::canbus::modeType |
Mode type.
The mode type is extracted from the CAN id. It is a single bit and designates how the application should interpret the 29 bit CAN id.
typedef ::std::map< ::carma::canbus::msgType, ::std::string > carma::canbus::MsgBriefMap |
typedef ::std::map< ::carma::canbus::msgType, ::std::string > carma::canbus::MsgIdInfoMap |
Alias for an ::std::map containing a string description of a message id, keyed by the described carma::canbus::msgType message id.
typedef unsigned short carma::canbus::msgType |
typedef unsigned short carma::canbus::nodeType |
typedef unsigned short carma::canbus::portType |
typedef unsigned short carma::canbus::serialNumberType |
Bus State type.
The Bus states are standard CAN bus states which are defined by the number of rx or tx errors recorded by the CAN controller.
Enumerator | |
---|---|
NO_ERRORS |
Rx and tx error count = 0. |
ERROR_ACTIVE |
Rx and tx error count < 127. |
ERROR_PASSIVE |
Rx and tx error count < 255. |
BUS_OFF |
Rx and tx error count = 255. |
Device state type enumeration.
Defines the various states of a CAN device.
timespec carma::canbus::calculateTimeToNextHalfSec | ( | ) |
Calculate the time to the next half second boundary.
This routine calculates the amount of time necessary to sleep until the next half second boundary as determined by absolute time.
timespec carma::canbus::calculateTimeToNextSlowBoundary | ( | ) |
Calculate the time to the next five second boundary.
This routine calculates the amount of time necessary to sleep until the next five second boundary as determined by absolute time.
idType carma::canbus::createEngId | ( | bool | host, |
boardType | board, | ||
serialNumberType | serialNumber, | ||
msgType | mid | ||
) |
Produce a CAN message from a board type and serial number (engineering message).
host | send to host. |
board | the board id being addressed. |
serialNumber | of board being addressed. |
mid | message id. |
idType carma::canbus::createId | ( | bool | host, |
apiType | api, | ||
nodeType | node, | ||
msgType | mid | ||
) |
Create a CAN id from api, node and mid.
Creates an application message from the api, node and message id addressed to either the host or nodes.
host | addressed to host or nodes. |
api | id. |
node | message node location id. |
mid | of message. |
double carma::canbus::dataToDouble | ( | std::vector< byteType > & | data | ) |
Convert data vector to IEEE double.
This routine interprets the first 8 bytes of a vector of raw CAN data as an IEEE double floating point value. It then extracts, converts and returns the double.
data | is the vector to extract the double from. |
carma::canbus::BadDataSizeException | if data vector is < than 8 bytes. |
float carma::canbus::dataToFloat | ( | std::vector< byteType > & | data | ) |
Convert data vector to IEEE float.
This routine interprets the first 4 bytes of a vector of raw CAN data as an IEEE floating point value. It then extracts, converts and returns the float.
data | is the vector to extract the float from. |
carma::canbus::BadDataSizeException | if data vector is < than 4 bytes. |
long carma::canbus::dataToLong | ( | std::vector< byteType > & | data | ) |
Convert data vector to signed long integer.
This routine interprets the first 4 bytes of a vector of raw CAN data as an signed long integer in network byte order. It then extracts, converts and returns the signed int.
data | is the vector to extract the signed long from. |
carma::canbus::BadDataSizeException | if data vector is < than 4 bytes. |
short carma::canbus::dataToShort | ( | std::vector< byteType > & | data | ) |
Convert data vector to signed short integer.
This routine interprets the first 2 bytes of a vector of raw CAN data as an signed short integer in network byte order. It then extracts, converts and returns the signed int.
data | is the vector to extract the signed short from. |
carma::canbus::BadDataSizeException | if data vector is < than 2 bytes. |
unsigned char carma::canbus::dataToUbyte | ( | std::vector< byteType > & | data | ) |
Convert data vector to unsigned byte.
This routine interprets the first byte of a vector of raw CAN data as an unsigned byte and returns the byte.
data | is the vector to extract the unsigned byte from. |
carma::canbus::BadDataSizeException | if data vector is empty. |
unsigned long carma::canbus::dataToUlong | ( | std::vector< byteType > & | data | ) |
Convert data vector to unsigned long integer.
This routine interprets the first 4 bytes of a vector of raw CAN data as an unsigned long integer in network byte order. It then extracts, converts and returns the unsigned int.
data | is the vector to extract the unsigned long from. |
carma::canbus::BadDataSizeException | if data vector is < than 4 bytes. |
unsigned short carma::canbus::dataToUshort | ( | std::vector< byteType > & | data | ) |
Convert data vector to unsigned short integer.
This routine interprets the first 2 bytes of a vector of raw CAN data as an unsigned short integer in network byte order. It then extracts, converts and returns the unsigned int.
data | is the vector to extract the unsigned short from. |
carma::canbus::BadDataSizeException | if data vector is < than 2 bytes. |
void carma::canbus::doubleToData | ( | std::vector< byteType > & | data, |
double | value | ||
) |
Convert a IEEE 754-1990 double float (8 bytes) into raw CAN bytes.
This routine takes an input double float value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the double to append to the data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
busIdType carma::canbus::extractBusId | ( | std::string | filename | ) |
Extract the busId from a string containing the device filename.
In order to maintain unique busIds on a multiprocess multi canbus system, I use the can device filename to determine the bus Id.
carma::canbus::BadParameterException | if input filename is invalid. |
void carma::canbus::floatToData | ( | std::vector< byteType > & | data, |
float | value | ||
) |
Convert a IEEE 754-1990 float (4 bytes) into raw CAN bytes.
This routine takes an input floating point value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the float to append to the data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
void carma::canbus::fromEngId | ( | boardType & | bt, |
serialNumberType & | sn, | ||
msgType & | mid, | ||
idType | engId | ||
) |
Convert a raw CAN id to board type, serial number and mid.
bt | board type id. |
sn | serial number id. |
mid | message id. |
engId | full Engineering CAN message id. |
void carma::canbus::fromId | ( | apiType & | api, |
nodeType & | node, | ||
msgType & | mid, | ||
idType | id | ||
) |
Convert a raw CAN id to api code, node location and mid.
api | api id. |
node | node id. |
mid | message id. |
id | full CAN message id. |
modeType carma::canbus::getMode | ( | idType | id | ) |
Extract the address mode from a 29 bit can id.
id | 29 bit CAN address. |
bool carma::canbus::isToHost | ( | idType | id | ) |
Extract the host bit from a 29 bit CAN id.
id | 29 bit CAN address. |
void carma::canbus::padWithZeros | ( | std::vector< byteType > & | data | ) |
Pad an input vector with up to 8 bytes of zeros.
This routine takes the input data, calculates it's size and fills the remaining space with up to 8 bytes of '0's. For example a single byte data vector, after being input to this routine, will contain the original data and 7 '0's.
data | reference to vector to be stuffed with '0's. |
carma::canbus::BadDataSizeException | if data vector is > than 8 bytes. |
void carma::canbus::sLongToData | ( | std::vector< byteType > & | data, |
long | value | ||
) |
Convert a signed long integer (4 bytes) into raw CAN bytes.
This routine takes an input signed long integer value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the signed long int to append to data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
void carma::canbus::sShortToData | ( | std::vector< byteType > & | data, |
short | value | ||
) |
Convert a signed short integer (2 bytes) into raw CAN bytes.
This routine takes an input signed short integer value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the signed short int to append to data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
void carma::canbus::uByteToData | ( | std::vector< byteType > & | data, |
unsigned char | value | ||
) |
Convert a unsigned char into raw CAN bytes.
This routine takes an input unsigned char value and adds it to the input vector of raw CAN bytes. This enbables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is a reference to a vector which the data will be appended to. |
data | is the vector to append the data to. |
value | is the unsigned char to be appended to data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
void carma::canbus::uLongToData | ( | std::vector< byteType > & | data, |
unsigned long | value | ||
) |
Convert an unsigned long integer (4 bytes) into raw CAN bytes.
This routine takes an input unsigned long integer value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the unsigned long int to append to data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
void carma::canbus::uShortToData | ( | std::vector< byteType > & | data, |
unsigned short | value | ||
) |
Convert an unsigned short integer (2 bytes) into raw CAN bytes.
This routine takes an input unsigned short integer value and adds it to the input vector of raw CAN bytes in network byte order. This enables one to build a full CAN data packet by consecutively calling the appropriate typeToData routine.
data | is the vector to append the data to. |
value | is the unsigned short int to append to data. |
carma::canbus::BadDataSizeException | if resulting vector is > than 8 bytes. |
int carma::canbus::validateModulbusNo | ( | int | modulbusNo | ) |
Validate a modulbusNo.
The janz modulbus hardware has a hex switch to designate the modulbus id of the board. This routine, checks to make sure that a modulbusNo is within the range of 0x00 to 0x0f.
modulbusNo | to validate. |
carma::canbus::BadParameterException | if invalid modulbusNo. |
int carma::canbus::validateSlotNo | ( | int | slotNo | ) |
Validate slot number for CANbus slot.
The specialized janz CANDio card contains CANbus cards in modulbus slots 0 and 1 only. This routine checks to make sure that a input slot number is within that range and throws an exception otherwise.
slotNo | to validate. |
carma::canbus::BadParameterException | if invalid slotNo. |
const busIdType carma::canbus::ALL_BUSSES = 0xffff |
const apiType carma::canbus::DUMMY_PKT_API = 0xFF |
const msgType carma::canbus::DUMMY_PKT_MID = 0x3FF |
const long carma::canbus::IPQ_BUFFER_SIZE = 150000 |
const bool carma::canbus::TO_HOST = true |
Constant for bool host parameter of createId indicating that the message is to be addressed to the linux host.
Definition at line 45 of file Utilities.h.
const bool carma::canbus::TO_NODES = false |
Constant for bool host parameter of createId indicating that the message is to be addressed to the can nodes on the bus.
Definition at line 51 of file Utilities.h.