Group isotp

Modules > 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.

** **

Public Types Documentation

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

Destroys the ISO-TP link and releases associated resources.

void isotp_destroy_link (
    IsoTpLink * link
) 

Parameters:

  • link The
    IsoTpLink 
    
    instance to destroy.

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:

  • link The
    IsoTpLink 
    
    instance used for transceiving data.
  • 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.

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:

  • link The
    IsoTpLink 
    
    instance used for transceiving data.
  • data The data received via CAN.
  • len The 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:

  • link The
    IsoTpLink 
    
    instance used.

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:

  • 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.

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:

  • link The
    IsoTpLink 
    
    instance used for transceiving data.
  • payload The payload to be sent. (Up to 4095 bytes).
  • size The size of the payload to be sent.

Returns:

Possible return values: *

ISOTP_RET_OVERFLOW 


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:

  • link The
    IsoTpLink 
    
    instance used for transceiving data.
  • block_size Block size (BS) for FlowControl. Zero means unlimited.
  • st_min_us Minimum 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:

  • link The
    IsoTpLink 
    
    instance used for transceiving data.
  • n_bs_us Timeout for N_Bs in microseconds.
  • n_cr_us Timeout for N_Cr in microseconds.