+Then, set up a callback and send an ISO-TP message:
+
+ // this is your callback for when the message is completely sent - it's
+ // optional
+ void message_sent(const IsoTpMessage* message, const bool success) {
+ // You received the message! Do something with it.
+ }
+
+ IsoTpShim shims = isotp_init_shims(debug, send_can, set_timer);
+ IsoTpHandle handle = isotp_send(&shims, 0x100, NULL, 0, message_sent);
+
+ if(handle.completed) {
+ if(!handle.success) {
+ // something happened and it already failed - possibly we aren't able to
+ // send CAN messages
+ return;
+ } else {
+ // If the message fit in a single frame, it's already been sent and
+ you're done
+ }
+ } else {
+ while(true) {
+ // Continue to read from CAN, passing off each message to the handle
+ bool complete = isotp_receive_can_frame(&shims, &handle, 0x100, data, size);
+
+ if(complete && handle.completed) {
+ if(handle.success) {
+ // All frames of the message have now been sent, following
+ // whatever flow control feedback it got from the receiver
+ } else {
+ // the message was unable to be sent and we bailed - fatal
+ // error!
+ }
+ }
+ }
+ }
+
+Finally, receive an ISO-TP message:
+
+ // This is your callback for when a complete ISO-TP message is received at
+ // the arbitration ID you specify
+ void message_received(const IsoTpMessage* message) {
+ }
+
+ IsoTpHandle handle = isotp_receive(&shims, 0x100, message_received);
+ if(!handle.success) {
+ // something happened and it already failed - possibly we aren't able to
+ // send CAN messages
+ } else {
+ while(true) {
+ // Continue to read from CAN, passing off each message to the handle
+ bool complete = isotp_receive_can_frame(&shims, &handle, 0x100, data, size);
+
+ if(complete && handle.completed) {
+ if(handle.success) {
+ // A message has been received successfully
+ } else {
+ // Fatal error - we weren't able to receive a message and
+ // gave up trying. A message using flow control may have
+ // timed out.
+ }
+ }
+ }
+ }