Go to file
Christopher Peplin 64af0554cb Print full payload by giving it enough buffer. DOH. 2014-01-03 12:18:33 -05:00
deps Attempt to print entire payload and fail. 2014-01-02 18:31:52 -05:00
src/isotp Print full payload by giving it enough buffer. DOH. 2014-01-03 12:18:33 -05:00
tests Print full payload by giving it enough buffer. DOH. 2014-01-03 12:18:33 -05:00
.gitignore Add canutil dependency for bit field manipulation. 2013-12-27 14:14:14 -05:00
.gitmodules Use renamed bitfield-c dependency. 2013-12-30 13:31:35 -05:00
.travis.yml Update submodules when running CI. 2013-12-30 13:21:30 -05:00
CHANGELOG.mkd Initial commit with blank structure. 2013-12-27 11:22:56 -05:00
LICENSE Initial commit with blank structure. 2013-12-27 11:22:56 -05:00
Makefile Bump dependency. 2013-12-30 13:32:23 -05:00
README.mkd Return completed rx messages instead of relying on callbacks. 2014-01-01 16:10:57 -05:00
runtests.sh Initial commit with blank structure. 2013-12-27 11:22:56 -05:00

README.mkd

ISO-TP (ISO 15765-2) Support Library in C

API

First, set up some shim functions to your lower level system:

void debug(const char* format, ...) {
    ...
}

void send_can(const uint16_t arbitration_id, const uint8_t* data,
        const uint8_t size) {
    ...
}

void set_timer(uint16_t time_ms, void (*callback)) {
    ...
}

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 - it's optional. The completed message is
// also returned by isotp_receive_can_frame
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
        IsoTp message = isotp_receive_can_frame(&shims, &handle, 0x100, data, size);

        if(message.completed && 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.
            }
        }
    }
}

// TODO add an optional dispatcher to handle multiple open requests

Testing

The library includes a test suite that uses the check C unit test library.

$ make test

Authors

Chris Peplin cpeplin@ford.com

License

Copyright (c) 2013 Ford Motor Company

Licensed under the BSD license.