forked from howerj/dbcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
can.h
85 lines (73 loc) · 2.47 KB
/
can.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
#ifndef CAN_H
#define CAN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "mpc.h"
typedef enum {
endianess_motorola_e = 0,
endianess_intel_e = 1,
} endianess_e;
typedef enum {
numeric_unsigned_e,
numeric_signed_e,
numeric_floating_e,
} numeric_e;
typedef struct {
char *name;
unsigned value;
} val_list_item_t;
typedef struct {
size_t val_list_item_count;
val_list_item_t **val_list_items;
unsigned id; /**< identifier, 11 or 29 bit */
char *name;
} val_list_t;
typedef struct {
size_t ecu_count; /**< ECU count */
char *units; /**< units used */
char **ecus; /**< ECUs sending/receiving */
char *name; /**< name of the signal */
double scaling; /**< scaling */
double offset; /**< offset */
double minimum; /**< minimum value */
double maximum; /**< maximum value */
unsigned bit_length; /**< bit length in message buffer */
unsigned start_bit; /**< starting bit position in message */
endianess_e endianess; /**< endianess of message */
bool is_signed; /**< if true, value is signed */
bool is_floating; /**< if true, value is a floating point number*/
unsigned sigval; /**< 1 == float, 2 == double. is_floating implies sigval == 1 || sigval == 2 */
bool is_multiplexor; /**< true if this is a multiplexor */
bool is_multiplexed; /**< true if this is a multiplexed signal */
unsigned switchval; /**< if is_multiplexed, this will contain the
value that decodes this signal for the multiplexor */
val_list_t *val_list;
char *comment;
} signal_t;
typedef struct {
char *name; /**< can message name */
char *ecu; /**< name of ECU @todo check this makes sense */
signal_t **sigs; /**< signals that can decode/encode this message*/
uint64_t data; /**< data, up to eight bytes, not used for generation */
size_t signal_count; /**< number of signals */
unsigned dlc; /**< length of CAN message 0-8 bytes */
unsigned long id; /**< identifier, 11 or 29 bit */
char *comment;
} can_msg_t;
typedef struct {
bool use_float; /**< true if floating point conversion routines are needed */
size_t message_count; /**< count of messages */
can_msg_t **messages; /**< list of messages */
size_t val_count; /**< count of vals */
val_list_t **vals; /**< value list; used for enumerations in DBC file */
} dbc_t;
dbc_t *ast2dbc(mpc_ast_t *ast);
void dbc_delete(dbc_t *dbc);
#ifdef __cplusplus
}
#endif
#endif