Skip to content

Practical Tools

KH-UCANFD_Linux_SDK integrates multiple tools including kcanfdtest and lskcan, allowing users to use devices more easily.

lskcan Enumerates Interface Information

lskcan enumerates CAN interface details:

bash
lskcan

List Information Demo

Enumerates all interfaces' device status, as well as detailed bit rate configuration, facilitating users to check CAN device status.

kcan_monitor Monitor

kcan_monitor can real-time monitor CAN bus status and CAN transmission frame statistics:

bash
kcan_monitor

Monitor Demo

Field Descriptions

FieldDescription
dev nameDevice physical identifier and channel number
ndevNetwork interface name assigned by Linux system SocketCAN subsystem, such as "can0", "can1", through which standard tools like candump, cansend can operate
bitsCAN FD bit rate configuration, format is "arbitration phase bit rate + data phase bit rate"
busBus operating status: ACTIVE (normal active status), PASSIVE (passive status), BUSOFF (bus-off status)
%busBus load rate
%tx fifoTransmit buffer usage rate
rx_fr/sFrames received per second
tx_fr/sFrames transmitted per second
rxCumulative frames received
txCumulative frames transmitted
rec/tecReceive error count / transmit error count
errCumulative error count, including total count of various CAN bus errors such as bit errors, stuffing errors, etc.

kcanfd_test Test Script

Introduction

kcanfd_test.sh is used to test whether UCANFD device can normally send and receive data without packet dropping under full load conditions.

After driver installation, run sudo kcanfd_test.sh in command line. The script will automatically complete driver loading, parameter setting, data packet transmission/reception, and result verification.

Test Steps

Cable Preparation

Before testing, you need to connect device CAN interfaces in pairs according to channel sequence. Taking UCANFDX6 as an example, refer to wiring diagram:

UCANFDX6 Wiring Diagram

Test Process

The script's detailed test process is as follows:

Test Process Flowchart

One-Click Test Instructions

The script defaults to testing 6 channels with 1M/5M bit rate. You can modify the following parameters as needed:

  • -c: Number of channels (≤ 12)
  • -b: Bit rate (e.g., 500000 represents 500 kbit/s)
  • -d: Data phase bit rate (e.g., 4000000 represents 4 Mbit/s)
  • -t: Number of test data packets

Example:

bash
# Enable can0 and can1 two channels, set bit rate to 1M/5M, test transmission/reception of 500,000 data packets
sudo kcanfd_test.sh -c 2 -b 1000000 -d 5000000 -t 500000

One-click test channels default start from can0, and are sequentially paired in groups of two. If you need to customize test channels, you can refer to the following method.

Custom Test Instructions

For example: Need to test can1 and can4 two channels. You can use the following commands:

bash
# Enable can channel before testing
kcanfdtest -b -d can1  # can1 enters loopback mode
kcanfdtest -b -d -g can4  # can4 generates frames in loop

Here -b -d indicates test mode is FD frames with BRS.

Log Description

The test will automatically generate logs. Logs are saved in the directory where the running script is located by default:

Test Log File

Log content includes test details, frame rate, and interface transmission/reception data packet count records. Directory structure example:

Log Directory Structure

Driving Intelligent Connections, Empowering the Future