CAN Module Support Package
The CAN module support package enables Engee to work with CAN interfaces using library blocks CAN. The package runs on top of the subsystem Engee.Integrations and it allows you to configure interfaces, send and receive CAN messages.
Requirements
-
Configured CAN interface in the OS.
-
Interface parameters (device name and bitrate) that are used in the CAN library blocks.
-
Installed drivers/utilities for the adapter you are using (Windows).
For more information, see CAN.
Quick start
-
Install or connect the Engee subsystem.Integrations as shown in article.
-
Configure the CAN interface in your OS and define the Channel/port value that you will specify in the CAN blocks.:
-
Linux (
socketcan): raise the network interfacecan0/vcan0(for an example of commands, see [CAN Interfaces]). -
Windows (
pcan): install PCAN-Basic (PEAK System) and use the following portPCAN_USBBUS1. -
Windows (
marathon): install the Marathon drivers and use the portcan0,can1… according to the numbering of the adapters. -
Virtual (
virtual): No drivers required, usevirtual_0,virtual_1… (take into account the channel pairing).To view the list of available CAN devices in Engee, run the command in Engee:
Main.EngeeDeviceManager.UTILS_API.getCanDevicesList()
-
-
Now you can use blocks from the library. CAN.
CAN interfaces
The support package uses different driver interfaces (the Interface parameter in the CAN blocks). To work in blocks, it is important to know two values:
-
Interface (for example,
socketcanorpcan); -
Channel/port is the device identifier to be specified in the block parameters (for example,
can0,vcan0,PCAN_USBBUS1,virtual_0).
How to view available CAN devices in Engee
To get a list of detected CAN controllers (identifiers that are then specified in the block parameters and scripts), run the following command in Engee:
Main.EngeeDeviceManager.UTILS_API.getCanDevicesList()
PCAN (interface pcan, Windows)
To work with PCAN-USB adapters, install PCAN-Basic drivers from PEAK System: Device Driver Setup (PCAN-Basic)
The Channel/port parameter specifies the names provided by the PCAN-Basic driver:
PCAN_USBBUS1, PCAN_USBBUS2, …, PCAN_USBBUSN.
SocketCAN (interface socketcan, Linux)
To work with socketcan It is necessary to activate the CAN interfaces in the OS.
Virtual CAN (if there is no physical adapter):
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set vcan0 up
In the Channel/port parameter, specify vcan0.
Physical CAN controller (example can0):
sudo modprobe can
sudo ip link set can0 type can bitrate 125000
sudo ip link set can0 up
# отправка сообщения
sudo cansend can0 '111#11aa'
# прием данных
sudo candump can0
In the Channel/port parameter, specify the name of the raised interface (can0, can1, …).
PCAN adapters via socketcan (for Linux kernel versions >= 3.4):
sudo modprobe peak_usb
sudo modprobe peak_pci
sudo ip link set can0 up type can bitrate 500000
Marathon (interface marathon)
To work with the Marathon CAN-bus-USB adapter install the manufacturer’s drivers: Marathon Drivers.
In the Channel/port parameter, specify the numbered adapter channel.
For the first connected adapter:
-
Conclusion
CAN 1respondcan0; -
Conclusion
CAN 2respondcan1.
Each Marathon USB adapter provides two channels: The first one — can0/can1, for the following — can2/can3, then can4/can5 and so on in ascending order.
Virtual (interface virtual)
For the interface virtual there is no need to install drivers — this is a software CAN emulation.
Specify the numbered virtual channel in the Channel/port parameter. For the first virtual bus, this is virtual_0 and virtual_1.
|
Traffic sent to |
The following virtual buses use pairs virtual_2/virtual_3, then virtual_4/virtual_5 and so on in ascending order.