-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmessage.h
176 lines (124 loc) · 3.14 KB
/
message.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include "attributes.h"
#include "comment.h"
enum class BitLayout
{
kIntel = 0,
kMotorolla
};
enum class MultiplexType
{
kNone,
kMaster,
kMulValue
};
enum class SigType
{
i8 = 0,
i16,
i32,
i64,
u8,
u16,
u32,
u64
};
typedef struct
{
// Signal name
std::string Name;
// Signal float name
std::string NameFloat;
// Unit
std::string Unit;
uint32_t StartBit;
uint8_t LengthBit;
// By next two fields any signal can be strictly related to one of
// 3 signal type:
// 1 double based scaled value (IsDoubleSig == true)
// 2 integer based scaled value (IsDoubleSig == false && IsSimpleSig == false)
// 3 simple (IsDoubleSig == false && IsSimpleSig == true)
// this flag shows when factor (or offset) is double
// it is used when *_from_S and _to_S macros is generated
bool IsDoubleSig;
// this flag shows if the signal has factor = 1 and offset = 0
// to reject any sigfloat or "toS"/"fromS" operations
// SimpleSig is true when: IsDoubleSig == false && Factor == 1 && Offset == 0
bool IsSimpleSig;
double Factor;
double Offset;
double RawOffset;
BitLayout Order;
bool Signed;
SigType TypeRo;
SigType TypePhys;
std::vector<std::string> SigToByte;
double MinValue;
double MaxValue;
std::vector<std::string> RecS;
ValTable_t ValDefs;
std::string CommentText;
std::string ValueText;
MultiplexType Multiplex;
} SignalDescriptor_t;
typedef struct
{
// Pointer on message name
std::string Name;
// Value of message length in bytes
uint8_t DLC;
// Message CAN identifier
uint32_t MsgID;
// Extended frame type mark, if 0 then standart frame
uint8_t IsExt;
// Frame cycle time im ms
uint32_t Cycle;
// Name of transmitter ECU
std::vector<std::string> TranS;
// List of ECUs to receive frame
std::vector<std::string> RecS;
// List of Message signals
std::vector<SignalDescriptor_t> Signals;
// flag about having sigfloat fields
bool hasPhys;
// flag if frame has at least one signal (not empty)
bool frameNotEmpty;
// pointer to rolling counter signal
SignalDescriptor_t* RollSig;
// pointer to checksum signal
SignalDescriptor_t* CsmSig;
// keeps the method or crc algorythm (will be passed to CRC calc function)
std::string CsmMethod;
// option value (will be passed to CRC calc function)
uint32_t CsmOp;
// expression to load CSM signal to byte
std::string CsmToByteExpr;
// byte number in payload which keeps CS value
uint8_t CsmByteNum;
// Message comment
std::string CommentText;
} MessageDescriptor_t;
typedef struct
{
std::vector<uint32_t> Rx;
std::vector<uint32_t> Tx;
std::vector<uint32_t> Both;
} MsgsClassification;
typedef struct
{
uint32_t hi;
uint32_t low;
} DbcFileVersion_t;
typedef struct
{
// Array of all the parsed messages from DBC file
std::vector<MessageDescriptor_t*> msgs;
// The value of maximum DLC value among the parsed messages
size_t maxDlcValue;
// DBC file version values to be printed as macro values inside driver source code
DbcFileVersion_t ver;
} DbcMessageList_t;