ISOTP-C
A platform-agnostic ISOTP implementation in C.
|
This project is inspired by openxc isotp-c, but the code has been completely re-written.
This is a platform agnostic C library that implements the ISO 15765-2 (also known as ISO-TP) protocol, which runs over a CAN bus. Quoting Wikipedia:
>ISO 15765-2, or ISO-TP, is an international standard for sending data packets over a CAN-Bus. >The protocol allows for the transport of messages that exceed the eight byte maximum payload of CAN frames. >ISO-TP segments longer messages into multiple frames, adding metadata that allows the interpretation of individual frames and reassembly >into a complete message packet by the recipient. It can carry up to 4095 bytes of payload per message packet.
This library doesn't assume anything about the source of the ISO-TP messages or the underlying interface to CAN. It uses dependency injection to give you complete control.
The current version supports ISO-15765-2 single and multiple frame transmition, and works in Full-duplex mode.
It's at this point where I'd like to point out all the fantastic contributions made to this fork by the amazing people using it! List of contributors
Thank you all!
This library may be built using either straight Makefiles, or using CMake.
To build this library using Make, simply call:
The CMake build system allows for more flexibility at generation and build time, so it is recommended you use this for building this library.
Of course, if your project does not use CMake, you don't have to use it. If your projects use a different build system, you are more than welcome to include it in this repository.
The Makefile generator for isotpc will automatically detect whether or not your build system is using the Debug
or Release
build type and will adjust compiler parameters accordingly.
If your project is configured to build as Debug
, then the library will be compiled with no optimisations and with debug symbols.
-DCMAKE_BUILD_TYPE=Debug
If your project is configured to build as Release
, then the library code will be optimised using -O2
and will be stripped.
-DCMAKE_BUILD_TYPE=Release
It is generally considered good practice to segregate header files from each other, depending on the project. For this reason, you may opt in to this behaviour for this library.
If you pass -Disotpc_USE_INCLUDE_DIR=ON
on the command-line, or you set set(isotpc_USE_INCLUDE_DIR ON CACHE BOOL "Use external include dir for isotp-c")
in your CMakeLists.txt, then a separate include/
directory will be added to the project.
This happens at generation time, and the CMake project will automatically reference ${CMAKE_CURRENT_BINARY_DIR}/include
as the include directory for the project. This will be propagated to your projects, too.
In your code:
In some cases, it is required that a static library be used instead of a shared library. isotp-c supports this also, via options.
Either pass -Disotpc_STATIC_LIBRARY=ON
via command-line or set(isotpc_STATIC_LIBRARY ON CACHE BOOL "Enable static library for isotp-c")
in your CMakeLists.txt and the library will be built as a static library (*.a|*.lib
) for your project to include.
First, create some shim functions to let this library use your lower level system:
You can use isotp-c in the following way:
You can call isotp_poll as frequently as you want, as it internally uses isotp_user_get_ms to measure timeout occurences. If you need handle functional addressing, you must use two separate links, one for each.
Please view Contributors to see a list of all contributors.
Licensed under the MIT license.