1 #ifndef __ISOTP_TYPES__
2 #define __ISOTP_TYPES__
8 #define CAN_MESSAGE_BYTE_SIZE 8
9 #define MAX_ISO_TP_MESSAGE_SIZE 4096
10 // TODO we want to avoid malloc, and we can't be allocated 4K on the stack for
11 // each IsoTpMessage, so for now we're setting an artificial max message size
12 // here - since we only handle single frame messages, 8 bytes is plenty.
13 #define OUR_MAX_ISO_TP_MESSAGE_SIZE 8
19 const uint8_t ISO_TP_DEFAULT_RESPONSE_TIMEOUT;
20 const bool ISO_TP_DEFAULT_FRAME_PADDING_STATUS;
23 const uint16_t arbitration_id;
24 uint8_t payload[OUR_MAX_ISO_TP_MESSAGE_SIZE];
29 typedef void (*LogShim)(const char* message, ...);
30 typedef bool (*SendCanMessageShim)(const uint16_t arbitration_id,
31 const uint8_t* data, const uint8_t size);
32 typedef bool (*SetTimerShim)(uint16_t time_ms, void (*callback));
34 typedef void (*IsoTpMessageReceivedHandler)(const IsoTpMessage* message);
35 typedef void (*IsoTpMessageSentHandler)(const IsoTpMessage* message,
37 typedef void (*IsoTpCanFrameSentHandler)(const IsoTpMessage* message);
41 SendCanMessageShim send_can_message;
42 SetTimerShim set_timer;
48 uint16_t arbitration_id;
49 IsoTpMessageReceivedHandler message_received_callback;
53 // timeout_ms: ISO_TP_DEFAULT_RESPONSE_TIMEOUT,
55 // frame_padding: ISO_TP_DEFAULT_FRAME_PADDING_STATUS,
56 uint8_t* receive_buffer;
57 uint16_t received_buffer_size;
58 uint16_t incoming_message_size;
59 // TODO timer callback for multi frame
64 PCI_FIRST_FRAME = 0x1,
65 PCI_CONSECUTIVE_FRAME = 0x2,
66 PCI_FLOW_CONTROL_FRAME = 0x3
67 } IsoTpProtocolControlInformation;
70 PCI_FLOW_STATUS_CONTINUE = 0x0,
71 PCI_FLOW_STATUS_WAIT = 0x1,
72 PCI_FLOW_STATUS_OVERFLOW = 0x2
79 #endif // __ISOTP_TYPES__