# cantools CAN 总线数据库工具

> 面向 CAN 总线数据库的 Python 3 库和命令行工具，可解析 DBC、KCD、SYM、ARXML 3/4 和 CDD 文件，对 CAN 报文进行编码和解码，支持简单与扩展信号多路复用以及诊断 DID。其命令行可依据数据库解码 candump 输出、用 matplotlib 绘制 candump 日志中解码出的信号、转储每条报文的位布局、在数据库格式之间转换、生成 C 语言打包与解包代码，并通过 python-can 在文本界面中监视实时总线。

- 类型：工具
- 目标：协议
- 类别：协议分析工具
- 关联：基础工具
- 来源复核于：2026-10-27
- 收录于：2026-11-03
- 原始资源：<https://github.com/cantools/cantools>
- 一手来源：<https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/README.rst>
- 目录页面：<https://awesomerea.org/zh/resources/cantools/>
- 记录 JSON：<https://awesomerea.org/resources/cantools/record.json>
- 英文版：[English](https://awesomerea.org/resources/cantools/index.md)

## 使用条件与局限

- 审阅时最新版本为 45.1.0，于 2026-10-20 发布在 GitHub 和 PyPI；所审阅的 master 提交比该标签多 15 个提交。可用 pip 安装；pyproject.toml 要求 Python 3.10+，依赖 python-can、bitstruct、textparser、crccheck 和 argparse_addons，并提供绘图（matplotlib）、缓存（diskcache）以及监视器所需 Windows curses 支持等可选扩展。
- 需要自备描述目标网络的数据库以及从该网络采集的帧：decode 从标准输入读取 candump 输出，plot 读取 candump 日志文件，monitor 则通过 python-can 的总线参数连接实时接口；README 中的脚本示例在 SocketCAN 通道上收发帧。仓库的 tests/files 目录收录示例和测试所用的 DBC、KCD、SYM、ARXML 和 CDD 示例数据库以及生成的 C 源码。
- 解码范围仅限所提供数据库中定义的内容；cantools 应用现有的报文和信号定义，并不推断未知布局；README 还指出生成的 C 代码仅支持不超过 64 位的信号。采用 MIT 许可。

## 一手来源

1. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/README.rst>
2. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/README.rst#L1-L35>
3. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/README.rst#L83-L130>
4. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/README.rst#L291-L310>
5. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/pyproject.toml>
6. <https://github.com/cantools/cantools/tree/5d37340b321c60cbf9b61f2abfad352751f5c835/src/cantools/subparsers>
7. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/src/cantools/subparsers/monitor.py>
8. <https://github.com/cantools/cantools/tree/5d37340b321c60cbf9b61f2abfad352751f5c835/tests/files>
9. <https://github.com/cantools/cantools/blob/5d37340b321c60cbf9b61f2abfad352751f5c835/LICENSE>
10. <https://github.com/cantools/cantools/releases/tag/45.1.0>
11. <https://pypi.org/project/cantools/45.1.0/>
12. <https://cantools.readthedocs.io/en/latest/>

## 同分区更多条目：协议

- [inspectrum 无线电信号分析工具](https://awesomerea.org/zh/resources/inspectrum/index.md) · 工具
- [PULSAR 协议学习研究原型](https://awesomerea.org/zh/resources/pulsar/index.md) · 工具
- [CanLab CAN 总线逆向分析工作站](https://awesomerea.org/zh/resources/canlab/index.md) · 工具
- [Facedancer USB 设备仿真与代理库](https://awesomerea.org/zh/resources/facedancer/index.md) · 工具
- [Mirage 无线通信分析框架](https://awesomerea.org/zh/resources/mirage-wireless-framework/index.md) · 工具
- [Protobuf Decoder 无定义 Protobuf 网页解码器](https://awesomerea.org/zh/resources/pawitp-protobuf-decoder/index.md) · 工具

## 关于此条目

说明已依据一手来源复核。
原创说明采用 MIT 许可；外部项目、论文与素材保留各自的权利和许可。
