11 const uint16_t MAX_ISO_TP_MESSAGE_SIZE;
12 const uint16_t MAX_CAN_FRAME_SIZE;
13 const uint8_t ISO_TP_DEFAULT_RESPONSE_TIMEOUT;
14 const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
17 const uint16_t arbitration_id;
18 const uint8_t* payload;
22 typedef void (*LogShim)(const char* message);
23 typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id,
24 const uint8_t* data, const uint8_t size);
25 typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
27 typedef void (*IsoTpMessageReceivedHandler)(const IsoTpMessage* message);
28 typedef void (*IsoTpMessageSentHandler)(const IsoTpMessage* message,
30 typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message);
34 SendCanMessageShim send_can_message;
35 SetTimerShim set_timer;
40 uint16_t arbitration_id;
41 IsoTpMessageReceivedHandler message_received_callback;
42 IsoTpMessageSentHandler message_sent_callback;
43 IsoTpCanFrameSentHandler can_frame_sent_callback;
48 uint8_t* receive_buffer;
49 uint16_t received_buffer_size;
50 uint16_t incoming_message_size;
52 // TODO timer callback
57 PCI_FIRST_FRAME = 0x1,
58 PCI_CONSECUTIVE_FRAME = 0x2,
59 PCI_FLOW_CONTROL_FRAME = 0x3
60 } IsoTpProtocolControlInformation;
63 PCI_FLOW_STATUS_CONTINUE = 0x0,
64 PCI_FLOW_STATUS_WAIT = 0x1,
65 PCI_FLOW_STATUS_OVERFLOW = 0x2
68 IsoTpShims isotp_init_shims(LogShim log,
69 SendCanMessageShim send_can_message,
70 SetTimerShim set_timer);
72 IsoTpHandler isotp_init(IsoTpShims* shims,
73 uint16_t arbitration_id,
74 IsoTpMessageReceivedHandler message_received_callback,
75 IsoTpMessageSentHandler message_sent_callback,
76 IsoTpCanFrameSentHandler can_frame_sent_callback);
78 /* Public: Change the timeout for waiting on an ISO-TP response frame.
80 * If this function is not used, the conventional 100ms is used by default.
82 * handler - the ISO-TP handler to modify.
83 * timeout - the new timeout in milliseconds.
85 void isotp_set_timeout(IsoTpHandler* handler, uint16_t timeout_ms);
87 void isotp_destroy(IsoTpHandler* handler);
89 void log_isotp_message(const IsoTpMessage* message);