1 /* max. number of CAN interfaces given on the cmdline */
4 /* buffer sizes for CAN frame string representations */
5 #define CL_ID (sizeof("12345678##1"))
6 #define CL_DATA sizeof(".AA")
7 #define CL_BINDATA sizeof(".10101010")
9 /* CAN FD ASCII hex short representation with DATA_SEPERATORs */
10 #define CL_CFSZ (2*CL_ID + 64*CL_DATA)
12 #define CANID_DELIM '#'
15 * Interface between the daemon and the binding
17 static const struct afb_binding_interface *interface;
20 * the type of position expected
22 * here, this type is the selection of protocol
27 type_DEFAULT = type_CAN,
31 #define type_size sizeof(enum type)-2
36 static const char * const type_NAMES[type_size] = {
41 /* CAN variable initialization */
42 struct canfd_frame canfd_frame;
48 struct sockaddr_can txAddress;
52 * each generated event
54 typedef struct _event event;
56 event *next; /* link for the next event */
57 const char *name; /* name of the event */
58 struct afb_event afb_event; /* the event for the binder */
59 openxc_CanMessage can_message; /* value for the can_message */
63 * each can event, will browse by the id
65 typedef struct _can_event can_event;
67 can_event *next; /* Link to the next other can message */
68 event *events; /* events for the can message */
69 uint32_t id; /* id of the event for unsubscribe */
70 enum type type; /* the type of data expected */
73 can_event *can_events_list;
75 /* TODO : Add help comments :p */
76 static int connect_to_event_loop();
78 const char hex_asc_upper[] = "0123456789ABCDEF";
80 #define hex_asc_upper_lo(x) hex_asc_upper[((x) & 0x0F)]
81 #define hex_asc_upper_hi(x) hex_asc_upper[((x) & 0xF0) >> 4]
83 static inline void put_hex_byte(char *buf, __u8 byte)
85 buf[0] = hex_asc_upper_hi(byte);
86 buf[1] = hex_asc_upper_lo(byte);
89 static inline void _put_id(char *buf, int end_offset, canid_t id)
91 /* build 3 (SFF) or 8 (EFF) digit CAN identifier */
92 while (end_offset >= 0) {
93 buf[end_offset--] = hex_asc_upper[id & 0xF];
98 #define put_sff_id(buf, id) _put_id(buf, 2, id)
99 #define put_eff_id(buf, id) _put_id(buf, 7, id)
101 static void parse_can_frame(openxc_CanMessage *can_message, struct canfd_frame *canfd_frame, int maxdlen);
104 // Initialize default can_handler values
105 static struct can_handler can_handler = {
108 .is_fdmode_on = false,
111 static void send_event();