5 #define VAG_DEBUG(...) do { fprintf(stdout, __VA_ARGS__); } while(0)
10 typedef unsigned char BAP_OpCode;
11 typedef unsigned char BAP_Node;
12 typedef unsigned char BAP_Port;
13 typedef unsigned short BAP_FrameLen;
16 /* A BAP frame at the BCL (BAP communication layer) as defined in
17 * http://www.itwissen.info/BCL-BAP-communication-layer.html
19 * This is basically BAP's equivalent of IP and TCP.
22 /* True if frame was/will be transmitted in multi-frame syntax */
26 /* Request/reply, kind of */
29 /* LSG = Logisches Steuergeraet
30 * https://www.springerprofessional.de/technische-informatik/eingebettete-systeme/neues-protokoll-vereinfacht-kommunikation-von-steuergeraeten/6592480
32 * BAP's equivalent of an IP address (to be confirmed).
34 * Always the same per CAN ID in the (simple) devices I looked at.
38 /* The "RPC" port, or "status register" ID.
40 * BAP's equivalent of a "UDP port".
44 /* Payload length, up to 2^12-1 = 4095 bytes. */
55 /* Temporary storage for incomplete frames */
56 struct BAP_Frame *mfchannel[8];
58 /* How many bytes have we already received on each channel? */
59 BAP_FrameLen len_done[8];
64 /* Temporary storage for frames not yet fully sent */
65 struct BAP_Frame *slot[4];
67 /* How many bytes have we already sent on each open slot? */
68 BAP_FrameLen slot_done[4];
73 /* BAP frame struct handling */
74 struct BAP_Frame* vag_bap_frame_alloc(void);
75 void vag_bap_frame_free(struct BAP_Frame *bap_frame);
77 int vag_bap_frame_is_valid(struct BAP_Frame *bap_frame);
79 struct BAP_Frame* vag_bap_frame_clone(struct BAP_Frame *bap_frame);
81 void vag_bap_frame_dump(struct BAP_Frame *bap_frame);
85 struct BAP_Frame* vag_bap_handle_can_frame(struct BAP_RXer *bap, struct can_frame *frame);
86 struct BAP_RXer* vag_bap_rxer_alloc();
87 void vag_bap_rxer_free(struct BAP_RXer *bap);
90 /* BAP transmission */
91 int vag_bap_txer_queue(struct BAP_TXer* bap, struct BAP_Frame *bap_frame, struct can_frame *frame);
92 struct BAP_TXer* vag_bap_txer_alloc();
93 void vag_bap_txer_free(struct BAP_TXer *bap);