“Shanghai interchange” by Denys Nevozhai
CAN BUS tools
Cannes (named after the city in France 🇫🇷) is an elixir WIP-wrapper
which is written in python. The wrapper makes it easier to handle CAN
messages in Elixir projects. Individual functionalities of
cantools are implemented using Porcelain. Porcelain
implements a saner approach to launching and communicating with external
OS processes from Elixir. Built on top of Erlang’s ports, it provides
richer functionality and simpler API.
Why a wrapper for CAN?
As part of my master thesis
A Man-In-The-Middle Approach Towards Dataflow Management for OBD-II Interfaces in Vehicles)
I had to deal with a variety of CAN messages. Since I wanted to develop
my approach using Elixir, I needed a simple way to encode and decode
different CAN messages in Elixir.
Cannesis still under development and by far not complete. Feel free to contribute.
See General Informations for more about this project.
- Install Python v3.x
- Install Elixir v1.11+
- Setup a virtualenv and activate it
pip install -r requirements.txtto install the python dependencies
mix deps.getto install the Hex dependencies
To use Cannes in your Mix projects, first add Cannes as a dependency.
Components of the library
“Brief general overview of the internal components.“
dumper module is for communicating with linux can
sockets over candump.
In order to spawns a candump process on the given interface you can use the following snippet.
There is also a function for stopping a running
candumpprocess carefully and for checking if the
candumpprocess is still running.
If you want to get a stream of formatted can messages you can do this by calling the following function.
This raw stream can also be formatted afterwards by passing the
stored binary to
This module is the counterpart to the
With the help of the included functions it is possible to send CAN
Cannes.Mock module provices some useful functions
for simulating simple CAN-messages. You can get an infinite stream of
formatted can messages by calling the
Currently we use a simple logging file as blueprints for the
Cannes.Tools facilitates a usefull wrapper for the
python library called
decode_message function it is possible to
decode given signal data as a message with given frame ID or given name
frame_id_or_name. The function returns a dictionary of
signal name value entries. If
false, scaled values are not converted to selection strings
(if any). If the scaling is
false, no scaling of signals is
The counterpart to this is the
It encodes given signal data as a message with the given frame ID or
frame_id_or_name. The return value is a dictionary of
signal name value entries. If scaling is
false, no scaling
of the signals is performed. If padding is
bits are encoded as 1. If strict is
true, all signal values
must be within their allowed ranges or an exception will be thrown.