can
Original:🇨🇳 Chinese
Translated
7 scriptsChecked / no sensitive code detected
Embedded CAN/CAN-FD debugging tool for interface scanning, message monitoring, test frame transmission, log recording, database file decoding, and bus statistics. Automatically triggered when users mention CAN, CAN-FD, DBC decoding, bus packet capture, USB-CAN joint debugging, message transmission, bus statistics, PCAN, Vector, slcan, CAN interface scanning, CAN ID filtering, ASC logs, BLF files. Also compatible with explicit invocation via /can. Even if users only say "check CAN messages", "send a test frame" or "decode DBC", this skill should be triggered as long as the context involves CAN bus communication.
2installs
Sourcezhinkgit/embeddedskills
Added on
NPX Install
npx skill4agent add zhinkgit/embeddedskills canTags
Translated version includes tags in frontmatterSKILL.md Content (Chinese)
View Translation Comparison →CAN — Embedded CAN/CAN-FD Debugging Tool
Unified encapsulation of interface discovery, real-time monitoring, message transmission, log recording, database file decoding, and statistical analysis capabilities.
Configuration
Environment-level Configuration (skill/config.json
)
skill/config.jsonOnly retain slcan-related environment-level configurations:
json
{
"slcan_serial_port": "",
"slcan_serial_baudrate": 115200
}| Field | Description | Default Value |
|---|---|---|
| Serial port for slcan scenario | |
| Serial baud rate for slcan scenario | |
Project-level Configuration (.embeddedskills/config.json
)
.embeddedskills/config.jsonThe in the workspace stores project-level CAN configurations:
.embeddedskills/config.jsonjson
{
"can": {
"interface": "",
"channel": "",
"bitrate": 500000,
"data_bitrate": 2000000,
"log_dir": ".embeddedskills/logs/can"
}
}| Field | Description | Default Value |
|---|---|---|
| CAN backend, e.g., | |
| Channel name, e.g., | |
| Arbitration field bit rate | |
| CAN-FD data field bit rate | |
| Log output directory | |
Parameter Parsing Priority
- CLI Parameters (,
--interface,--channel, etc.) - Highest priority--bitrate - Project-level Configuration (the section in
can).embeddedskills/config.json - State File (historical records in )
.embeddedskills/state.json - Default Values - Lowest priority
Automatic Scanning Behavior
When and are not specified, the script will automatically scan system CAN interfaces:
interfacechannel- If only one interface is found, it will be used automatically and written to the project configuration
- If multiple interfaces are found, a candidate list will be returned for the user to select
- If no interface is found, an error will be prompted
Subcommands
| Subcommand | Purpose | Risk |
|---|---|---|
| Scan available CAN interfaces and USB-CAN devices | Low |
| Real-time monitoring of bus messages | Low |
| Send standard/extended/remote/CAN-FD frames | High |
| Record bus messages to ASC/BLF/CSV files | Low |
| Decode messages or logs using database files like DBC | Low |
| Statistics on bus load, ID distribution, and frame rate | Low |
Execution Flow
- Check if is available; prompt
python-canif not installedpip install python-can - Parse parameters by priority: CLI > Project-level Configuration > State File > Default Values
- Execute by default when no subcommand is specified
scan - use the parsed connection parameters
monitor / send / log / stats - first confirms the existence of the database file and input source
decode - If /
interfaceare not specified, automatically scan system CAN interfaces:channel- Unique candidate: automatically use and write to project configuration
- Multiple candidates: return list for user selection
- After successful execution, write the confirmed parameters back to the project configuration
- executes directly as long as the configuration is connectable, no secondary confirmation required
send - Run the corresponding script and output structured results
- When failed, prioritize feedback on interface, driver, bit rate, and filter condition issues
Script Invocation
All scripts are located in the directory under the skill directory, and can be called directly via .
Scripts read parameters from CLI parameters, project-level configuration, and state file by priority.
scripts/pythonbash
# Scan interfaces
python scripts/can_scan.py [--json]
# Real-time monitoring
python scripts/can_monitor.py [--interface <interface>] [--channel <channel>] [--bitrate <bitrate>] [--fd] [--filter-id <ID list>] [--exclude-id <ID list>] [--dbc <DBC file>] [--timeout <seconds>] [--json]
# Send messages
python scripts/can_send.py [--interface <interface>] [--channel <channel>] [--bitrate <bitrate>] <id> <data> [--extended] [--remote] [--fd] [--repeat <times>] [--interval <seconds>] [--periodic <milliseconds>] [--listen] [--json]
# Log recording
python scripts/can_log.py [--interface <interface>] [--channel <channel>] [--bitrate <bitrate>] [--output <file>] [--duration <seconds>] [--max-count <number>] [--filter-id <ID list>] [--console] [--json]
# Database decoding
python scripts/can_decode.py <db_file> [--db-format <auto|dbc|arxml|kcd|sym|cdd>] [--id <CAN_ID>] [--data <HEX data>] [--log <log file>] [--signal <signal name>] [--list] [--json]
# Bus statistics
python scripts/can_stats.py [--interface <interface>] [--channel <channel>] [--bitrate <bitrate>] [--duration <seconds>] [--top <number>] [--watch <ID list>] [--json]Output Format
Single command returns standard JSON:
json
{
"status": "ok",
"action": "scan",
"summary": "Found 2 CAN interfaces",
"details": { ... }
}Continuous commands (monitor --json, send --listen --json) output JSON Lines, and the end summary is written to stderr.
Error output:
json
{
"status": "error",
"action": "send",
"error": { "code": "interface_open_failed", "message": "Failed to open the specified CAN interface" }
}Core Rules
- Do not automatically guess interface, channel, or bitrate; do not automatically select when multiple interfaces exist
- Parameter parsing priority: CLI > Project-level Configuration > State File > Default Values
- Automatically scan when /
interfaceare not specified; automatically write the unique candidate to configuration, require user selection for multiple candidateschannel - After successful execution, automatically write confirmed parameters back to
.embeddedskills/config.json - Do not actively send any messages without clear instructions on usage
- Continuous streams output via use JSON Lines, with summaries written to stderr to avoid polluting the data stream
--json - DBC decoding failure should not interrupt monitoring
- Return clear errors when frame definitions are not found, do not silently discard them
References
- : Information on common USB-CAN devices
references/common_interfaces.json