Skip to content

About

Core library for integrating the CANsub CAN interfaces in C/C++ or via bindings

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

13 Commits

Folders and files

Repository files navigation

C/C++ SDK for CANsub

This repository contains the common core code for CANsub projects, aiming to interface with CANsub CAN interfaces from CSS Electronics over the remote API.

The core library is written in C and exposes a C API for other languages to consume via their respective foreign function interface (FFI) bindings. It is designed around sans-IO, so the core library does not handle any I/O operations itself.

Layout

├── docs                # Auxiliary documentation for the core library.
├── include             # Global header files for the core library.
└── src                 # Source code for the core library.

Specification

The spec is the C API defined in include/cansub/cansub_ffi.h. Auxiliary documentation can be found in the docs directory.

Integration

As the library is sans-IO, the caller must handle the sockets and move bytes between them and the library according to the specification in the C API header file. The library uses up to two TCP streams at once:

  • One dedicated to live WebSocket data (data).
  • One dedicated to HTTP REST calls (control).

The library may request that the control transport be closed and opened many times.

It is up to the caller to resolve the host passed to the library and connect to the correct port. The caller should not try to interpret the data in the transports, as the library handles the full TLS stack itself. Detection of dead streams has to be done by the caller via e.g. TCP keep-alive monitoring.

The HDLC frame format used to encode CAN frames is abstracted away by the library. Some of the HTTP REST call complexity can also be offloaded to the library, but JSON parsing is left to the caller.

Building

The build uses CMake, and all dependencies are included in src/thirdparty:

cmake -S . -B build
cmake --build build -j

This builds a static library that bundles the third-party code (libcansub.a, cansub_static.lib with MSVC) and a shared library (libcansub.so, cansub.dll on Windows).

License

The C/C++ SDK for CANsub is licensed under the MIT License, see LICENSE.

The third-party code under src/thirdparty keeps its own licenses. Their notices are collected in THIRD_PARTY_NOTICES.md.

About

Core library for integrating the CANsub CAN interfaces in C/C++ or via bindings

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages