Most of automotive projects need to have an access to the Controller Area Network (CAN) bus. There are plenty of commercial frameworks that provides CAN stacks and hardware/software tools necessary to develop proper CAN networks. They are very comprehensive and thus expensive. CANdevStudio aims to be cost-effective replacement for CAN simulation software. It can work with variety of CAN hardware interfaces (e.g. Microchip, Vector, PEAK-Systems) or even without it (vcan and cannelloni) . CANdevStudio enables to simulate CAN signals such as ignition status, doors status or reverse gear by every automotive developer. Thanks to modularity it is easy to implement new, custom features.
Checkout CANdevStudio on YouTube
Access to CAN bus is based on Qt framework. Current list of supported CAN interfaces can be found here.
Current list of devices compatible with SocketCAN (Linux only) can be found here.
- Linux
- Windows
- macOS
CANdevStudio project uses Travis CI (Linux) and AppVeyor (Windows) continuous integration tools. You can always check .travis.yml and .appveyor.yml files for building details.
git clone https://github.com/GENIVI/CANdevStudio.git
cd CANdevStudio
git submodule update --init --recursive
mkdir build
cd build
cmake ..
make
cd CANdevStudio/build
rm -rf *
export CC=clang
export CXX=clang++
cmake ..
make
If CMake failed to find Qt in your system:
cd CANdevStudio/build
rm -rf *
cmake .. -DCMAKE_PREFIX_PATH=/home/genivi/Qt5.8.0/5.8/gcc_64
make
Install AUR package: candevstudio-git
git clone https://github.com/GENIVI/CANdevStudio.git
cd CANdevStudio
git submodule update --init --recursive
mkdir build
cd build
cmake .. -G "Visual Studio 14 2015" -DCMAKE_PREFIX_PATH=C:\Qt\5.9\msvc2015
cmake --build .
git clone https://github.com/GENIVI/CANdevStudio.git
cd CANdevStudio
git submodule update --init --recursive
mkdir build
cd build
cmake .. -G "Visual Studio 14 2015 Win64" -DCMAKE_PREFIX_PATH=C:\Qt\5.9\msvc2015_64
cmake --build .
git clone https://github.com/GENIVI/CANdevStudio.git
cd CANdevStudio
git submodule update --init --recursive
mkdir build
cd build
cmake .. -G "MinGW Makefiles" -DCMAKE_PREFIX_PATH=C:\Qt\5.9\mingw53_32
cmake --build .
git clone https://github.com/GENIVI/CANdevStudio.git
cd CANdevStudio
git submodule update --init --recursive
mkdir build
cd build
cmake .. -GNinja -DCMAKE_PREFIX_PATH=/path/to/Qt/lib/cmake
ninja
Binary packages are automatically uploaded by CI tools (i.e. Travis and Appveyor) to Bintray artifactory for every commit on master branch.
Use Bintray badges above to dowload stable or develop version (each commit on master creates corresponding binary packege in Bintray)
CANdevStudio-X.Y.ZZZZZZZ-SYS[-standalone]
X - major version number of previous stable version
Y - minor version of previous stable version
Z - SHA commit ID
SYS - either win32, Linux or Darwin
standalone - bundle version that contains Qt libraries and all relevant plugins.
All packages are being built on Ubuntu 18.04 LTS. You may experience problems with missing or incompatible libraries when trying to run the package on other distros.
To run standalone version use CANdevStudio.sh script.
Packages built with MinGW 5.3.
Standalone version contains Qt and MinGW runtime libs.
Package is a DMG installer.
General instructions to start your first simulation:
- Build the latest master or release.
- Run the application and start a new project
- Drag and drop CanDevice and CanRawView components and connect them accordingly.
- Double click on CanDevice node to open configuration window.
- set one of supported backends (e.g. socketcan) link.
NOTE: List of supported backends depends on Qt version. - set name of your can interface (e.g. can0)
- set one of supported backends (e.g. socketcan) link.
- Start the simulation
- Double click on CanRawView component to see CAN traffic
Steps required to use specific CAN hardware or virtual interfaces require some additional steps listed in following sections.
The list below shows hardware that has been successfuly used with CANdevStudio.
- Tested on Linux
- Requires socketcan driver.
- Officially supported in Linux Kernel v4.12+ Configuration:
- Find your interface name (e.g. can0)
ip link
- Configure bitrate
sudo ip link set can0 type can bitrate 1000000
- Bring the device up
sudo ip link set can0 up
- Optionally configure CAN termination
- In GitHUB based driver
sudo ip link set can0 type can termination 1
- In Linux 4.12+ driver
sudo ip link set can0 type can termination 120
- In GitHUB based driver
CanDevice backend: socketcan
- Tested on Linux
- Based on FTDI Serial driver
- Requires slcand to "convert" serial device to SocketCAN.
- Officially supported in Linux Kernel v2.6.38
Configuration:
- Create SocketCAN device from serial interface
sudo slcand -o -c -s8 -S1000000 /dev/ttyUSB0 can0
- Bring the device up
sudo ip link set can0 up
CanDevice backend: socketcan
- Tested on Windows
CanDevice settings example:
backend: peakcan
interface: usb0
configuration: BitRateKey = 250000
- Tested on Windows
CanDevice settings example for PEAK-PCAN:
backend: passthrucan
configuration: BitRateKey = 250000
interface: PCANPT32
CanDevice settings example for SIE_CANUSB:
backend: passthrucan
configuration: BitRateKey = 250000
interface: CANUSB
CANdevStudio can be used without actual CAN hardware thanks to Linux's built-in emulation.
Configuration:
sudo modprobe vcan
sudo ip link add dev can0 type vcan
sudo ip link set can0 up
CanDevice backend: socketcan
A SocketCAN over Ethernet tunnel. Available for Linux only.
Let's consider setup as before:
Target configuration:
sudo modprobe vcan
sudo ip link add dev can0 type vcan
sudo ip link set can0 up
cannelloni -I can0 -R 192.168.0.1 -r 30000 -l 20000
PC configuration:
- Install libqtCannelloniCanBusPlugin.so that is built along with CANdevStudio. You can either copy it manually to Qt plugins directory (e.g. /usr/lib/qt/plugins/canbus) or use "make install" to do it automatically.
- Create new project in CANdevStudio and add CanDevice node
- Configure CanDevice:
- backend: cannelloni
- interface: 30000,192.168.0.2,20000 (local_port,remote_ip,remote_port)
- Start simulation
Target configuration:
sudo modprobe vcan
sudo ip link add dev can0 type vcan
sudo ip link set can0 up
cannelloni -I can0 -R 192.168.0.1 -r 30000 -l 20000
PC configuration:
- Execute following lines in a shell
sudo modprobe vcan
sudo ip link add dev can0 type vcan
sudo ip link set can0 up
cannelloni -I can0 -R 192.168.0.2 -r 20000 -l 30000
- Create new project in CANdevStudio and add CanDevice node
- Configure CanDevice:
- backend: socketcan
- interface: can0
- Start simulation
CANdevStudio provides support for CAN signals handling. DBC database description format is supported. Reverse engineered DBC files can be found in opendbc project.
Support for others CAN database formats can be added via extension of CANdb.
- Start new project and setup CanDevice as described in quick start section
- Add CanSignalData component that serves as CAN signals database for other components. You may have multiple CanSignalData components per projecthttps://github.com/commaai/opendbc
- Open CanSignalData properties and configure path to DBC file
- List of messages and signals shall be now loaded and visible in CanSignalData window
- You may configure cycle and initial value per each message
- Add CanSignalEncoder component and connect it with CanDevice. CanSignalEncoder act as a translator between signals and CAN frames. It is also responsible for sending cyclical messages.
- CanSignalSender has been automatically configured to use previously added CAN database. CAN database can be manually selected in component properties (this applies to all components from "Signals" group)
- Add CanSignalSender component and connect it with CanSignalEncoder
- Add signals in CanSignalSender window
- Start simulation
- CanSignalEncoder will start sending cyclical messages
- You can send previously configured signals from CanSignalSender:
- if signal is a part of periodic message its value will be updated in a next cycle
- if signal is not a part of periodic message it will be sent out immiediatelly
- Start new project and setup CanDevice as described in quick start section
- Add CanSignalData component that serves as CAN signals database for other components. You may have multiple CanSignalData components per project
- Open CanSignalData properties and configure path to DBC file
- List of messages and signals shall be now loaded and visible in CanSignalData window
- Add CanSignalDecoder component and connect it with CanDevice. CanSignalDecoder act as a translator between signals and CAN frames.
- CanSignalDecoder has been automatically configured to use previously added CAN database. CAN database can be manually selected in component properties (this applies to all components from "Signals" group)
- Add CanSignalViewer component and connect it with CanSignalDecoder
- Start simulation
- Signals shall now appear in CanSignalViewer. Note that CanSignalDecoder is sending over only signals which values has changed.
CanDevice component can be confiugred using "configuration" property:
- Format - "key1=value1;key2=value2;keyX=valueX"
- Keys names are case sensitive, values are case insensitive
- Configuration keys are taken from ConfigurationKey enum.
- RawFilterKey and ErrorFilterKey are currently not supported
- DataBitRateKey is available since Qt 5.9
- Whitespaces are ignored
E.g.
BitRateKey=100000;ReceiveOwnKey=false;LoopbackKey=true
CanRawFilter component enables to filter (i.e. accept or drop) incoming and outgoing frames:
- Qt regular expressions are used to match filter rules.
- Rules are matched from top to bottom
- Default policy is applied to frames unmatched by any filter
Examples:
- match 0x222 and 0x333 frames only [id field]
222|333
- match 0x200 - 0x300 frames only [id field]
^[23]..$
- match empty payload (DLC 0) [payload field]
^$
- match 2 byte payload (DLC 2) [payload field]
^.{4}$
- Configure build to include templategen tool
cd build
cmake .. -DWITH_TOOLS=ON
make
- Generate component (use -g option if you don't need component to have GUI)
./tools/templategen/templategen -n MyNewComponent -o ../src/components -g
- CMake script automatically detects new components. It has to be invoked manually.
cmake ..
- Build project
make
- Your component is now integrated with CANdevStudio
- You may want to modify src/components/mynewcomponent/mynewcomponentplugin.h to configure section name, color and spacing
- Define component inputs and outputs in src/components/mynewcomponent/mynewcomponentmodel.cpp. Look for examples in other components.
- Modify automatically generated unit tests src/components/mynewcomponent/tests