Cantools
A collection of CLI tools for the CAN bus network
Install / Use
/learn @mwkpe/CantoolsREADME
cantools
A collection of CLI tools for receiving and transmitting CAN frames using Linux SocketCAN
Description
These tools can be used - and were developed - using a Raspberry Pi 3 with a PiCAN2 HAT.
- cantx: one-time or cyclic transmission of a single frame
- canprint: printing frames into the console
- cangw: routing frames between CAN and UDP
Build
Use make to build all tools or make cangw etc.
Usage
| Tool | Options | Short | Required | Default | Description |
| ---- | ------- | :---: | :------: | ------- | ----------- |
| cantx | device<br>id<br>payload<br>cycle<br>realtime | -d<br>-i<br>-p<br>-c<br>-r | <br>✓<br><br><br><br> | can0<br><br>00<br>-1 (send once)<br>false | CAN device<br>Frame ID<br>Hex data string<br>Repetition time in ms<br>Enable realtime scheduling policy |
| canprint | device | -d | | can0 | CAN device |
| cangw | listen<br>send<br>realtime<br>timestamp<br>device<br>ip<br>port | -l<br>-s<br>-r<br>-t<br>-d<br>-i<br>-p | -l ∨ -s<br>-l ∨ -s<br><br><br><br>✓<br>✓ | <br><br>false<br>false<br>can0<br><br><br> | Route frames from CAN to UDP<br>Route frames from UDP to CAN<br>Enable realtime scheduling policy<br>Prefix payload with 8-byte timestamp (ms)<br>CAN device<br>IP of remote device<br>UDP port |
Examples:
# Send frame each 100 ms
$ ./cantx --device=can0 --id=42 --data=0807060504030201 --cycle=100
# Route frames from CAN to UDP
$ ./cangw --listen --ip=192.168.1.5 --port=30001
# Same but using short options
$ ./cangw -li 192.168.1.5 -p 30001
# Route frames between interfaces and add timestamps to UDP payload
$ ./cangw -lsti 192.168.1.5 -p 30001
Acknowledgements
cxxopts for parsing command line options
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
