1 ISO-TP (ISO 15765-2) Support Library in C
2 ================================
6 First, set up some shim functions to your lower level system:
8 void debug(const char* format, ...) {
12 void send_can(const uint16_t arbitration_id, const uint8_t* data,
17 void set_timer(uint16_t time_ms, void (*callback)) {
21 Then, set up a callback and send an ISO-TP message:
23 // this is your callback for when the message is completely sent - it's
25 void message_sent(const IsoTpMessage* message, const bool success) {
26 // You received the message! Do something with it.
29 IsoTpShim shims = isotp_init_shims(debug, send_can, set_timer);
30 IsoTpHandle handle = isotp_send(&shims, 0x100, NULL, 0, message_sent);
32 if(handle.completed) {
34 // something happened and it already failed - possibly we aren't able to
38 // If the message fit in a single frame, it's already been sent and
43 // Continue to read from CAN, passing off each message to the handle
44 bool complete = isotp_receive_can_frame(&shims, &handle, 0x100, data, size);
46 if(complete && handle.completed) {
48 // All frames of the message have now been sent, following
49 // whatever flow control feedback it got from the receiver
51 // the message was unable to be sent and we bailed - fatal
58 Finally, receive an ISO-TP message:
60 // This is your callback for when a complete ISO-TP message is received at
61 // the arbitration ID you specify - it's optional. The completed message is
62 // also returned by isotp_receive_can_frame
63 void message_received(const IsoTpMessage* message) {
66 IsoTpHandle handle = isotp_receive(&shims, 0x100, message_received);
68 // something happened and it already failed - possibly we aren't able to
72 // Continue to read from CAN, passing off each message to the handle
73 IsoTp message = isotp_receive_can_frame(&shims, &handle, 0x100, data, size);
75 if(message.completed && handle.completed) {
77 // A message has been received successfully
79 // Fatal error - we weren't able to receive a message and
80 // gave up trying. A message using flow control may have
87 // TODO add an optional dispatcher to handle multiple open requests
91 The library includes a test suite that uses the `check` C unit test library.
95 You can also see the test coverage if you have `lcov` installed and the
96 `BROWSER` environment variable set to your choice of web browsers:
98 $ BROWSER=google-chrome-stable make coverage
102 Chris Peplin cpeplin@ford.com
106 Copyright (c) 2013 Ford Motor Company
108 Licensed under the BSD license.