The example demonstrates use of the Controller Area Network (CAN) driver on the Radxa ROCK 3A hardware platform to forward a message between two CAN controllers represented in the system as the can0 and can1 network interfaces.
Example directory in the SDK
The code of the example and build scripts are available at the following path:
/opt/KasperskyOS-Community-Edition-<platform>-<version>/examples/can2can
List of programs
CanClient – application that uses the CAN driver interface.CAN – CAN bus driver.DCM – system program that lets you dynamically create IPC channels.When you build an example for the target hardware platform, platform-specific drivers are automatically included in the solution:
BSP – Board Support Package that provides cross-platform configuration of peripherals.PinCtrl – low-level pin multiplexing configuration driver (pinmux).Initialization description
The solution initialization description file named init.yaml is generated during the solution build process based on the ./einit/src/init.yaml.in template. Macros in @INIT_*@ format contained in the template are automatically expanded in the resulting init.yaml file. For more details, refer to init.yaml.in template.
Security policy description
The security.psl file contains a description of a security policy for a KasperskyOS-based solution and is located in the ./einit/src directory. The declarations in the PSL file are provided with comments that explain the purpose of these declarations.
The security.psl file is a top-level file that includes a part of the solution security policy description in the form of a PSL file dynld.psl via the use declaration. The dynld.psl file contains the security policy description that is used when dynamically linking the solution components. The declarations in the PSL files are provided with comments that explain the purpose of these declarations.
Resources
The ./resources/xdl/can2can directory contains the CanClient.edl file, which is the EDL description for the CanClient program.
Operating scenario
The CanClient program performs the following actions:
can0 and can1) with the same baud rate defined by the CAN_BR_800KBS constant.The example uses the classic CAN settings, which establish a baud rate limit of 1 MB/s. When setting the baud rate, you must use only the following constants:
CAN_BR_1MBSCAN_BR_800KBSCAN_BR_500KBSCAN_BR_250KBSCAN_BR_125KBSCAN_BR_62_5KBSCanFrame structure. For Classical CAN, the length of the data field is limited to 8 bytes.can0 interface and waits 5000 ms for it to be received via the can1 interface. (The CAN driver does not impose any restrictions on the message sending direction.)EXIT_SUCCESS code upon successful completion of all operations, or shows the EXIT_FAILURE code if errors occurred.Building and running the example
The CMake system, which is included with KasperskyOS Community Edition, is used to build and run the example.
This example is intended to run only on Radxa ROCK 3A. If you build and run this example in QEMU, an error will occur. This is the expected behavior, because there is no CAN driver for QEMU.
In contrast to the can_loopback example, which uses only one CAN interface and does not require additional equipment, this example requires two TJA1050 transceivers connected to the CAN_H and CAN_L lines.
For the example to work correctly, you must do the following:
Connection diagram for the can0 interface
Radxa ROCK 3A |
TJA1050 |
|---|---|
|
|
|
|
|
|
|
|
Connection diagram for the can1 interface
Radxa ROCK 3A |
TJA1050 |
|---|---|
|
|
|
|
|
|
|
|
can0 and can1 interfaces:See Building and running examples section.
Page top