Advance segmented transmission and protocol timeouts.
Advance segmented transmission and protocol timeouts.Call this regularly even when completion callbacks are enabled. The required frequency depends on the configured separation time and response timeout. Single-frame transmission and incoming-frame parsing happen synchronously in their respective API calls.
#include "example_platform.h"
#define EXAMPLE_TX_ID 0x7E0u
#define EXAMPLE_RX_ID 0x7E8u
#define EXAMPLE_BUFFER_SIZE 4095u
static ExampleCan* example_can;
static uint8_t send_buffer[EXAMPLE_BUFFER_SIZE];
static uint8_t receive_buffer[EXAMPLE_BUFFER_SIZE];
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);
}
void example_isotp_init(ExampleCan* can) {
example_can = can;
isotp_init_link(&link, EXAMPLE_TX_ID, send_buffer,
sizeof(send_buffer), receive_buffer,
sizeof(receive_buffer));
}
void example_isotp_process(void) {
uint32_t arbitration_id;
uint8_t frame_size;
uint8_t payload[EXAMPLE_BUFFER_SIZE];
uint32_t payload_size;
if (example_can_receive(example_can, &arbitration_id, frame, &frame_size) && arbitration_id == EXAMPLE_RX_ID) {
}
isotp_poll(&link);
if (
isotp_receive(&link, payload,
sizeof(payload), &payload_size) ==
ISOTP_RET_OK) { example_process_message(payload, payload_size); }
}
int example_isotp_send(
const uint8_t* payload, uint32_t size) {
return isotp_send(&link, payload, size); }
int isotp_send(IsoTpLink *link, const uint8_t payload[], uint32_t size)
Start transmitting a payload with the link's configured CAN identifier.
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.
int isotp_receive(IsoTpLink *link, uint8_t *payload, const uint32_t payload_size, uint32_t *out_size)
Copy and consume one completed, non-streaming message.
void isotp_on_can_message(IsoTpLink *link, const uint8_t *data, uint8_t len)
Process one CAN frame already routed to this link.
#define ISOTP_CAN_DL_CLASSIC
Public ISO-TP link and transport API.
State for one independent, full-duplex ISO-TP conversation.