ISOTP-C
A platform-agnostic ISOTP implementation in C.
|
Go to the source code of this file.
Functions | |
static uint8_t | isotp_us_to_st_min (uint32_t us) |
STATIC FUNCTIONS ///. More... | |
static uint32_t | isotp_st_min_to_us (uint8_t st_min) |
static int | isotp_send_flow_control (IsoTpLink *link, uint8_t flow_status, uint8_t block_size, uint32_t st_min_us) |
static int | isotp_send_single_frame (IsoTpLink *link, uint32_t id) |
static int | isotp_send_first_frame (IsoTpLink *link, uint32_t id) |
static int | isotp_send_consecutive_frame (IsoTpLink *link) |
static int | isotp_receive_single_frame (IsoTpLink *link, IsoTpCanMessage *message, uint8_t len) |
static int | isotp_receive_first_frame (IsoTpLink *link, IsoTpCanMessage *message, uint8_t len) |
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) |
int | isotp_send (IsoTpLink *link, const uint8_t payload[], uint16_t size) |
PUBLIC FUNCTIONS ///. More... | |
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. More... | |
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 and handles it accordingly. More... | |
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. More... | |
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. More... | |
void | isotp_poll (IsoTpLink *link) |
Polling function; call this function periodically to handle timeouts, send consecutive frames, etc. More... | |
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.
link | The Struct containing the data for linking an application to a CAN instance. The data stored in this stru... Definition: isotp.h:22 |
sendid | The ID used to send data to other CAN nodes. |
sendbuf | A pointer to an area in memory which can be used as a buffer for data to be sent. |
sendbufsize | The size of the buffer area. |
recvbuf | A pointer to an area in memory which can be used as a buffer for data to be received. |
recvbufsize | The size of the buffer area. |
Definition at line 450 of file isotp.c.
References ISOTP_RECEIVE_STATUS_IDLE, ISOTP_SEND_STATUS_IDLE, IsoTpLink::receive_buf_size, IsoTpLink::receive_buffer, IsoTpLink::receive_status, IsoTpLink::send_arbitration_id, IsoTpLink::send_buf_size, IsoTpLink::send_buffer, and IsoTpLink::send_status.
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 and handles it accordingly.
link | The instance used for transceiving data. |
data | The data received via CAN. |
len | The length of the data received. |
Definition at line 281 of file isotp.c.
References IsoTpCanMessage::common, IsoTpCanMessage::data_array, IsoTpCanMessage::flow_control, ISOTP_PCI_TYPE_FIRST_FRAME, ISOTP_PCI_TYPE_FLOW_CONTROL_FRAME, ISOTP_PCI_TYPE_SINGLE, isotp_receive_consecutive_frame(), isotp_receive_first_frame(), isotp_receive_flow_control_frame(), isotp_receive_single_frame(), ISOTP_RECEIVE_STATUS_FULL, ISOTP_RECEIVE_STATUS_IDLE, ISOTP_RECEIVE_STATUS_INPROGRESS, isotp_send_flow_control(), ISOTP_SEND_STATUS_ERROR, ISOTP_SEND_STATUS_INPROGRESS, isotp_st_min_to_us(), isotp_user_get_us(), PCI_FLOW_STATUS_CONTINUE, PCI_FLOW_STATUS_OVERFLOW, PCI_FLOW_STATUS_WAIT, IsoTpDataArray::ptr, IsoTpLink::receive_bs_count, IsoTpLink::receive_offset, IsoTpLink::receive_protocol_result, IsoTpLink::receive_size, IsoTpLink::receive_status, IsoTpLink::receive_timer_cr, IsoTpLink::send_bs_remain, IsoTpLink::send_protocol_result, IsoTpLink::send_st_min_us, IsoTpLink::send_status, IsoTpLink::send_timer_bs, IsoTpLink::send_wtf_count, and TSOTP_PCI_TYPE_CONSECUTIVE_FRAME.
void isotp_poll | ( | IsoTpLink * | link | ) |
Polling function; call this function periodically to handle timeouts, send consecutive frames, etc.
link | The instance used. |
Definition at line 463 of file isotp.c.
References ISOTP_RECEIVE_STATUS_IDLE, ISOTP_RECEIVE_STATUS_INPROGRESS, isotp_send_consecutive_frame(), ISOTP_SEND_STATUS_ERROR, ISOTP_SEND_STATUS_IDLE, ISOTP_SEND_STATUS_INPROGRESS, isotp_user_get_us(), IsoTpLink::receive_protocol_result, IsoTpLink::receive_status, IsoTpLink::receive_timer_cr, IsoTpLink::send_bs_remain, IsoTpLink::send_offset, IsoTpLink::send_protocol_result, IsoTpLink::send_size, IsoTpLink::send_st_min_us, IsoTpLink::send_status, IsoTpLink::send_timer_bs, and IsoTpLink::send_timer_st.
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.
link | The IsoTpLink instance used to transceive data. |
payload | A pointer to an area in memory where the raw data is copied from. |
payload_size | The size of the received (raw) CAN data. |
out_size | A reference to a variable which will contain the size of the actual (parsed) data. |
Definition at line 430 of file isotp.c.
References ISOTP_RECEIVE_STATUS_FULL, ISOTP_RECEIVE_STATUS_IDLE, IsoTpLink::receive_buffer, IsoTpLink::receive_size, and IsoTpLink::receive_status.
|
static |
Definition at line 186 of file isotp.c.
References IsoTpCanMessage::consecutive_frame, isotp_user_debug(), IsoTpLink::receive_buffer, IsoTpLink::receive_offset, IsoTpLink::receive_size, and IsoTpLink::receive_sn.
Referenced by isotp_on_can_message().
|
static |
Definition at line 154 of file isotp.c.
References IsoTpCanMessage::first_frame, isotp_user_debug(), IsoTpLink::receive_buf_size, IsoTpLink::receive_buffer, IsoTpLink::receive_offset, IsoTpLink::receive_size, and IsoTpLink::receive_sn.
Referenced by isotp_on_can_message().
|
static |
Definition at line 215 of file isotp.c.
References isotp_user_debug().
Referenced by isotp_on_can_message().
|
static |
Definition at line 140 of file isotp.c.
References isotp_user_debug(), IsoTpLink::receive_buffer, IsoTpLink::receive_size, and IsoTpCanMessage::single_frame.
Referenced by isotp_on_can_message().
int isotp_send | ( | IsoTpLink * | link, |
const uint8_t | payload[], | ||
uint16_t | size | ||
) |
PUBLIC FUNCTIONS ///.
Sends ISO-TP frames via CAN, using the ID set in the initialising function.
Definition at line 229 of file isotp.c.
References isotp_send_with_id(), and IsoTpLink::send_arbitration_id.
|
static |
Definition at line 103 of file isotp.c.
References IsoTpCanMessage::consecutive_frame, IsoTpCanMessage::data_array, isotp_user_send_can(), IsoTpDataArray::ptr, IsoTpLink::send_arbitration_id, IsoTpLink::send_buffer, IsoTpLink::send_offset, IsoTpLink::send_size, IsoTpLink::send_sn, and TSOTP_PCI_TYPE_CONSECUTIVE_FRAME.
Referenced by isotp_poll().
|
static |
Definition at line 79 of file isotp.c.
References IsoTpCanMessage::data_array, IsoTpCanMessage::first_frame, ISOTP_PCI_TYPE_FIRST_FRAME, isotp_user_send_can(), IsoTpDataArray::ptr, IsoTpLink::send_buffer, IsoTpLink::send_offset, IsoTpLink::send_size, and IsoTpLink::send_sn.
Referenced by isotp_send_with_id().
|
static |
Definition at line 29 of file isotp.c.
References IsoTpCanMessage::data_array, IsoTpCanMessage::flow_control, ISOTP_PCI_TYPE_FLOW_CONTROL_FRAME, isotp_us_to_st_min(), isotp_user_send_can(), IsoTpDataArray::ptr, and IsoTpLink::send_arbitration_id.
Referenced by isotp_on_can_message().
|
static |
Definition at line 53 of file isotp.c.
References IsoTpCanMessage::data_array, ISOTP_PCI_TYPE_SINGLE, isotp_user_send_can(), IsoTpDataArray::ptr, IsoTpLink::send_buffer, IsoTpLink::send_size, and IsoTpCanMessage::single_frame.
Referenced by isotp_send_with_id().
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 at line 233 of file isotp.c.
References isotp_send_first_frame(), isotp_send_single_frame(), ISOTP_SEND_STATUS_INPROGRESS, isotp_user_debug(), isotp_user_get_us(), IsoTpLink::send_bs_remain, IsoTpLink::send_buf_size, IsoTpLink::send_buffer, IsoTpLink::send_offset, IsoTpLink::send_protocol_result, IsoTpLink::send_size, IsoTpLink::send_st_min_us, IsoTpLink::send_status, IsoTpLink::send_timer_bs, IsoTpLink::send_timer_st, and IsoTpLink::send_wtf_count.
Referenced by isotp_send().
|
static |
Definition at line 20 of file isotp.c.
Referenced by isotp_on_can_message().
|
static |
STATIC FUNCTIONS ///.
Definition at line 10 of file isotp.c.
Referenced by isotp_send_flow_control().