ISOTP-C
A platform-agnostic ISOTP implementation in C.
isotp_config.h
Go to the documentation of this file.
1#ifndef __ISOTP_CONFIG__
2#define __ISOTP_CONFIG__
3
4/* Max number of messages the receiver can receive at one time, this value
5 * is affected by can driver queue length
6 */
7#define ISO_TP_DEFAULT_BLOCK_SIZE 8
8
9/* The STmin parameter value specifies the minimum time gap allowed between
10 * the transmission of consecutive frame network protocol data units
11 */
12#define ISO_TP_DEFAULT_ST_MIN_US 0
13
14/* This parameter indicate how many FC N_PDU WTs can be transmitted by the
15 * receiver in a row.
16 */
17#define ISO_TP_MAX_WFT_NUMBER 1
18
19/* Private: The default timeout to use when waiting for a response during a
20 * multi-frame send or receive.
21 */
22#define ISO_TP_DEFAULT_RESPONSE_TIMEOUT_US 100000
23
24/* Private: Determines if by default, padding is added to ISO-TP message frames.
25 */
26//#define ISO_TP_FRAME_PADDING
27
28/* Private: Value to use when padding frames if enabled by ISO_TP_FRAME_PADDING
29 */
30#ifndef ISO_TP_FRAME_PADDING_VALUE
31#define ISO_TP_FRAME_PADDING_VALUE 0xAA
32#endif
33
34#endif
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 ...
Definition: isotp.c:281
static int isotp_send_single_frame(IsoTpLink *link, uint32_t id)
Definition: isotp.c:53
static int isotp_send_consecutive_frame(IsoTpLink *link)
Definition: isotp.c:103
static int isotp_receive_first_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
Definition: isotp.c:154
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.
Definition: isotp.c:430
static int isotp_receive_consecutive_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
Definition: isotp.c:186
static int isotp_receive_flow_control_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
Definition: isotp.c:215
static int isotp_send_flow_control(IsoTpLink *link, uint8_t flow_status, uint8_t block_size, uint32_t st_min_us)
Definition: isotp.c:29
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.
Definition: isotp.c:450
void isotp_poll(IsoTpLink *link)
Polling function; call this function periodically to handle timeouts, send consecutive frames,...
Definition: isotp.c:463
static uint8_t isotp_us_to_st_min(uint32_t us)
STATIC FUNCTIONS ///.
Definition: isotp.c:10
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.
Definition: isotp.c:233
static uint32_t isotp_st_min_to_us(uint8_t st_min)
Definition: isotp.c:20
static int isotp_send_first_frame(IsoTpLink *link, uint32_t id)
Definition: isotp.c:79
int isotp_send(IsoTpLink *link, const uint8_t payload[], uint16_t size)
PUBLIC FUNCTIONS ///.
Definition: isotp.c:229
static int isotp_receive_single_frame(IsoTpLink *link, IsoTpCanMessage *message, uint8_t len)
Definition: isotp.c:140
#define ISO_TP_MAX_WFT_NUMBER
Definition: isotp_config.h:17
#define ISO_TP_DEFAULT_ST_MIN_US
Definition: isotp_config.h:12
#define ISO_TP_DEFAULT_RESPONSE_TIMEOUT_US
Definition: isotp_config.h:22
#define ISO_TP_DEFAULT_BLOCK_SIZE
Definition: isotp_config.h:7
@ ISOTP_RECEIVE_STATUS_FULL
Definition: isotp_defines.h:64
@ ISOTP_RECEIVE_STATUS_IDLE
Definition: isotp_defines.h:62
@ ISOTP_RECEIVE_STATUS_INPROGRESS
Definition: isotp_defines.h:63
#define ISOTP_RET_NOSPACE
Definition: isotp_defines.h:45
#define ISOTP_PROTOCOL_RESULT_BUFFER_OVFLW
#define ISOTP_PROTOCOL_RESULT_UNEXP_PDU
#define ISOTP_INVALID_BS
Definition: isotp_defines.h:51
#define ISOTP_RET_NO_DATA
Definition: isotp_defines.h:42
#define ISOTP_PROTOCOL_RESULT_OK
#define ISOTP_RET_OVERFLOW
Definition: isotp_defines.h:40
#define ISOTP_PROTOCOL_RESULT_TIMEOUT_CR
@ ISOTP_SEND_STATUS_ERROR
Definition: isotp_defines.h:57
@ ISOTP_SEND_STATUS_IDLE
Definition: isotp_defines.h:55
@ ISOTP_SEND_STATUS_INPROGRESS
Definition: isotp_defines.h:56
#define ISOTP_PROTOCOL_RESULT_TIMEOUT_BS
#define ISOTP_RET_WRONG_SN
Definition: isotp_defines.h:41
#define ISOTP_PROTOCOL_RESULT_WFT_OVRN
#define ISOTP_RET_LENGTH
Definition: isotp_defines.h:44
#define ISOTP_RET_INPROGRESS
Definition: isotp_defines.h:39
@ PCI_FLOW_STATUS_OVERFLOW
@ PCI_FLOW_STATUS_WAIT
@ PCI_FLOW_STATUS_CONTINUE
#define ISOTP_RET_ERROR
Definition: isotp_defines.h:38
#define ISOTP_RET_OK
Definition: isotp_defines.h:37
@ TSOTP_PCI_TYPE_CONSECUTIVE_FRAME
@ ISOTP_PCI_TYPE_SINGLE
@ ISOTP_PCI_TYPE_FIRST_FRAME
@ ISOTP_PCI_TYPE_FLOW_CONTROL_FRAME
#define IsoTpTimeAfter(a, b)
Definition: isotp_defines.h:48
#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
IsoTpPciType common
IsoTpConsecutiveFrame consecutive_frame
IsoTpSingleFrame single_frame
IsoTpFlowControl flow_control
uint8_t ptr[8]