7 #define CAN_MESSAGE_BYTE_SIZE 8
13 const uint16_t MAX_ISO_TP_MESSAGE_SIZE;
14 const uint16_t MAX_CAN_FRAME_SIZE;
15 const uint8_t ISO_TP_DEFAULT_RESPONSE_TIMEOUT;
16 const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
19 const uint16_t arbitration_id;
20 const uint8_t* payload;
24 typedef void (*LogShim)(const char* message);
25 typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id,
26 const uint8_t* data, const uint8_t size);
27 typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
29 typedef void (*IsoTpMessageReceivedHandler)(const IsoTpMessage* message);
30 typedef void (*IsoTpMessageSentHandler)(const IsoTpMessage* message,
32 typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message);
36 SendCanMessageShim send_can_message;
37 SetTimerShim set_timer;
42 uint16_t arbitration_id;
43 IsoTpMessageReceivedHandler message_received_callback;
44 IsoTpMessageSentHandler message_sent_callback;
45 IsoTpCanFrameSentHandler can_frame_sent_callback;
50 uint8_t* receive_buffer;
51 uint16_t received_buffer_size;
52 uint16_t incoming_message_size;
54 // TODO timer callback
59 PCI_FIRST_FRAME = 0x1,
60 PCI_CONSECUTIVE_FRAME = 0x2,
61 PCI_FLOW_CONTROL_FRAME = 0x3
62 } IsoTpProtocolControlInformation;
65 PCI_FLOW_STATUS_CONTINUE = 0x0,
66 PCI_FLOW_STATUS_WAIT = 0x1,
67 PCI_FLOW_STATUS_OVERFLOW = 0x2
70 IsoTpShims isotp_init_shims(LogShim log,
71 SendCanMessageShim send_can_message,
72 SetTimerShim set_timer);
74 IsoTpHandler isotp_init(IsoTpShims* shims,
75 uint16_t arbitration_id,
76 IsoTpMessageReceivedHandler message_received_callback,
77 IsoTpMessageSentHandler message_sent_callback,
78 IsoTpCanFrameSentHandler can_frame_sent_callback);
80 /* Public: Change the timeout for waiting on an ISO-TP response frame.
82 * If this function is not used, the conventional 100ms is used by default.
84 * handler - the ISO-TP handler to modify.
85 * timeout - the new timeout in milliseconds.
87 void isotp_set_timeout(IsoTpHandler* handler, uint16_t timeout_ms);
89 void isotp_destroy(IsoTpHandler* handler);
91 void log_isotp_message(const IsoTpMessage* message);