跳转到内容

BMCLI daemon

命令名、参数与机器可读字段保持英文,以便直接复制到终端或交给 AI 使用;当前安装版本的精确契约请以 bmcli help ... --format=json 为准。

Background process keeping channels open for low-latency command execution. Communicates via TCP socket on 127.0.0.1:4502 (cross-platform, same on Windows and Linux).

On Linux, daemon state follows the XDG base-directory convention:

  • PID: $XDG_RUNTIME_DIR/bmcli/daemon_4502.pid; fallback /tmp/bmcli-<uid>/daemon_4502.pid.
  • Log: $XDG_STATE_HOME/bmcli/daemon_4502.log; fallback ~/.local/state/bmcli/daemon_4502.log.
  • IPC remains the loopback TCP endpoint above; there is no filesystem socket.

Recommendation: Always specify the real timing, role/mode, and termination or pull-up at startup. The bus type is inferred from channel capability. Incorrect defaults can disturb a physical CAN or LIN network.

Terminal window
# Recommended: stable SN/port and explicit CAN parameters
bmcli daemon start --channel=10356/0 --nbitrate=500k --dbitrate=2M --termination=120
# Multi-channel on same device
bmcli daemon start --channel=10356/0,10356/1 --nbitrate=250k --dbitrate=1M --mode=normal --termination=120
# Multi-device
bmcli daemon start --channel=10356/0,10357/0 --nbitrate=500k --termination=120
# LIN master startup
bmcli daemon start --channel=10356/4 --mode=master --bitrate=19200 --pullup=1k --power=on
# Legacy index remains supported for temporary interactive use
bmcli daemon start --channel=0 --nbitrate=500 --dbitrate=2000 --termination=120
Option Default Description
--channel Channels to open at startup
--mode CAN normal; LIN listen-only CAN mode or LIN role
--nbitrate 500 CAN nominal bitrate kbps
--dbitrate 2000 CAN data bitrate kbps
--bitrate 19200 LIN bitrate bps
--termination 120 CAN termination: 120 or off
--pullup mode default LIN pull-up: 1k or off
--power mode default LIN 12 V output: on or off
--lin-version 2.2 LIN protocol version
--checksum auto LIN checksum model

Blocks until daemon socket is ready (up to 10s).

Terminal window
bmcli daemon stop

Close and capability-reopen all CAN and LIN channels. Re-applies saved TX tasks; CAN routes are also restored.

Terminal window
bmcli daemon restart
Terminal window
bmcli daemon status

Shows: open channel count, PID, uptime.

  • SN-based channel identification: Channels are tracked by SN+port internally, so recovery after USB reconnection always finds the correct device regardless of enumeration order
  • BUSOFF recovery: CAN channels are checked without consuming traffic and recovered through BM_RecoverBusOff; if recovery fails, the daemon capability-reopens the channel and restores its persistent configuration. LIN channels are excluded from CAN BUSOFF handling.
  • USB reconnect: On USB disconnect (ILLOPERATION), waits 1s then re-enumerates and reopens using stored SN+port
  • Config persistence: Txtasks and routes are re-applied after channel recovery
  • Background threads: Host logging and replay run in separate threads


权威来源: bmcli_reference.md in the BMCLI repository. Run bmcli help <category> <action> --format=json for the exact contract of the installed version.