Skip to content

USB layer error logging (alongside separate CANbus error logging) #22

Description

@MDAR

Feature Request: Bus Health / Activity Logging via snap logs

Summary

Add application-layer bus health logging to python-velbustcp so that operators can monitor Velbus packet flow, detect bus silence, and surface parse errors through the standard snap logs velbus-tcp interface.


Background — complementary hardware-layer logging already exists

This request is motivated by work on a parallel project: a direct CAN-to-TCP gateway built on M5Stack AtomS3 Lite hardware (W5500 Ethernet + CA-IS3050G CAN transceiver), which connects to the Velbus CAN bus directly at the electrical layer rather than through a USB interface module.

That gateway firmware (v0.5.0) implements a SYSlog reporting pipeline that monitors and reports the CAN electrical layer in real time:

  • Bus-off detection — TWAI controller entering bus-off state (too many consecutive errors), reported immediately via UDP syslog bypassing any throttle interval
  • CAN error frame rate — TWAI_ALERT_BUS_ERROR events, rate-limited to a summary every 2 seconds to avoid flooding under sustained noise
  • TCP client connect / disconnect events — bridge connection state changes to the central Velbus TCP server, also reported immediately
  • Heartbeat — periodic status line reporting frame counts, uptime, and connection state
  • Boot messages — connection sequence logged from cold start

All of this flows through a unified ILOG/SLOG pipeline that also drives the local serial log and an on-demand portal "Send Test" button, with a fallback auto-send on reboot.

What the CAN gateway can see (electrical layer)

Event Detectable at CAN layer
Bus-off state ✅ Yes — TWAI controller alert
Bit stuffing / arbitration errors ✅ Yes — TWAI error counters
TX retry exhaustion ✅ Yes — TWAI alert
Frame rate / bus load ✅ Yes — frame counter
No frames (bus silent) ✅ Yes — 750ms dormancy threshold

Together they give an operator full visibility from the CAN wire up to the TCP connection, without either system needing to reach into the other's layer.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions