Debug pages switch between each other: one tab bar on top of /status.html, /can.html and /sim.html (views/_debug_nav.erb). CAN analyzer: a trace of every frame as it came (the server keeps the last 1000, GET /api/can?since=<seq> gives the new ones), each byte colored by what it is and decoded by its CANopen role — SDO command, index:subindex, expedited payload, segments, abort codes, byte 0 in bits; NMT, heartbeat, EMCY, SYNC, PDOs; who sent it, Δ ms, pause, clear, the frame filter
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-02 18:22:16 +01:00
1 parent 7901d75ff1
commit 7fdc0114e6
7 files changed
+153 -9

No files matched your search

+11 -2
View File
@@ -137,6 +137,7 @@ module Maptool
# every frame id seen (count, rate, last data) and the decoded signals.
class Store
MAX_FRAME_IDS = 2048 # ponytail: stops counting new ids past this, enough for a bus
LOG_SIZE = 1000 # the last frames as they came, for /can.html's trace
# Signals starting with this aren't taken from the bus (the GNSS
# simulation's, put by #put, stand in for the node's meanwhile).
@@ -148,6 +149,8 @@ module Maptool
@nodes = {}
@interfaces = {}
@frames = {}
@log = []
@seq = 0
end
def interface(name, **state)
@@ -174,6 +177,8 @@ module Maptool
# EMCY: error code (0 = errors reset), error register, 5 bytes vendor-specific
n[:emcy] = { code: frame.data.unpack1("S<"), register: frame.data.getbyte(2), at: at } if role == :emcy && frame.data.bytesize >= 3
end
@log << { seq: @seq += 1, at: at, interface: interface, id: frame.id, extended: frame.extended, data: frame.data.unpack1("H*") }
@log.shift if @log.size > LOG_SIZE
key = "#{interface}:#{frame.extended ? format('%08X', frame.id) : format('%03X', frame.id)}"
f = @frames[key]
if f.nil? && @frames.size < MAX_FRAME_IDS
@@ -208,8 +213,12 @@ module Maptool
end
end
def snapshot
@mutex.synchronize { { interfaces: @interfaces.dup, nodes: @nodes.dup, signals: @signals.dup, frames: @frames.values.map(&:dup) } }
# log: the frames after seq `since` (none without it).
def snapshot(since: nil)
@mutex.synchronize do
snap = { interfaces: @interfaces.dup, nodes: @nodes.dup, signals: @signals.dup, frames: @frames.values.map(&:dup) }
since ? snap.merge(log: @log.select { |f| f[:seq] > since }) : snap
end
end
end