Skip to content

Commit 323d2a8

Browse files
committed
Added test DBC CAN matrix and generation scripts.
1 parent 45209db commit 323d2a8

18 files changed

+1692
-0
lines changed

run-test-gen.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
start "coder" "build/Release/coderdbc.exe" -dbc test\testdb.dbc -out -out test\gencode -drvname testdb -nodeutils -rw
2+
pause

run-test-gen.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./build/coderdbc -dbc test/testdb.dbc -out test/gencode -drvname testdb -nodeutils -rw

test/gencode/butl/BCM_testdb.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "BCM_testdb.h"
2+
3+
#ifdef __DEF_TESTDB__
4+
5+
testdb_rx_t testdb_rx;
6+
7+
testdb_tx_t testdb_tx;
8+
9+
#endif // __DEF_TESTDB__
10+
11+
uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_)
12+
{
13+
uint32_t recid = 0;
14+
if (_id == 0x360U) {
15+
recid = Unpack_FLT_TEST_1_testdb(&(_m->FLT_TEST_1), _d, dlc_);
16+
} else {
17+
if (_id == 0x777U) {
18+
recid = Unpack_SIG_TEST_1_testdb(&(_m->SIG_TEST_1), _d, dlc_);
19+
} else if (_id == 0x1FFFFFF6U) {
20+
recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_);
21+
}
22+
}
23+
24+
return recid;
25+
}
26+

test/gencode/butl/BCM_testdb.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#include "dbccodeconf.h"
8+
9+
#include "testdb.h"
10+
11+
// This version definition comes from main driver version and
12+
// can be compared in user code space for strict compatibility test
13+
#define VER_TESTDB_MAJ (1U)
14+
#define VER_TESTDB_MIN (10U)
15+
16+
typedef struct
17+
{
18+
FLT_TEST_1_t FLT_TEST_1;
19+
SIG_TEST_1_t SIG_TEST_1;
20+
EMPTY_EXT_ID_t EMPTY_EXT_ID;
21+
} testdb_rx_t;
22+
23+
typedef struct
24+
{
25+
UTEST_2_t UTEST_2;
26+
EMPTY_0_t EMPTY_0;
27+
UTEST_3_t UTEST_3;
28+
EMPTY_EXT_ID_t EMPTY_EXT_ID;
29+
} testdb_tx_t;
30+
31+
uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc);
32+
33+
#ifdef __DEF_TESTDB__
34+
35+
extern testdb_rx_t testdb_rx;
36+
37+
extern testdb_tx_t testdb_tx;
38+
39+
#endif // __DEF_TESTDB__
40+
41+
#ifdef __cplusplus
42+
}
43+
#endif

test/gencode/butl/BMS_testdb.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "BMS_testdb.h"
2+
3+
#ifdef __DEF_TESTDB__
4+
5+
testdb_rx_t testdb_rx;
6+
7+
testdb_tx_t testdb_tx;
8+
9+
#endif // __DEF_TESTDB__
10+
11+
uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_)
12+
{
13+
uint32_t recid = 0;
14+
if ((_id >= 0x14DU) && (_id < 0x22BU)) {
15+
if (_id == 0x14DU) {
16+
recid = Unpack_UTEST_2_testdb(&(_m->UTEST_2), _d, dlc_);
17+
} else if (_id == 0x160U) {
18+
recid = Unpack_EMPTY_0_testdb(&(_m->EMPTY_0), _d, dlc_);
19+
}
20+
} else {
21+
if (_id == 0x22BU) {
22+
recid = Unpack_UTEST_3_testdb(&(_m->UTEST_3), _d, dlc_);
23+
} else if (_id == 0x1FFFFFF6U) {
24+
recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_);
25+
}
26+
}
27+
28+
return recid;
29+
}
30+

test/gencode/butl/BMS_testdb.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#include "dbccodeconf.h"
8+
9+
#include "testdb.h"
10+
11+
// This version definition comes from main driver version and
12+
// can be compared in user code space for strict compatibility test
13+
#define VER_TESTDB_MAJ (1U)
14+
#define VER_TESTDB_MIN (10U)
15+
16+
typedef struct
17+
{
18+
UTEST_2_t UTEST_2;
19+
EMPTY_0_t EMPTY_0;
20+
UTEST_3_t UTEST_3;
21+
EMPTY_EXT_ID_t EMPTY_EXT_ID;
22+
} testdb_rx_t;
23+
24+
typedef struct
25+
{
26+
EMPTY_0_t EMPTY_0;
27+
FLT_TEST_1_t FLT_TEST_1;
28+
} testdb_tx_t;
29+
30+
uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc);
31+
32+
#ifdef __DEF_TESTDB__
33+
34+
extern testdb_rx_t testdb_rx;
35+
36+
extern testdb_tx_t testdb_tx;
37+
38+
#endif // __DEF_TESTDB__
39+
40+
#ifdef __cplusplus
41+
}
42+
#endif

test/gencode/butl/EPS_testdb.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "EPS_testdb.h"
2+
3+
#ifdef __DEF_TESTDB__
4+
5+
testdb_tx_t testdb_tx;
6+
7+
#endif // __DEF_TESTDB__
8+

test/gencode/butl/EPS_testdb.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#include "dbccodeconf.h"
8+
9+
#include "testdb.h"
10+
11+
// This version definition comes from main driver version and
12+
// can be compared in user code space for strict compatibility test
13+
#define VER_TESTDB_MAJ (1U)
14+
#define VER_TESTDB_MIN (10U)
15+
16+
// There is no any RX mapped massage.
17+
18+
typedef struct
19+
{
20+
SIG_TEST_1_t SIG_TEST_1;
21+
} testdb_tx_t;
22+
23+
#ifdef __DEF_TESTDB__
24+
25+
extern testdb_tx_t testdb_tx;
26+
27+
#endif // __DEF_TESTDB__
28+
29+
#ifdef __cplusplus
30+
}
31+
#endif

test/gencode/butl/ESP_testdb.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "ESP_testdb.h"
2+
3+
#ifdef __DEF_TESTDB__
4+
5+
testdb_rx_t testdb_rx;
6+
7+
testdb_tx_t testdb_tx;
8+
9+
#endif // __DEF_TESTDB__
10+
11+
uint32_t testdb_Receive(testdb_rx_t* _m, const uint8_t* _d, uint32_t _id, uint8_t dlc_)
12+
{
13+
uint32_t recid = 0;
14+
if (_id == 0x14DU) {
15+
recid = Unpack_UTEST_2_testdb(&(_m->UTEST_2), _d, dlc_);
16+
} else if (_id == 0x1FFFFFF6U) {
17+
recid = Unpack_EMPTY_EXT_ID_testdb(&(_m->EMPTY_EXT_ID), _d, dlc_);
18+
}
19+
20+
return recid;
21+
}
22+

test/gencode/butl/ESP_testdb.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#pragma once
2+
3+
#ifdef __cplusplus
4+
extern "C" {
5+
#endif
6+
7+
#include "dbccodeconf.h"
8+
9+
#include "testdb.h"
10+
11+
// This version definition comes from main driver version and
12+
// can be compared in user code space for strict compatibility test
13+
#define VER_TESTDB_MAJ (1U)
14+
#define VER_TESTDB_MIN (10U)
15+
16+
typedef struct
17+
{
18+
UTEST_2_t UTEST_2;
19+
EMPTY_EXT_ID_t EMPTY_EXT_ID;
20+
} testdb_rx_t;
21+
22+
typedef struct
23+
{
24+
EMPTY_0_t EMPTY_0;
25+
} testdb_tx_t;
26+
27+
uint32_t testdb_Receive(testdb_rx_t* m, const uint8_t* d, uint32_t msgid, uint8_t dlc);
28+
29+
#ifdef __DEF_TESTDB__
30+
31+
extern testdb_rx_t testdb_rx;
32+
33+
extern testdb_tx_t testdb_tx;
34+
35+
#endif // __DEF_TESTDB__
36+
37+
#ifdef __cplusplus
38+
}
39+
#endif

test/gencode/conf/dbccodeconf.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
5+
// when USE_SIGFLOAT enabed the sigfloat_t must be defined
6+
// typedef double sigfloat_t;
7+
8+
// when USE_CANSTRUCT enabled __CoderDbcCanFrame_t__ must be defined
9+
// #include "{header_with_can_struct}"
10+
// typedef {can_struct} __CoderDbcCanFrame_t__;
11+
12+
// if you need to allocate rx and tx messages structs put the allocation macro here
13+
// #define __DEF_{your_driver_name}__
14+

test/gencode/conf/testdb-config.h

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#pragma once
2+
3+
/* include common dbccode configurations */
4+
#include "dbccodeconf.h"
5+
6+
7+
/* ------------------------------------------------------------------------- *
8+
This define enables using CAN message structs with bit-fielded signals
9+
layout.
10+
11+
Note(!): bit-feild was not tested properly. */
12+
13+
/* #define TESTDB_USE_BITS_SIGNAL */
14+
15+
16+
/* ------------------------------------------------------------------------- *
17+
This macro enables using CAN message descriptive struct packing functions
18+
(by default signature of pack function intakes a few simple typed params
19+
for loading data, len, etc). To compile you need to define the struct
20+
__CoderDbcCanFrame_t__ which must have fields:
21+
22+
u32 MsgId (CAN Frame message ID)
23+
u8 DLC (CAN Frame payload length field)
24+
u8 Data[8] (CAN Frame payload data)
25+
u8 IDE (CAN Frame Extended (1) / Standard (0) ID type)
26+
27+
This struct definition have to be placed (or be included) in dbccodeconf.h */
28+
29+
/* #define TESTDB_USE_CANSTRUCT */
30+
31+
32+
/* ------------------------------------------------------------------------- *
33+
All the signals which have values of factor != 1 or offset != 0
34+
will be named in message struct with posfix '_ro'. Pack to payload
35+
operations will be made on this signal value as well as unpack from payload.
36+
37+
USE_SIGFLOAT macro makes some difference:
38+
39+
1. All the '_ro' fields will have a pair field with '_phys' postfix.
40+
If only offset != 0 is true then the type of '_phys' signal is the same
41+
as '_ro' signal. In other case the type will be @sigfloat_t which
42+
have to be defined in user dbccodeconf.h
43+
44+
2. In pack function '_ro' signal will be rewritten by '_phys' signal, which
45+
requires from user to use ONLY '_phys' signal for packing frame
46+
47+
3. In unpack function '_phys' signal will be written by '_ro' signal.
48+
User have to use '_phys' signal to read physical value. */
49+
50+
/* #define TESTDB_USE_SIGFLOAT */
51+
52+
53+
/* ------------------------------------------------------------------------- *
54+
Note(!) that the "canmonitorutil.h" must be accessed in include path:
55+
56+
This macro adds:
57+
58+
- monitor field @mon1 to message struct
59+
60+
- capture system tick in unpack function and save value to mon1 field
61+
to provide to user better missing frame detection code. For this case
62+
user must provide function declared in canmonitorutil.h - GetSysTick()
63+
which may return 1ms uptime.
64+
65+
- calling function FMon_*** (from 'fmon' driver) inside unpack function
66+
which is empty by default and have to be filled by user if
67+
tests for DLC, rolling, checksum are necessary */
68+
69+
/* #define TESTDB_USE_DIAG_MONITORS */
70+
71+
72+
/* ------------------------------------------------------------------------- *
73+
When monitor using is enabled (TESTDB_USE_DIAG_MONITORS) and define below
74+
uncommented, additional signal will be added to message struct. ***_expt:
75+
expected rolling counter, to perform monitoring rolling counter sequence
76+
automatically (result may be tested in dedicated Fmon_*** function) */
77+
78+
/* #define TESTDB_AUTO_ROLL */
79+
80+
81+
/* ------------------------------------------------------------------------- *
82+
When monitor using is enabled (TESTDB_USE_DIAG_MONITORS) and define below
83+
uncommented, frame checksum signal may be handled automatically.
84+
85+
The signal which may be marked as checksum signal must have substring
86+
with next format:
87+
<Checksum:XOR8:3>
88+
89+
where:
90+
91+
- "Checksum": constant marker word
92+
93+
- "XOR8": type of method, this text will be passed to GetFrameHash
94+
(canmonitorutil.h) function as is, the best use case is to define 'enum
95+
DbcCanCrcMethods' in canmonitorutil.h file with all possible
96+
checksum algorithms (e.g. XOR8, XOR4 etc)
97+
98+
- "3": optional value that will be passed to GetFrameHash as integer value
99+
100+
Function GetFrameHash have to be implemented by user
101+
102+
In pack function checksum signal will be calculated automatically
103+
and loaded to payload
104+
105+
In unpack function checksum signal is checked with calculated.
106+
(result may be tested in dedicated Fmon_*** function). */
107+
108+
/* #define TESTDB_AUTO_CSM */
109+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy