Skip to content

Commit 013b993

Browse files
committed
Test DBC with new val table macros generated.
1 parent 6661cdd commit 013b993

File tree

3 files changed

+133
-5
lines changed

3 files changed

+133
-5
lines changed

test/gencode/lib/testdb.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
#endif // TESTDB_USE_DIAG_MONITORS
1010

1111

12-
// To compile this function you need to typedef 'bitext_t' and 'ubitext_t'
13-
// globally in @dbccodeconf.h or locally in 'dbcdrvname'-config.h
14-
// Type selection may affect common performance. Most useful types are:
15-
// bitext_t : int64_t and ubitext_t : uint64_t
16-
static bitext_t __ext_sig__( ubitext_t val, uint8_t bits )
12+
// This function performs extension of sign for the signals
13+
// which have non-aligned to power of 2 bit's width.
14+
// The types 'bitext_t' and 'ubitext_t' define maximal bit width which
15+
// can be correctly handled. You need to select type which can contain
16+
// n+1 bits where n is the largest signed signal width. For example if
17+
// the most wide signed signal has a width of 31 bits you need to set
18+
// bitext_t as int32_t and ubitext_t as uint32_t
19+
// Defined these typedefs in @dbccodeconf.h or locally in 'dbcdrvname'-config.h
20+
static bitext_t __ext_sig__(ubitext_t val, uint8_t bits)
1721
{
1822
ubitext_t const m = 1u << (bits - 1);
1923
return (val ^ m) - m;
@@ -177,6 +181,7 @@ uint32_t Unpack_UTEST_3_testdb(UTEST_3_t* _m, const uint8_t* _d, uint8_t dlc_)
177181
{
178182
(void)dlc_;
179183
_m->U32_TEST_1 = ((_d[3] & (0xFFU)) << 24) | ((_d[2] & (0xFFU)) << 16) | ((_d[1] & (0xFFU)) << 8) | (_d[0] & (0xFFU));
184+
_m->TestValTableID = (_d[4] & (0x07U));
180185

181186
#ifdef TESTDB_USE_DIAG_MONITORS
182187
_m->mon1.dlc_error = (dlc_ < UTEST_3_DLC);
@@ -199,6 +204,7 @@ uint32_t Pack_UTEST_3_testdb(UTEST_3_t* _m, __CoderDbcCanFrame_t__* cframe)
199204
cframe->Data[1] |= ((_m->U32_TEST_1 >> 8) & (0xFFU));
200205
cframe->Data[2] |= ((_m->U32_TEST_1 >> 16) & (0xFFU));
201206
cframe->Data[3] |= ((_m->U32_TEST_1 >> 24) & (0xFFU));
207+
cframe->Data[4] |= (_m->TestValTableID & (0x07U));
202208

203209
cframe->MsgId = UTEST_3_CANID;
204210
cframe->DLC = UTEST_3_DLC;
@@ -216,6 +222,7 @@ uint32_t Pack_UTEST_3_testdb(UTEST_3_t* _m, uint8_t* _d, uint8_t* _len, uint8_t*
216222
_d[1] |= ((_m->U32_TEST_1 >> 8) & (0xFFU));
217223
_d[2] |= ((_m->U32_TEST_1 >> 16) & (0xFFU));
218224
_d[3] |= ((_m->U32_TEST_1 >> 24) & (0xFFU));
225+
_d[4] |= (_m->TestValTableID & (0x07U));
219226

220227
*_len = UTEST_3_DLC;
221228
*_ide = UTEST_3_IDE;

test/gencode/lib/testdb.h

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ extern "C" {
2727
#define UTEST_2_IDE (0U)
2828
#define UTEST_2_DLC (8U)
2929
#define UTEST_2_CANID (0x14d)
30+
31+
// Value tables for @ValTest signal
32+
33+
#ifndef ValTest_UTEST_2_Unsupported
34+
#define ValTest_UTEST_2_Unsupported (3)
35+
#endif
36+
37+
#ifndef ValTest_UTEST_2_Fail
38+
#define ValTest_UTEST_2_Fail (2)
39+
#endif
40+
41+
#ifndef ValTest_UTEST_2_OK
42+
#define ValTest_UTEST_2_OK (1)
43+
#endif
44+
45+
#ifndef ValTest_UTEST_2_Undefined
46+
#define ValTest_UTEST_2_Undefined (0)
47+
#endif
48+
3049
// signal: @U7_TEST_1_ro
3150
#define TESTDB_U7_TEST_1_ro_CovFactor (1)
3251
#define TESTDB_U7_TEST_1_ro_toS(x) ( (uint8_t) ((x) - (-255)) )
@@ -135,16 +154,77 @@ typedef struct
135154
#define UTEST_3_DLC (8U)
136155
#define UTEST_3_CANID (0x22b)
137156

157+
// Value tables for @TestValTableID signal
158+
159+
#ifndef TestValTableID_UTEST_3_Description_for_the_value_0x7
160+
#define TestValTableID_UTEST_3_Description_for_the_value_0x7 (-2)
161+
#endif
162+
163+
#ifndef TestValTableID_UTEST_3_Udef
164+
#define TestValTableID_UTEST_3_Udef (-1)
165+
#endif
166+
167+
#ifndef TestValTableID_UTEST_3_Udef
168+
#define TestValTableID_UTEST_3_Udef (6)
169+
#endif
170+
171+
#ifndef TestValTableID_UTEST_3_Udef
172+
#define TestValTableID_UTEST_3_Udef (5)
173+
#endif
174+
175+
#ifndef TestValTableID_UTEST_3_Udef
176+
#define TestValTableID_UTEST_3_Udef (4)
177+
#endif
178+
179+
#ifndef TestValTableID_UTEST_3_Error
180+
#define TestValTableID_UTEST_3_Error (3)
181+
#endif
182+
183+
#ifndef TestValTableID_UTEST_3_Ok
184+
#define TestValTableID_UTEST_3_Ok (2)
185+
#endif
186+
187+
#ifndef TestValTableID_UTEST_3_State_one
188+
#define TestValTableID_UTEST_3_State_one (1)
189+
#endif
190+
191+
#ifndef TestValTableID_UTEST_3_State_1
192+
#define TestValTableID_UTEST_3_State_1 (0)
193+
#endif
194+
195+
138196
typedef struct
139197
{
140198
#ifdef TESTDB_USE_BITS_SIGNAL
141199

142200
uint32_t U32_TEST_1; // Bits=32
143201

202+
// -2 : "Description for the value '0x7'"
203+
// -1 : "Udef"
204+
// 6 : "Udef"
205+
// 5 : "Udef"
206+
// 4 : "Udef"
207+
// 3 : "Error"
208+
// 2 : "Ok"
209+
// 1 : "State one"
210+
// 0 : "State 1"
211+
uint8_t TestValTableID : 3; // Bits= 3
212+
144213
#else
145214

146215
uint32_t U32_TEST_1; // Bits=32
147216

217+
// -2 : "Description for the value '0x7'"
218+
// -1 : "Udef"
219+
// 6 : "Udef"
220+
// 5 : "Udef"
221+
// 4 : "Udef"
222+
// 3 : "Error"
223+
// 2 : "Ok"
224+
// 1 : "State one"
225+
// 0 : "State 1"
226+
uint8_t TestValTableID; // Bits= 3
227+
148228
#endif // TESTDB_USE_BITS_SIGNAL
149229

150230
#ifdef TESTDB_USE_DIAG_MONITORS
@@ -160,6 +240,25 @@ typedef struct
160240
#define FLT_TEST_1_DLC (8U)
161241
#define FLT_TEST_1_CANID (0x360)
162242
#define FLT_TEST_1_CYC (101U)
243+
244+
// Value tables for @ValTable signal
245+
246+
#ifndef ValTable_FLT_TEST_1_Unsupported
247+
#define ValTable_FLT_TEST_1_Unsupported (3)
248+
#endif
249+
250+
#ifndef ValTable_FLT_TEST_1_Fail
251+
#define ValTable_FLT_TEST_1_Fail (2)
252+
#endif
253+
254+
#ifndef ValTable_FLT_TEST_1_OK
255+
#define ValTable_FLT_TEST_1_OK (1)
256+
#endif
257+
258+
#ifndef ValTable_FLT_TEST_1_Undefined
259+
#define ValTable_FLT_TEST_1_Undefined (0)
260+
#endif
261+
163262
// signal: @INT_TEST_2_ro
164263
#define TESTDB_INT_TEST_2_ro_CovFactor (5)
165264
#define TESTDB_INT_TEST_2_ro_toS(x) ( (int8_t) ((x) / (5)) )
@@ -423,6 +522,25 @@ typedef struct
423522
#define EMPTY_EXT_ID_DLC (8U)
424523
#define EMPTY_EXT_ID_CANID (0x1ffffff6)
425524

525+
// Value tables for @ValTest signal
526+
527+
#ifndef ValTest_EMPTY_EXT_ID_Unsupported
528+
#define ValTest_EMPTY_EXT_ID_Unsupported (3)
529+
#endif
530+
531+
#ifndef ValTest_EMPTY_EXT_ID_Fail
532+
#define ValTest_EMPTY_EXT_ID_Fail (2)
533+
#endif
534+
535+
#ifndef ValTest_EMPTY_EXT_ID_OK
536+
#define ValTest_EMPTY_EXT_ID_OK (1)
537+
#endif
538+
539+
#ifndef ValTest_EMPTY_EXT_ID_Undefined
540+
#define ValTest_EMPTY_EXT_ID_Undefined (0)
541+
#endif
542+
543+
426544
typedef struct
427545
{
428546
#ifdef TESTDB_USE_BITS_SIGNAL

test/testdb.dbc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ NS_ :
3434
BS_:
3535

3636
BU_: EPS ESP BMS BCM
37+
VAL_TABLE_ VtTestSig -2 "Description for the value '0x7'" -1 "Udef" 6 "Udef" 5 "Udef" 4 "Udef" 3 "Error" 2 "Ok" 1 "State one" 0 "State 1" ;
3738

3839

3940
BO_ 1911 SIG_TEST_1: 8 EPS
@@ -48,6 +49,7 @@ BO_ 2684354550 EMPTY_EXT_ID: 8 BCM
4849
SG_ ValTest : 7|2@0+ (1,0) [0|0] "c" BCM,ESP,BMS
4950

5051
BO_ 555 UTEST_3: 8 BCM
52+
SG_ TestValTableID : 32|3@1+ (1,0) [0|7] "" BMS
5153
SG_ U32_TEST_1 : 0|32@1+ (1,0) [0|4294967295] "" BMS
5254

5355
BO_ 333 UTEST_2: 8 BCM
@@ -133,6 +135,7 @@ BA_ "GenSigStartValue" SG_ 864 FLT4_TEST_1 0;
133135
BA_ "GenSigStartValue" SG_ 864 FLT4_TEST_3 5.05;
134136
BA_ "GenSigStartValue" SG_ 864 Accel 1000;
135137
VAL_ 2684354550 ValTest 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ;
138+
VAL_ 555 TestValTableID -2 "Description for the value '0x7'" -1 "Udef" 6 "Udef" 5 "Udef" 4 "Udef" 3 "Error" 2 "Ok" 1 "State one" 0 "State 1" ;
136139
VAL_ 333 ValTest 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ;
137140
VAL_ 864 ValTable 3 "Unsupported" 2 "Fail" 1 "OK" 0 "Undefined" ;
138141

0 commit comments

Comments
 (0)