Skip to content

Commit

Permalink
examples: cortex-a-r: can_demo: Added documentation about using the L…
Browse files Browse the repository at this point in the history
…inux can-utils 'canfdtest' with the CAN demo application.

Signed-off-by: Adrien Ricciardi <[email protected]>
  • Loading branch information
RICCIARDI-Adrien committed Jan 4, 2024
1 parent 66441ff commit 2497468
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions examples/cortex-a-r/armv8/spider/can_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Between the DB-9 pin 7 and pin 3 we soldered a 60 ohms resistors, we also added
## Software setup

The Kvaser CanKing CAN bus configuration is as follow :
* Bus speed : 125 Kbit/s.
* Sample point : 75% (Tseg1 = 11, TSeg2 = 4).
* SWJ (Synchronization Jump Width) : 4.
* CAN Mode : CAN FD
* Both Arbitration Phase and Data Phase parameters set to :
* Bus speed : 1000 Kbit/s, 80%.
* SJW : 8
* Bit timing : Tseg1=31, Tseg2=8.

No configuration is needed on the CAN demo application side.

Expand All @@ -32,9 +34,49 @@ goil --target=cortex-a-r/armv8/spider --templates=../../../../../goil/templates/

## Running

### Using Kvaser CanKing

Before starting the CAN demo application, connect the hardware setup and configure the Kvaser CanKing application as described in the above paragraphs.
Then, click the CanKing `Go On Bus` button.
Now, you can run the CAN demo application.

The CAN demo application starts by sending a CAN frame with the CAN ID `0x123` and the string payload `Ready!`.
After that, it waits for a CAN frame to be received. When a frame is received, it increments the CAN ID and all the payload bytes, then it sends the frame back.

### Using canfdtest on Linux

For this test we used `Ubuntu 23.10` as it is the first Ubuntu version containing a recent enough version of the `can-utils` package (the minimal required version of the `can-utils` package is `v2023.03`).

* Install the required package :
```
sudo apt install can-utils
```
Note : it is also possible to build the `can-utils` package from sources to run it on older Linux versions (see [https://github.com/linux-can/can-utils/releases/tag/v2023.03](https://github.com/linux-can/can-utils/releases/tag/v2023.03)).
* Start the CAN demo application on the board.
* Then, execute the following commands on the Linux PC :
```
# Configure the CAN interface for CAN-FD operations without bit rate switch
sudo ip link set can0 type can bitrate 1000000 dbitrate 1000000 fd on
sudo ip link set up can0
# Run the test (the PC generates the frames and the board sends the answers)
# Generate CAN-FD frames without bit rate switch
canfdtest -d -g -v can0
```
* When frames are correctly transmitted and received, the output of the program looks like :
```
baylibre@baylibre:~$ canfdtest -d -g -v can0
interface = can0, family = 29, type = 3, proto = 1
.................................................................
```
* On another terminal on the PC, you can display the CAN bus load, showing that frames are being transmitted :
Run the command : `canbusload -b can0@1000000`.
The output of the program looks like :
```
baylibre@baylibre:~$ canbusload -b can0@1000000
can0@1000000 963 131931 61632 0 13% |XX..................|
can0@1000000 1061 145357 67904 0 14% |XX..................|
can0@1000000 1012 138644 64768 0 13% |XX..................|
```

0 comments on commit 2497468

Please sign in to comment.