ADTF_DEVICE_TOOLBOX  3.12.1 (ADTF 3.18.3)
can_types.h
Go to the documentation of this file.
1 
17 #pragma once
18 #include <stdint.h>
19 #include <string.h>
20 
24 namespace adtf
25 {
26 
30 namespace devicetb
31 {
32 
36 namespace sdk
37 {
38 
42 namespace can
43 {
44 
48 namespace axle
49 {
50 #pragma pack(push, 1)
51 
52 using tChannelID = uint8_t;
53 using tSignalID = uint32_t;
54 using tMessageID = uint32_t;
55 using tNetworkNodeID = uint32_t;
56 
57 static constexpr const uint8_t CAN_CHANNEL_MIN = 1;
58 static constexpr const uint8_t CAN_CHANNEL_MAX = 16;
59 // CAN standard message id 0..0x7FF
60 static constexpr const uint32_t CAN_MSGID_STANDARD_MAX = 0x7FF;
61 // CAN extended message id 0..0x1FFFFFFF
62 static constexpr const uint32_t CAN_MSGID_EXTENDED_MAX = 0x1FFFFFFF;
63 
64 static constexpr const uint8_t INVALID_CHANNEL_ID = 0xFF;
65 static constexpr const uint32_t INVALID_SIGNAL_ID = 0xFFFFFFFF;
66 static constexpr const uint32_t INVALID_MESSAGE_ID = 0xFFFFFFFF;
67 
68 static constexpr const uint32_t CAN_SIGNALID_HEADER_TAG = 0x10000000;
69 static constexpr const uint32_t CAN_SIGNALID_HEADER_CHANNEL = 0x10000001;
70 static constexpr const uint32_t CAN_SIGNALID_HEADER_HWTIME = 0x10000002;
71 
72 enum eSignalType
73 {
74  CAN_SIGNAL_TYPE_INVALID = 0,
75  CAN_SIGNAL_TYPE_NORMAL = 1,
76  CAN_SIGNAL_TYPE_MULTIPLEXOR = 2,
77  CAN_SIGNAL_TYPE_MULTIPLEXED = 3
78 };
79 
80 struct tValueInfo
81 {
82  uint32_t nValue;
83  const char* strDescription;
84 };
85 
86 typedef enum
87 {
88  DT_CAN_UNKNOWN = 0,
89  DT_CAN_UNSIGNED = 1,
90  DT_CAN_SIGNED = 2,
91  DT_CAN_IEEE_FLOAT = 3,
92  DT_CAN_IEEE_DOUBLE = 4
93 } tSignalRawDataType;
94 
96 {
97  tSignalID nSignalID;
98  tMessageID nMessageId;
99  bool bCANExtended;
100 
101  const char* strSignalName;
102  const char* strUnit;
103  const char* strDescription;
104 
105  uint8_t nSignalType;
106  uint8_t nStartbit;
107  uint8_t nBitlen;
108  uint8_t nType;
109 
111  bool bSigned;
114 
115  uint64_t nDefaultRawValue;
116  uint64_t nStartRawValue;
117  double f64Factor;
118  double f64Offset;
119  double f64Min;
120  double f64Max;
121 
122  uint32_t nValueTableSize;
124 
125  uint64_t nReserved2;
126 };
127 
129 {
130  enum eTypeTag
131  {
132  TAG_INVALID = 0,
133  TAG_RAW_VALUE = 1,
134  TAG_FLOAT64 = 2,
135  TAG_UINT64 = 3,
136  TAG_INT64 = 4,
137  TAG_UINT32 = 5,
138  TAG_INT32 = 6,
139  TAG_FLOAT32 = 7
140  };
141 
142  uint8_t nTypeTag = TAG_INVALID; // see eTypeTag
143  uint8_t nReserved[7] = {}; // reserved, set to 0
144 
145  union
146  {
147  float f32Value; // used when nTAG == TAG_FLOAT32
148  double f64Value; // used when nTag == TAG_FLOAT64
149  uint64_t nui64Value; // used when nTag == TAG_UINT64
150  int64_t ni64Value; // used when nTag == TAG_INT64
151  uint32_t nui32Value; // used when nTag == TAG_UINT32
152  int32_t ni32Value; // used when nTag == TAG_INT32
153  uint64_t n64RawValue = 0; // used when nTag == TAG_RAW_VALUE
154  };
155 
156  const char* strValue = nullptr; // Value from TEXTTABLE, may be NULL
157  uint8_t nReserved2[8] = {}; // reserved, set to 0
158 };
159 
161 {
162  tMessageID nMessageID;
164  const char* strMessageName;
165 
166  uint8_t nDataLength;
167  uint8_t nReserved[3];
168 
169  uint32_t nCycleTime;
170  tNetworkNodeID nNetworkNodeID;
171 
172  uint32_t nSignalCount;
174 
175  const char* strDescription;
176 };
177 
182 struct tCANData
183 {
189  {
190  MT_Data = 0,
191  MT_Status = 1,
192  };
193 
198  {
199  DF_NONE = 0,
203  };
204 
209  {
213  BS_ERROR_ACTIVE = 8
214  };
215 
220  enum eMsgId
221  {
222  MSG_IDMASK_BASE = 0x000007FF,
223  MSG_IDMASK_EXTENDED = 0x1FFFFFFF,
224  MSG_EXTENDED_FLAG = 0x80000000
225  };
226 
231  {
232  uint8_t ui8Tag;
233  uint8_t ui8Channel;
234  int64_t tmTimeStamp;
235  };
236 
240  struct tData
241  {
242  uint32_t ui32Id;
243  uint8_t ui8Length;
244  uint8_t ui8Reserved;
245  uint16_t ui16Flags;
246  uint16_t ui16Reserved;
247  uint32_t ui32Reserved;
248  uint8_t aui8Data[8];
249  };
250 
254  struct tStatus
255  {
256  uint32_t ui32BitRate;
257  uint32_t ui32RxBitCount;
258  uint32_t ui32TxBitCount;
261  uint8_t ui8BusStatus;
262  uint8_t ui8Reserved;
263  uint32_t ui32Reserved;
264  };
265 
267 
268  union
269  {
272  };
273 };
274 
275 #pragma pack(pop)
276 
277 } // namespace axle
278 
282 namespace jack
283 {
284 #pragma pack(push, 1)
285 
286 static constexpr const uint8_t CAN_CHANNEL_MIN = 0;
287 
288 #pragma pack(pop)
289 } //namespace jack
290 
291 using jack::CAN_CHANNEL_MIN;
292 using axle::CAN_CHANNEL_MAX;
293 
295 using tChannelID = axle::tChannelID;
296 using tSignalID = axle::tSignalID;
297 using tMessageID = axle::tMessageID;
298 using eSignalType = axle::eSignalType;
299 using tSignalRawDataType = axle::tSignalRawDataType;
303 
304 } // namespace can
305 } // namespace sdk
306 } // namespace devicetb
307 } // namespace adtf
axle::tChannelID tChannelID
Definition: can_types.h:295
axle::tMessageID tMessageID
Definition: can_types.h:297
axle::tMessageInfo tMessageInfo
Definition: can_types.h:302
axle::tSignalValue tSignalValue
Definition: can_types.h:301
axle::tSignalInfo tSignalInfo
Definition: can_types.h:300
axle::tCANData tCANData
The CAN data structure is used by CAN MediaSamples use following code within your filter:
Definition: can_types.h:294
axle::tSignalID tSignalID
Definition: can_types.h:296
ADTF - Namespace.
uint32_t ui32Reserved
reserved, should be zero
Definition: can_types.h:247
uint16_t ui16Reserved
reserved, should be zero
Definition: can_types.h:246
uint8_t ui8Length
length of data [0..8]
Definition: can_types.h:243
uint8_t ui8Reserved
reserved, should be zero
Definition: can_types.h:244
uint32_t ui32Id
id of can message. For extended CAN messages bit 31 is set. Use the members of the enum eMsgId to get...
Definition: can_types.h:242
uint8_t ui8Tag
Type of contained message (see eMessageTag)
Definition: can_types.h:232
int64_t tmTimeStamp
Hardware timestamp in micro seconds.
Definition: can_types.h:234
uint8_t ui8Channel
Channel that received this message.
Definition: can_types.h:233
uint32_t ui32Reserved
reserved, should be zero
Definition: can_types.h:263
uint32_t ui32RxBitCount
Count of received bits.
Definition: can_types.h:257
uint8_t ui8Reserved
reserved, should be zero
Definition: can_types.h:262
uint32_t ui32TxBitCount
Count of transmitted bits.
Definition: can_types.h:258
uint16_t ui16RxErrorCounter
Error counter for the receive section of the CAN controller.
Definition: can_types.h:259
uint16_t ui16TxErrorCounter
Error counter for the transmit section of the CAN controller.
Definition: can_types.h:260
The CAN data structure is used by CAN MediaSamples use following code within your filter:
Definition: can_types.h:183
tData sData
used when ui8Tag == MT_Data
Definition: can_types.h:270
eMessageTag
This enum specifies the different kinds of messages that may be contained in the union.
Definition: can_types.h:189
@ DF_TX_COMPLETED
Notification for successful message transmission.
Definition: can_types.h:202
@ DF_REMOTE_FRAME
Indicates a remote frame.
Definition: can_types.h:201
@ DF_ERROR_FRAME
Indicates an error frame.
Definition: can_types.h:200
@ MSG_IDMASK_EXTENDED
Message IDs for extended frame format use 29 bit identifiers.
Definition: can_types.h:223
@ MSG_EXTENDED_FLAG
Extended CAN messages are marked by bit 31.
Definition: can_types.h:224
@ MSG_IDMASK_BASE
Message IDs for base frame format use 11 bit identifiers.
Definition: can_types.h:222
tMessageHeader sHeader
CAN message header structure.
Definition: can_types.h:266
@ BS_ERROR_WARNING
One of the error counters has reached the warning level.
Definition: can_types.h:212
@ BS_ERROR_PASSIVE
One of the error counters has reached the error level.
Definition: can_types.h:211
tStatus sStatus
used when ui8Tag == MT_Status
Definition: can_types.h:271
uint32_t nSignalCount
Number of signals of this message.
Definition: can_types.h:172
const tSignalInfo * psSignalInfo
Pointer to array of signal infos.
Definition: can_types.h:173
const char * strDescription
Description of CAN message.
Definition: can_types.h:175
const char * strMessageName
Name of can message.
Definition: can_types.h:164
tNetworkNodeID nNetworkNodeID
Network node id.
Definition: can_types.h:170
uint32_t nCycleTime
Cycle time of message in milliseconds (0 if undefined)
Definition: can_types.h:169
tMessageID nMessageID
CAN message id.
Definition: can_types.h:162
uint8_t nDataLength
Length of message [bytes].
Definition: can_types.h:166
int32_t nRequiredMultiplexorValue
Required multiplexor value for this signal to be valid.
Definition: can_types.h:113
uint64_t nStartRawValue
Represents the GenSigStartValue.
Definition: can_types.h:116
uint8_t nBitlen
Bit length of CAN signal.
Definition: can_types.h:107
const char * strDescription
Description of CAN signal.
Definition: can_types.h:103
tMessageID nMessageId
CAN message id.
Definition: can_types.h:98
uint64_t nDefaultRawValue
Represents the GenSigInactiveValue.
Definition: can_types.h:115
double f64Factor
Scale factor of CAN signal.
Definition: can_types.h:117
double f64Offset
Offset value of CAN signal.
Definition: can_types.h:118
uint32_t nValueTableSize
Size of value table array (0 if no table is defined)
Definition: can_types.h:122
const char * strSignalName
Name of CAN signal.
Definition: can_types.h:101
uint8_t nStartbit
Startbit of CAN signal.
Definition: can_types.h:106
tValueInfo * pValueTable
Pointer to sorted value table array.
Definition: can_types.h:123
tSignalID nMultiplexorSignalID
Signal ID of multiplexor.
Definition: can_types.h:112
uint8_t nType
is type IEEE Float or IEEE Double (see tSignalRawDataType)
Definition: can_types.h:108
const char * strUnit
Unit of CAN signal.
Definition: can_types.h:102
double f64Min
Minimum value of range of CAN signal.
Definition: can_types.h:119
double f64Max
Maximum value of range of CAN signal.
Definition: can_types.h:120
bool bByteOrderMotorola
Byte order of signal is motorola.
Definition: can_types.h:110
bool bSigned
Indicates if signal is signed value or not.
Definition: can_types.h:111
const char * strDescription
Description.
Definition: can_types.h:83