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

Set the CAN frame data length used to transmit on a link.

Set the CAN frame data length used to transmit on a link.A Classical CAN link uses 8. CAN FD links may use 12, 16, 20, 24, 32, 48, or 64, subject to the compiled ISO_TP_MAX_CAN_FRAME_SIZE.

Parameters
[in,out]linkInitialised link, or NULL.
[in]tx_dlDesired transmit data length.
Return values
ISOTP_RET_OKThe value was applied.
ISOTP_RET_ERRORThe link is NULL, the value is not a legal CAN data length, or it exceeds ISO_TP_MAX_CAN_FRAME_SIZE.
ISOTP_RET_INPROGRESSA segmented transmission is active; its TX_DL cannot be changed.
Note
RX_DL is learned independently from each incoming First Frame.
#include "example_platform.h"
#include "isotp.h"
#define EXAMPLE_TX_ID 0x7E0u
static IsoTpLink link;
static uint8_t send_buffer[4095];
static uint8_t receive_buffer[4095];
int isotp_user_send_can(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size, const uint8_t flags, void* arg) {
ExampleCan* can = (ExampleCan*)arg;
const bool fd = (flags & ISOTP_CAN_FRAME_FLAG_FD) != 0u;
const bool brs = (flags & ISOTP_CAN_FRAME_FLAG_BRS) != 0u;
return example_can_send(can, arbitration_id, data, size, fd, brs);
}
uint32_t isotp_user_get_us(void) { return example_get_us(); }
void isotp_user_debug(const char* message, ...) { (void)message; }
void example_can_fd_init(ExampleCan* can) {
isotp_init_link(&link, EXAMPLE_TX_ID, send_buffer, sizeof(send_buffer), receive_buffer, sizeof(receive_buffer));
link.user_send_can_arg = can;
}
int example_can_fd_use_classical_frames(void) { return isotp_set_tx_dl(&link, ISOTP_CAN_DL_CLASSIC); }
void isotp_init_link(IsoTpLink *link, uint32_t sendid, uint8_t *sendbuf, uint32_t sendbufsize, uint8_t *recvbuf, uint32_t recvbufsize)
Initialise an ISO-TP link and its caller-owned buffers.
#define ISOTP_CAN_FRAME_FLAG_BRS
#define ISOTP_CAN_FRAME_FLAG_FD
#define ISOTP_CAN_DL_CLASSIC
void isotp_user_debug(const char *message,...)
Receive a diagnostic message from the library.
uint32_t isotp_user_get_us(void)
Return the current 32-bit monotonic time in microseconds.
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.
Public ISO-TP link and transport API.