Register or clear the completed-receive callback.
Register or clear the completed-receive callback.The callback runs synchronously from isotp_on_can_message(). Its payload pointer refers to the link's receive buffer and is valid only until the callback returns. Registering it disables delivery through isotp_receive(). Oversized streaming messages are still delivered through isotp_receive_streaming().
#include "example_platform.h"
#define EXAMPLE_TX_ID 0x7E0u
#define EXAMPLE_RX_ID 0x7E8u
static ExampleCan* example_can;
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) {
return example_can_send(example_can, arbitration_id, data, size, false, false);
}
static void transmit_complete(void* completed_link, uint32_t size, void* user_arg) {
(void)completed_link;
(void)size;
(void)user_arg;
}
static void receive_complete(void* completed_link, const uint8_t* data, uint32_t size, void* user_arg) {
(void)completed_link;
(void)user_arg;
example_process_message(data, size);
}
void example_callbacks_init(ExampleCan* can) {
example_can = can;
isotp_init_link(&link, EXAMPLE_TX_ID, send_buffer,
sizeof(send_buffer), receive_buffer,
sizeof(receive_buffer));
isotp_set_rx_done_cb(&link, receive_complete, NULL);
}
void example_callbacks_process(void) {
uint32_t arbitration_id;
uint8_t frame_size;
if (example_can_receive(example_can, &arbitration_id, frame, &frame_size) && arbitration_id == EXAMPLE_RX_ID) {
}
isotp_poll(&link);
}
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.
void isotp_on_can_message(IsoTpLink *link, const uint8_t *data, uint8_t len)
Process one CAN frame already routed to this link.
void isotp_set_tx_done_cb(IsoTpLink *link, isotp_tx_done_cb cb, void *arg)
Register or clear the successful-transmission callback.
#define ISOTP_CAN_DL_CLASSIC
Public ISO-TP link and transport API.
State for one independent, full-duplex ISO-TP conversation.