isotp-c
Platform-independent ISO 15765-2 transport for embedded C
Loading...
Searching...
No Matches
Platform integration

Functions that every application supplies to connect ISO-TP to its driver and clock. More...

Functions

void isotp_user_debug (const char *message,...)
 Receive a diagnostic message from the library.
int isotp_user_send_can (const uint32_t arbitration_id, const uint8_t *data, const uint8_t size, const uint8_t flags, void *arg)
 Submit one CAN or CAN FD frame to the application's driver.
uint32_t isotp_user_get_us (void)
 Return the current 32-bit monotonic time in microseconds.

Detailed Description

Functions that every application supplies to connect ISO-TP to its driver and clock.

Function Documentation

◆ isotp_user_debug()

void isotp_user_debug ( const char * message,
... )

Receive a diagnostic message from the library.

The application may implement this as a no-op. Calls can occur from any transport API that detects an error. The library does not require the message to be retained after this function returns.

Parameters
[in]messageDiagnostic string or printf-style format.
[in]...Optional format arguments.
Examples
isotp_example_callbacks.c, isotp_example_can_fd.c, isotp_example_polling.c, and isotp_example_streaming.c.

◆ isotp_user_get_us()

uint32_t isotp_user_get_us ( void )

Return the current 32-bit monotonic time in microseconds.

The value must advance independently of call frequency. Natural wraparound at UINT32_MAX is supported.

Returns
Current platform tick in microseconds.
Examples
isotp_example_callbacks.c, isotp_example_can_fd.c, isotp_example_polling.c, and isotp_example_streaming.c.

◆ isotp_user_send_can()

int isotp_user_send_can ( const uint32_t arbitration_id,
const uint8_t * data,
const uint8_t size,
const uint8_t flags,
void * arg )

Submit one CAN or CAN FD frame to the application's driver.

The implementation must consume or copy data before returning. It may be called synchronously from isotp_send(), isotp_on_can_message(), isotp_receive_streaming(), or isotp_poll().

Parameters
[in]arbitration_idCAN identifier to transmit.
[in]dataFrame payload, valid only for the duration of this call.
[in]sizeFrame payload length. It never exceeds ISO_TP_MAX_CAN_FRAME_SIZE. Lengths above 8 require CAN FD.
[in]flagsPresent only with ISO_TP_USER_SEND_CAN_FLAGS. A bitwise OR of ISOTP_CAN_FRAME_FLAG_FD and ISOTP_CAN_FRAME_FLAG_BRS; short frames on a link with TX_DL above 8 still carry the FD flag.
[in]argPresent only with ISO_TP_USER_SEND_CAN_ARG. This is the link's user_send_can_arg value.
Return values
ISOTP_RET_OKThe driver accepted the frame.
ISOTP_RET_NOSPACEThe driver is temporarily full and a polled Consecutive Frame should be retried.
ISOTP_RET_ERRORThe frame could not be submitted.
Examples
isotp_example_callbacks.c, isotp_example_can_fd.c, isotp_example_polling.c, and isotp_example_streaming.c.