README Linux¶
The simplyCAN software package is delivered as .tar.gz archive, which includes the following components:
simplyCAN library (so, static lib)
Header file
busmonitor
Demo applications for C, C# and Python
API documentation
License
The instructions below are valid and tested for Ubuntu 22.04 LTS (Python 3.9). This may be different for other distributions.
Installation Driver¶
The USB interface is automatically installed when plugged in, without a driver installation. By default the device will be mapped to
/dev/ttyACMx. The device name will be set by means of an udev rule in60-simplyCAN.rules.If the
modemmanageris installed on your system, it may grab the device after plugged in. During this time, the device cannot be used by your application. This is prevented by a separate udev rule in60-simplyCAN.rules.To prevent both problems, copy the file
60-simplyCAN.rulesto the folder/etc/udev/rules.dTo activate the new rules, execute the following command:
$ sudo udevadm control --reload-rulesand unplug the device and plug it back in.If user rights for using the simplyCAN device are missing, add your user name to the dialout group:
$ sudo usermod -a -G dialout $USER
Installation Bus Monitor¶
The simplyCAN Bus Monitor is installed with the following commands (tested for Ubuntu 20.04)
If necessary, adapt the version number for python3.9-tk according to your Python version:
$ sudo add-apt-repository universe
$ sudo apt update
$ sudo apt install python3-pip
$ sudo pip3 install pyserial
$ sudo apt install python3.9-tk
$ cd busmonitor
$ sudo pip3 install simplycan_busmonitor-1.3.0-py3-none-any.whl
The simplyCAN Bus Monitor can then be started with the following command:
$ simplycan_busmonitor
Usage of the Demo Applications¶
The demo applications are available for C, C# and Python. First the serial port has to be adapted according to your hardware setup. To determine the used serial port, you can:
use the simplyCAN bus monitor
use the command
ls -l /dev/serial/by-iduse a udev rule (see above)
use the function
retrieve_serial_port()(C and Python)
C Demo¶
Adapt the
k_SERIAL_PORTandk_BAUDRATEdefines indemo.caccording to your hardware setup:#ifdef __unix__ #define k_SERIAL_PORT "/dev/ttyACM0" #else #define k_SERIAL_PORT "COM1" #endif #define k_BAUDRATE (250)
Compile the demo with
makeand run the executable located in bin/
C# Demo¶
The C# demo is developed for .NET Core 2.0 from Microsoft. To run and build the demo application the .NET Core Runtime is required. .Net Core 2.x is currently not available for 32 bit Linux distributions.
Adapt the name of the .so that provides the simplyCAN API in
simply.csaccording to your system:public const string SimplyCANlib = "simplyCAN.dll"; // Windows 32bit public const string SimplyCANlib = "simplyCAN-64.dll"; // Windows 64bit public const string SimplyCANlib = "simplyCAN.so"; // ELF 64bit
Adapt
mserial_portandmbitrateindemo.csaccording to your hardware setup:private static char[] mserial_port = "/dev/ttyACM0\0".ToCharArray(); // Linux //private static char[] mserial_port = "COM5\0".ToCharArray(); // Windows private static ushort mbitrate = 250;
Before running the demo the
simplyCAN.sohas to be copied tousr/lib/Run the demo with
dotnet run demo.csproj.
Python Demo¶
Adapt the COM port in
demo.pyaccording to your hardware setup:# main("/dev/ttyACM0", 250) # for Linux main("COM6", 250) # for Windows
The value
250is the used baudrate in kBaud.Run the demo with
python demo.py.
Copyright¶
(C) 2019-2022 HMS Technology Center Ravensburg GmbH
Helmut-Vetter-Strasse 2
88213 Ravensburg
Germany