CANopen diagnostics and map data over HTTPS: /can.html (interfaces, nodes with heartbeat state and last EMCY, decoded signals, every COB-ID with role, count, rate and last data); signals can mark an invalid raw value (esphome-canopen's unknown) and NaN gives no value; the CAN reader never dies and a broken can.json only turns CAN off; the GNSS node mcu-stm32-xiao-c5-2 (0x21) and host networking for the car's server in docs; bin/pull-maps.sh pulls map data from GET /api/sync/maps(/file) with SYNC_TOKEN instead of rsync over SSH, resuming cut-off downloads
CI / check (push) Successful in 42s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-29 12:47:23 +01:00
1 parent a3e5fefaf1
commit 6a0d6194fe
9 files changed
+365 -43

No files matched your search

+13
View File
@@ -42,6 +42,12 @@ class CanTest < Minitest::Test
assert_empty decoder.decode(Frame.new(0x0F1, "\0\0\0\0\0".b, false))
assert_in_delta(-15.0, decoder.decode(Frame.new(0x281, [250].pack("s<"), false))["temp"])
assert_empty decoder.decode(Frame.new(0x181, "\x01".b, false)), "too short for the i32s"
# esphome-canopen's Sensor16 (min..max over 0..65534, 65535 unknown) and a NaN float: no value.
alt = Maptool::Can::Decoder.new([{ "name" => "alt", "id" => "0x4A1", "type" => "u16", "scale" => 9500.0 / 65534, "offset" => -500, "invalid" => 65535 },
{ "name" => "lat", "id" => "0x3A1", "type" => "f32" }])
assert_in_delta 9000, alt.decode(Frame.new(0x4A1, [65534].pack("S<"), false))["alt"], 1e-6
assert_empty alt.decode(Frame.new(0x4A1, [65535].pack("S<"), false))
assert_empty alt.decode(Frame.new(0x3A1, [Float::NAN].pack("e"), false))
assert_raises(ArgumentError) { Maptool::Can::Decoder.new([{ "name" => "x", "id" => 1, "type" => "u64" }]) }
end
@@ -53,6 +59,13 @@ class CanTest < Minitest::Test
assert_equal({ frames: 2, last_frame_at: 2.0 }, snapshot[:interfaces]["vcan0"])
assert_equal({ seen_at: 1.0, state: "operational" }, snapshot[:nodes][5])
assert_equal({ value: 49.1, at: 2.0 }, snapshot[:signals]["gnss.lat"])
store.record("vcan0", Frame.new(0x181, "".b, false), {}, at: 2.5)
store.record("vcan0", Frame.new(0x085, [0x8130, 0x11].pack("S<C"), false), {}, at: 3.0)
snapshot = store.snapshot
tpdo = snapshot[:frames].find { |f| f[:id] == 0x181 }
assert_equal [:tpdo1, 1, 2, 0.5], tpdo.values_at(:role, :node, :count, :interval)
assert_equal({ code: 0x8130, register: 0x11, at: 3.0 }, snapshot[:nodes][5][:emcy])
end
# Over a real SocketCAN interface when there is one: