CARMA C++
Types.h
Go to the documentation of this file.
1 
9 #ifndef CARMA_CANBUS_TYPES_H
10 #define CARMA_CANBUS_TYPES_H
11 
12 // C++ Standard Library includes
13 #include <map>
14 #include <string>
15 #include <vector>
16 
57 namespace carma {
58 namespace canbus {
59 
60  typedef unsigned int idType;
61  typedef unsigned char byteType;
62  typedef unsigned short portType;
64  typedef unsigned short apiType;
65  typedef unsigned short boardType;
66  typedef unsigned short nodeType;
67  typedef unsigned short serialNumberType;
68  typedef unsigned int keyType;
69  typedef unsigned short msgType;
70  typedef unsigned short busIdType;
72  typedef ::std::vector< ::carma::canbus::byteType> DataVector;
74  typedef ::std::map< ::carma::canbus::msgType, ::std::string > MsgBriefMap;
75 
80  const apiType DUMMY_PKT_API = 0xFF;
81 
86  const msgType DUMMY_PKT_MID = 0x3FF;
87 
91  const busIdType ALL_BUSSES = 0xffff;
92 
99  typedef enum modeTypeEnum {
102  } modeType;
103 
110  typedef enum busStateEnum {
111  NO_ERRORS = 0,
114  BUS_OFF = 3,
115  } busStateType;
116 
124  typedef struct busStatusStruct {
126  volatile double rxMsgRate;
127  volatile double txMsgRate;
128  volatile double oneMinRxMsgRate;
129  volatile double oneMinTxMsgRate;
130  volatile unsigned short rxErrors;
131  volatile unsigned short txErrors;
136  volatile unsigned int slowMsgsLost;
141  volatile unsigned int fastMsgsLost;
142 
147  volatile int tsEchoLatency;
148  } busStatusType;
149 
153  typedef std::map< busIdType, busStatusType > BusStatusMap;
154 
183  typedef enum deviceStateEnum {
188  } deviceStateType;
189 
194  typedef enum {
195  HIGH = 1,
196  NORMAL = 2,
197  LOW = 3,
198  } txPriorityType;
199 
200  // Useful constants.
201  const int NANOSECS_PER_SEC = 1000000000;
202 
203  // IPQ name string constants. The CAN_INPUT_IPQ is the name
204  // of the ipq that will be written by DirectCan, read from CanIo
205  // and rewritten to the CANbus. The CAN_OUTPUT_IPQ is the name
206  // of the ipq that will be read by DirectCan, written to by
207  // CanIo with messages read from the CANbus.
208  const std::string CAN_INPUT_IPQ = "/can-input.ipq";
209  const std::string CAN_OUTPUT_IPQ = "/can-output.ipq";
210  // The IPQ is very large in order to accomodate an entire remote firmware
211  // upload (roughly 40,000 messages and 3x as many dummy packets). This
212  // allows us to very rapidly download firmware.
213  const long IPQ_BUFFER_SIZE = 150000;
215 } // namespace canbus
216 } // namespace carma
217 #endif
unsigned short portType
Port id type for multi-port boards.
Definition: Types.h:62
unsigned int keyType
Unique key identifier for each device.
Definition: Types.h:68
volatile unsigned short rxErrors
Current CAN rx errors.
Definition: Types.h:130
volatile double rxMsgRate
Half sec averaged rx msg rate.
Definition: Types.h:126
busStateType state
State of bus.
Definition: Types.h:125
unsigned short boardType
Carma Board Type id type.
Definition: Types.h:65
unsigned char byteType
Base raw CAN byte.
Definition: Types.h:61
volatile unsigned short txErrors
Current CAN tx errors.
Definition: Types.h:131
const busIdType ALL_BUSSES
Specifies that a message should be sent to ALL_BUSSES.
Definition: Types.h:91
Decode CAN id in API, Node form.
Definition: Types.h:101
deviceStateEnum
Device state type enumeration.
Definition: Types.h:183
volatile unsigned int slowMsgsLost
Count of Janz slow msgs lost (slow msgs are messages to communicate with the Janz board only)...
Definition: Types.h:136
Rx and tx error count &lt; 127.
Definition: Types.h:112
Host is receiving CAN messages on a half second time scale.
Definition: Types.h:186
Rx and tx error count = 0.
Definition: Types.h:111
Monitor packets are not being received from the module.
Definition: Types.h:184
enum carma::canbus::modeTypeEnum modeType
Mode type.
enum carma::canbus::busStateEnum busStateType
Bus State type.
modeTypeEnum
Mode type.
Definition: Types.h:99
volatile unsigned int fastMsgsLost
Count of Janz fast msgs lost (fast msgs are CAN messages only).
Definition: Types.h:141
const long IPQ_BUFFER_SIZE
DirectCan IPQ buffer sizes.
Definition: Types.h:213
const apiType DUMMY_PKT_API
Dummy packet api.
Definition: Types.h:80
unsigned short apiType
Carma API id type.
Definition: Types.h:64
Rx and tx error count &lt; 255.
Definition: Types.h:113
struct carma::canbus::busStatusStruct busStatusType
Bus Status type.
unsigned short serialNumberType
Carma Serial Number type.
Definition: Types.h:67
std::map< busIdType, busStatusType > BusStatusMap
Map to hold bus status for multiple busses.
Definition: Types.h:153
unsigned short nodeType
Carma Node Type id type.
Definition: Types.h:66
::std::map< ::carma::canbus::msgType,::std::string > MsgBriefMap
Alias for message descriptions keyed by message id.
Definition: Types.h:74
::std::vector< ::carma::canbus::byteType > DataVector
Alias for CAN data.
Definition: Types.h:72
Host is simulating the receipt of monitor packets for this module.
Definition: Types.h:187
volatile double oneMinTxMsgRate
1 Min averaged tx msg rate
Definition: Types.h:129
Decode CAN Id in serial num, board type form.
Definition: Types.h:100
txPriorityType
CAN Tx priority type.
Definition: Types.h:194
unsigned int idType
Type for full 29 bit CAN id.
Definition: Types.h:60
const msgType DUMMY_PKT_MID
Dummy packet message id.
Definition: Types.h:86
The module has sent out a single slow monitor packet to identify itself.
Definition: Types.h:185
busStateEnum
Bus State type.
Definition: Types.h:110
unsigned short busIdType
Carma Bus Id type.
Definition: Types.h:70
Bus Status type.
Definition: Types.h:124
volatile int tsEchoLatency
Time elapsed from the time timestamp is created to when it is echoed back to the host and processed (...
Definition: Types.h:147
unsigned short msgType
Carma Message id type.
Definition: Types.h:69
Rx and tx error count = 255.
Definition: Types.h:114
volatile double txMsgRate
Half sec averaged tx msg rate.
Definition: Types.h:127
volatile double oneMinRxMsgRate
1 Min averaged rx msg rate
Definition: Types.h:128