1#ifndef __ISOTP_DEFINES_H__
2#define __ISOTP_DEFINES_H__
7
8
10#if __BYTE_ORDER__
== __ORDER_LITTLE_ENDIAN__
11#define ISOTP_BYTE_ORDER_LITTLE_ENDIAN
12#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
14#error "unsupported byte ordering"
19
20
22#define snprintf _snprintf
27#define ISOTP_BYTE_ORDER_LITTLE_ENDIAN
28#define __builtin_bswap8 _byteswap_uint8
29#define __builtin_bswap16 _byteswap_uint16
30#define __builtin_bswap32 _byteswap_uint32
31#define __builtin_bswap64 _byteswap_uint64
35
36
38#define ISOTP_RET_ERROR -1
39#define ISOTP_RET_INPROGRESS -2
40#define ISOTP_RET_OVERFLOW -3
41#define ISOTP_RET_WRONG_SN -4
42#define ISOTP_RET_NO_DATA -5
43#define ISOTP_RET_TIMEOUT -6
44#define ISOTP_RET_LENGTH -7
45#define ISOTP_RET_NOSPACE -8
48#define IsoTpTimeAfter(a,b) ((int32_t)((int32_t)(b) - (int32_t)(a)) < 0
)
51#define ISOTP_INVALID_BS 0xFFFF
58} IsoTpSendStatusTypes;
65} IsoTpReceiveStatusTypes;
68#if defined(ISOTP_BYTE_ORDER_LITTLE_ENDIAN
)
92} IsoTpConsecutiveFrame;
107 uint8_t reserve_2[7];
111
112
113
114
115
116
117
118
119
127
128
129
130
131
132
133
134
135
138 uint8_t FF_DL_high:4;
144
145
146
147
148
149
150
151
152
157} IsoTpConsecutiveFrame;
160
161
162
163
164
165
166
167
168
195
196
199
205} IsoTpProtocolControlInformation;
208
216
217#define ISOTP_PROTOCOL_RESULT_OK 0
218#define ISOTP_PROTOCOL_RESULT_TIMEOUT_A -1
219#define ISOTP_PROTOCOL_RESULT_TIMEOUT_BS -2
220#define ISOTP_PROTOCOL_RESULT_TIMEOUT_CR -3
221#define ISOTP_PROTOCOL_RESULT_WRONG_SN -4
222#define ISOTP_PROTOCOL_RESULT_INVALID_FS -5
223#define ISOTP_PROTOCOL_RESULT_UNEXP_PDU -6
224#define ISOTP_PROTOCOL_RESULT_WFT_OVRN -7
225#define ISOTP_PROTOCOL_RESULT_BUFFER_OVFLW -8
226#define ISOTP_PROTOCOL_RESULT_ERROR -9
void isotp_on_can_message(IsoTpLink *link, uint8_t *data, uint8_t len)
Handles incoming CAN messages. Determines whether an incoming message is a valid ISO-TP frame or not ...
static int isotp_send_single_frame(IsoTpLink *link, uint32_t id)
static int isotp_send_consecutive_frame(IsoTpLink *link)
static int isotp_receive_first_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
int isotp_receive(IsoTpLink *link, uint8_t *payload, const uint16_t payload_size, uint16_t *out_size)
Receives and parses the received data and copies the parsed data in to the internal buffer.
static int isotp_receive_consecutive_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
static int isotp_receive_flow_control_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
static int isotp_send_flow_control(IsoTpLink *link, uint8_t flow_status, uint8_t block_size, uint32_t st_min_us)
void isotp_init_link(IsoTpLink *link, uint32_t sendid, uint8_t *sendbuf, uint16_t sendbufsize, uint8_t *recvbuf, uint16_t recvbufsize)
Initialises the ISO-TP library.
void isotp_poll(IsoTpLink *link)
Polling function; call this function periodically to handle timeouts, send consecutive frames,...
static uint8_t isotp_us_to_st_min(uint32_t us)
STATIC FUNCTIONS ///.
int isotp_send_with_id(IsoTpLink *link, uint32_t id, const uint8_t payload[], uint16_t size)
See isotp_send, with the exception that this function is used only for functional addressing.
static uint32_t isotp_st_min_to_us(uint8_t st_min)
static int isotp_send_first_frame(IsoTpLink *link, uint32_t id)
int isotp_send(IsoTpLink *link, const uint8_t payload[], uint16_t size)
PUBLIC FUNCTIONS ///.
static int isotp_receive_single_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
#define ISO_TP_MAX_WFT_NUMBER
#define ISO_TP_DEFAULT_ST_MIN_US
#define ISO_TP_DEFAULT_RESPONSE_TIMEOUT_US
#define ISO_TP_DEFAULT_BLOCK_SIZE
@ ISOTP_RECEIVE_STATUS_FULL
@ ISOTP_RECEIVE_STATUS_IDLE
@ ISOTP_RECEIVE_STATUS_INPROGRESS
#define ISOTP_RET_NOSPACE
#define ISOTP_PROTOCOL_RESULT_BUFFER_OVFLW
#define ISOTP_PROTOCOL_RESULT_UNEXP_PDU
#define ISOTP_RET_NO_DATA
#define ISOTP_PROTOCOL_RESULT_OK
#define ISOTP_RET_OVERFLOW
#define ISOTP_PROTOCOL_RESULT_TIMEOUT_CR
@ ISOTP_SEND_STATUS_ERROR
@ ISOTP_SEND_STATUS_INPROGRESS
#define ISOTP_PROTOCOL_RESULT_TIMEOUT_BS
#define ISOTP_RET_WRONG_SN
#define ISOTP_PROTOCOL_RESULT_WFT_OVRN
#define ISOTP_RET_INPROGRESS
@ PCI_FLOW_STATUS_OVERFLOW
@ PCI_FLOW_STATUS_CONTINUE
@ TSOTP_PCI_TYPE_CONSECUTIVE_FRAME
@ ISOTP_PCI_TYPE_FIRST_FRAME
@ ISOTP_PCI_TYPE_FLOW_CONTROL_FRAME
#define IsoTpTimeAfter(a, b)
#define ISOTP_PROTOCOL_RESULT_WRONG_SN
void isotp_user_debug(const char *message,...)
user implemented, print debug message
int isotp_user_send_can(const uint32_t arbitration_id, const uint8_t *data, const uint8_t size)
user implemented, send can message. should return ISOTP_RET_OK when success.
uint32_t isotp_user_get_us(void)
user implemented, gets the amount of time passed since the last call in microseconds
IsoTpDataArray data_array
IsoTpFirstFrame first_frame
IsoTpConsecutiveFrame consecutive_frame
IsoTpSingleFrame single_frame
IsoTpFlowControl flow_control
Struct containing the data for linking an application to a CAN instance. The data stored in this stru...
uint32_t receive_timer_cr
uint32_t receive_arbitration_id
uint16_t receive_buf_size
int receive_protocol_result
uint32_t send_arbitration_id