]> git.enpas.org Git - revag-bap.git/blob - vw-bap.h
b7540ea070a816d55d60a3c56675257c139f7c79
[revag-bap.git] / vw-bap.h
1 #ifndef __VW_BAP_H__
2 #define __VW_BAP_H__
3
4 #include <linux/can.h>
5
6
7 typedef unsigned char BAP_OpCode;
8 typedef unsigned char BAP_Node;
9 typedef unsigned char BAP_Function;
10 typedef unsigned short BAP_FrameLen;
11
12
13 /* A BAP frame at the BCL (BAP communication layer) as defined in
14  * http://www.itwissen.info/BCL-BAP-communication-layer.html
15  *
16  * This is basically BAP's equivalent of IP and TCP.
17  */
18 struct BAP_Frame {
19         /* True if frame was/will be transmitted in multi-frame syntax */
20         int is_multiframe;
21
22
23         /* Request/reply, kind of */
24         BAP_OpCode opcode;
25
26         /* LSG = Logisches Steuergeraet
27          * https://www.springerprofessional.de/technische-informatik/eingebettete-systeme/neues-protokoll-vereinfacht-kommunikation-von-steuergeraeten/6592480
28          *
29          * BAP's equivalent of an IP address (to be confirmed).
30          *
31          * Always the same per CAN ID in the (simple) devices I looked at.
32          */
33         BAP_Node node;
34
35         /* The "RPC" function, or "status register" ID.
36          *
37          * BAP's equivalent of a "TCP port".
38          */
39         BAP_Function function;
40
41         /* Payload length, up to 2^12 = 4096 bytes.
42          *
43          * 4095 bytes according to:
44          * http://www.itwissen.info/BCL-BAP-communication-layer.html
45          */
46         BAP_FrameLen len;
47
48
49         /* Payload */
50         char data[4096];
51 };
52
53
54
55 struct BAP_RXer {
56         /* Temporary storage for incomplete frames */
57         struct BAP_Frame *mfchannel[8];
58
59         /* How many bytes have we already received on each channel? */
60         BAP_FrameLen len_done[8];
61 };
62
63
64
65
66
67 void vw_bap_frame_dump(struct BAP_Frame *bap_frame);
68
69 struct BAP_Frame* vw_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame *frame);
70
71 void vw_bap_frame_free(struct BAP_Frame *bap_frame);
72
73 struct BAP_RXer* vw_bap_rxer_alloc();
74 void vw_bap_rxer_free(struct BAP_RXer *bap);
75
76
77 #endif