can-debug

Original🇨🇳 Chinese
Translated
1 scriptsChecked / no sensitive code detected

Used for debugging CAN bus communication, supports listening to, sending CAN frames, and scanning nodes via USB-CAN adapters.

11installs
Added on

NPX Install

npx skill4agent add leokemp223/embed-ai-tool can-debug

SKILL.md Content (Chinese)

View Translation Comparison →

CAN Bus Debugging

Application Scenarios

  • Embedded devices that implement CAN communication need to verify whether sending and receiving are functioning properly.
  • Need to monitor all frames on the CAN bus or filter specific IDs.
  • Need to send test frames to the CAN bus and wait for responses.
  • Need to scan active nodes on the bus.

Required Inputs

  • CAN interface type (pcan, kvaser, slcan, socketcan, virtual, etc.).
  • Channel name (depends on the interface type, e.g., PCAN_USBBUS1, COM3, can0).
  • Baud rate (default 500000).

Dependencies

  • python-can
    (pip install python-can)
  • Drivers for the corresponding adapter (e.g., PCAN requires PCAN-Basic API)

Execution Steps

  1. First read references/usage.md to confirm operation parameters.
  2. Detect the environment:
    bash
    python scripts/can_tool.py --detect
  3. Perform operations according to requirements:
    bash
    # Listen to the bus
    python scripts/can_tool.py --interface pcan --channel PCAN_USBBUS1 --listen --duration 10
    
    # Send frames
    python scripts/can_tool.py --interface pcan --channel PCAN_USBBUS1 --send --id 0x123 --data 01,02,03
    
    # Scan nodes
    python scripts/can_tool.py --interface pcan --channel PCAN_USBBUS1 --scan --scan-range 0x001-0x0FF

Failure Diversion

  • connection-failure
    : Adapter not connected or driver not installed.
  • bus-error
    : CAN bus error (e.g., no terminal resistor connected).
  • timeout
    : No response after sending.

Output Convention

Example output format:
Result: ✅ Listening completed, received 15 frames
  Connection: pcan PCAN_USBBUS1 500000

  [14:30:01] 0x123  [8]  01 02 03 04 05 06 07 08
  [14:30:01] 0x456  [4]  AA BB CC DD

Handover Relationships

  • After burning firmware with
    build-keil
    /
    build-platformio
    , use this skill to verify CAN communication.
  • Complementary to
    serial-monitor
    : serial-monitor views serial port debugging output, can-debug performs CAN protocol-level debugging.