目录

moonbit-canbus

Pure MoonBit building blocks for CAN 2.0 and CAN-FD protocol work: validated frames, deterministic wire codecs, filters, arbitration, a virtual bus, and JSON/CSV event logs.

Status

The first release focuses on protocol modeling and hardware-free simulation. It does not provide SocketCAN, USB, or native hardware access. DBC, UDS, J1939, and CANopen are planned extension areas.

Build and test

moon fmt --check
moon info --target all
moon check --deny-warn --fmt --target all
moon test --deny-warn --target all
moon run cmd/can-demo

The installed MoonBit CLI currently exposes warning denial on moon check, not on moon fmt or moon info; the CI uses the supported equivalent checks and fails on any formatting diff.

Packages

  • frame: standard/extended identifiers, data/remote/error frames, classic and FD payload validation.
  • codec: DLC mapping, bitstreams, CRC, bit stuffing, and strict frame encoding/decoding.
  • filter: identifier, mask, frame-kind, and payload acceptance rules.
  • sim: bounded queues, deterministic arbitration, logical timestamps, nodes, and virtual-bus events.
  • log: versioned JSON and CSV interchange for simulation traces.
  • trace: deterministic event selection, frame extraction, summary counters, and log round trips.

Quick example

moon run cmd/can-demo

The example creates controller and logger nodes, arbitrates one standard frame, delivers it through an exact-ID filter, and prints a replayable JSON trace.

Design boundary

The core is dependency-light and written in MoonBit. It models protocol semantics and repeatable test scenarios; it does not claim to replace certified automotive stacks, hardware drivers, or real-time controller firmware.

Ecosystem review

On 2026-08-06, Mooncakes searches for can, canbus, socketcan, can-fd, dbc, uds, j1939, and canopen found no mature package with this same protocol-and-simulation scope. The broad can search primarily matched unrelated canvas packages. See docs/ecosystem.md for the bounded review and sources.

License

Apache-2.0. See LICENSE.

关于

Pure MoonBit CAN 2.0/CAN-FD frames, codecs, filters, deterministic virtual bus, and replayable JSON/CSV traces.

142.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号