Group isotp¶
Public API for ISO-TP link management and message handling. More...
Modules¶
| Type | Name |
|---|---|
| module | Configuration Build-time configuration for ISO-TP. |
| module | Protocol definitions Internal protocol definitions and type structures. |
| module | User hooks User-implemented callbacks and platform hooks. |
Classes¶
| Type | Name |
|---|---|
| struct | IsoTpLink Link state for a single ISO-TP connection. |
Public Types¶
| Type | Name |
|---|---|
| typedef struct IsoTpLink | IsoTpLink Link state for a single ISO-TP connection. |
Public Functions¶
| Type | Name |
|---|---|
| void | isotp_destroy_link (IsoTpLink * link) Destroys the ISO-TP link and releases associated resources. |
| void | isotp_init_link (IsoTpLink * link, uint32_t sendid, uint8_t * sendbuf, uint32_t sendbufsize, uint8_t * recvbuf, uint32_t recvbufsize) Initialises the ISO-TP library. |
| void | isotp_on_can_message (IsoTpLink * link, const 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. |
| void | isotp_poll (IsoTpLink * link) Polling function; call this function periodically to handle timeouts, send consecutive frames, etc. |
| int | isotp_receive (IsoTpLink * link, uint8_t * payload, const uint32_t payload_size, uint32_t * out_size) Receives and parses the received data and copies the parsed data into the internal buffer. |
| int | isotp_send (IsoTpLink * link, const uint8_t payload, uint32_t size) Sends ISO-TP frames via CAN, using the ID set in the initialising function. |
| int | isotp_send_with_id (IsoTpLink * link, uint32_t id, const uint8_t payload, uint32_t size) See isotp_send , with the exception that this function is used only for functional addressing. |
| void | isotp_set_fc_params (IsoTpLink * link, uint8_t block_size, uint32_t st_min_us) Sets FlowControl parameters used by the receiver. |
| void | isotp_set_timeouts (IsoTpLink * link, uint32_t n_bs_us, uint32_t n_cr_us) Sets timing parameters for waiting on FlowControl and ConsecutiveFrame. |
Detailed Description¶
This module groups the public interface and its supporting submodules: Configuration, Protocol definitions, and User hooks.
This group defines the public interface for initializing links, sending and receiving messages, handling incoming CAN frames, and polling the protocol state machine. It also exposes optional callback registration when enabled in configuration.
** **
- Link lifecycle: isotp_init_link, isotp_destroy_link.
- Message flow: isotp_send, isotp_send_with_id, isotp_on_can_message, isotp_receive, isotp_poll.
- Link data model: IsoTpLink.
- Optional callbacks: isotp_set_tx_done_cb, isotp_set_rx_done_cb.
Public Types Documentation¶
typedef IsoTpLink¶
Link state for a single ISO-TP connection.
typedef struct IsoTpLink IsoTpLink;
The data stored in this struct is used internally and may be used by software programs using this library.
Public Functions Documentation¶
function isotp_destroy_link¶
Destroys the ISO-TP link and releases associated resources.
void isotp_destroy_link (
IsoTpLink * link
)
Parameters:
linkTheinstance to destroy.IsoTpLink
function isotp_init_link¶
Initialises the ISO-TP library.
void isotp_init_link (
IsoTpLink * link,
uint32_t sendid,
uint8_t * sendbuf,
uint32_t sendbufsize,
uint8_t * recvbuf,
uint32_t recvbufsize
)
Parameters:
linkTheinstance used for transceiving data.IsoTpLinksendidThe ID used to send data to other CAN nodes.sendbufA pointer to an area in memory which can be used as a buffer for data to be sent.sendbufsizeThe size of the buffer area.recvbufA pointer to an area in memory which can be used as a buffer for data to be received.recvbufsizeThe size of the buffer area.
function isotp_on_can_message¶
Handles incoming CAN messages. Determines whether an incoming message is a valid ISO-TP frame or not and handles it accordingly.
void isotp_on_can_message (
IsoTpLink * link,
const uint8_t * data,
uint8_t len
)
Parameters:
linkTheinstance used for transceiving data.IsoTpLinkdataThe data received via CAN.lenThe length of the data received.
function isotp_poll¶
Polling function; call this function periodically to handle timeouts, send consecutive frames, etc.
void isotp_poll (
IsoTpLink * link
)
Parameters:
linkTheinstance used.IsoTpLink
function isotp_receive¶
Receives and parses the received data and copies the parsed data into the internal buffer.
int isotp_receive (
IsoTpLink * link,
uint8_t * payload,
const uint32_t payload_size,
uint32_t * out_size
)
Parameters:
linkThe IsoTpLink instance used to transceive data.payloadA pointer to an area in memory where the raw data is copied from.payload_sizeThe size of the received (raw) CAN data.out_sizeA reference to a variable which will contain the size of the actual (parsed) data.
Returns:
Possible return values: * ISOTP_RET_OK * ISOTP_RET_NO_DATA
function isotp_send¶
Sends ISO-TP frames via CAN, using the ID set in the initialising function.
int isotp_send (
IsoTpLink * link,
const uint8_t payload,
uint32_t size
)
Single-frame messages will be sent immediately when calling this function. Multi-frame messages will be sent consecutively when calling isotp_poll.
Parameters:
linkTheinstance used for transceiving data.IsoTpLinkpayloadThe payload to be sent. (Up to 4095 bytes).sizeThe size of the payload to be sent.
Returns:
Possible return values: *
ISOTP_RET_OVERFLOW
-
ISOTP_RET_INPROGRESS -
ISOTP_RET_OK -
The return value of the user shim function isotp_user_send_can().
function isotp_send_with_id¶
See isotp_send , with the exception that this function is used only for functional addressing.
int isotp_send_with_id (
IsoTpLink * link,
uint32_t id,
const uint8_t payload,
uint32_t size
)
function isotp_set_fc_params¶
Sets FlowControl parameters used by the receiver.
void isotp_set_fc_params (
IsoTpLink * link,
uint8_t block_size,
uint32_t st_min_us
)
Parameters:
linkTheinstance used for transceiving data.IsoTpLinkblock_sizeBlock size (BS) for FlowControl. Zero means unlimited.st_min_usMinimum separation time (STmin) in microseconds.
function isotp_set_timeouts¶
Sets timing parameters for waiting on FlowControl and ConsecutiveFrame.
void isotp_set_timeouts (
IsoTpLink * link,
uint32_t n_bs_us,
uint32_t n_cr_us
)
Parameters:
linkTheinstance used for transceiving data.IsoTpLinkn_bs_usTimeout for N_Bs in microseconds.n_cr_usTimeout for N_Cr in microseconds.