Documentation
¶
Overview ¶
Package sysinfo provides best-effort discovery of CAN and USB-serial hardware present on the host, so beacon's UI "add source/sink" forms and its GET /api/v1/system endpoint can offer detected interfaces/ports instead of a blank text field. It is a leaf package (no beacon imports of its own) so both internal/api and internal/ui can depend on it directly without either package importing the other just for this.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscoverCAN ¶
func DiscoverCAN() []string
DiscoverCAN best-effort lists SocketCAN network interface names present on this host: entries of canRoot (normally /sys/class/net) whose "type" file reads "280" (ARPHRD_CAN, the CAN bus link-layer type in Linux's if_arp.h). SocketCAN is Linux-only, so any other OS short-circuits to an empty list without touching the filesystem at all; both a missing canRoot and a per-interface read failure are treated as "no such interface" rather than an error, matching this function's best-effort contract.
func DiscoverSerial ¶
func DiscoverSerial() []string
DiscoverSerial best-effort lists likely USB-serial device paths under serialRoot (normally /dev), matching the naming conventions Linux (ttyUSB*, ttyACM*) and macOS (tty.usbserial*, tty.usbmodem*) use for USB serial adapters — the typical connection for USB-CAN and NMEA 0183 hardware. Unlike DiscoverCAN this is not OS-gated: on a host with none of these devices the glob patterns simply match nothing.
Types ¶
type CANInterface ¶
type CANInterface struct {
Name string `json:"name"`
OperationalState string `json:"operational_state,omitempty"`
CANState string `json:"can_state,omitempty"`
Bitrate uint64 `json:"bitrate,omitempty"`
RestartMS uint64 `json:"restart_ms,omitempty"`
RXPackets uint64 `json:"rx_packets,omitempty"`
TXPackets uint64 `json:"tx_packets,omitempty"`
RXErrors uint64 `json:"rx_errors,omitempty"`
TXErrors uint64 `json:"tx_errors,omitempty"`
RXDropped uint64 `json:"rx_dropped,omitempty"`
TXDropped uint64 `json:"tx_dropped,omitempty"`
BusLoadPercent *float64 `json:"bus_load_percent,omitempty"`
}
func DiscoverCANDetails ¶
func DiscoverCANDetails() []CANInterface
DiscoverCANDetails adds link state, error counters, bitrate, controller state, and an approximate live bus load to DiscoverCAN's interface list.