diff --git a/TODO.adoc b/TODO.adoc index 32538ab..ea4bddb 100644 --- a/TODO.adoc +++ b/TODO.adoc @@ -230,6 +230,9 @@ already reaches the home MQTT broker (`mqtt_ext`) from ESPHome nodes in `~/espho *** [ ] EDS (CiA 306) read from a node (`0x1021`) or a file, the same decoder from it — once the ESPHome side generates EDS (proposal for mrk in home-gitops `docs/canopen-nodes.adoc`); the car bridge's frames described the same way +**** [x] Meanwhile one EDS for all of them: esphome-canopen's generic one (from can2mqtt) in + `public/can/esphome.eds`, names the SDO objects in `/trace.html` (plus the entity objects); + a node's own EDS (`0x1021`) to take its place per node *** [ ] 0x1008/0x1018 identity for any CANopen device in `/can.html` ** [x] A node that stops its heartbeat (3 missed) is flagged: one journal line when it goes silent and when it's back (`can: node 2 silent, last heartbeat …`), red in `/can.html` diff --git a/app.rb b/app.rb index ec22935..c752f0f 100644 --- a/app.rb +++ b/app.rb @@ -540,6 +540,11 @@ module Maptool erb :can, layout: false end + # Every CAN frame as it came, decoded (polls GET /api/can?since=). + get "/trace.html" do + erb :trace, layout: false + end + # A share to the installed app normally never reaches the server: the # service worker (public/sw.js) takes the POST, parks the files and # opens the app. Only lands here if no worker is running yet — back to diff --git a/docs/third-party-notices.adoc b/docs/third-party-notices.adoc index 618b080..30990dd 100644 --- a/docs/third-party-notices.adoc +++ b/docs/third-party-notices.adoc @@ -165,6 +165,13 @@ Offline routing runs https://github.com/valhalla/valhalla[Valhalla] (`ghcr.io/valhalla/valhalla`, version pinned in `docker-compose.yaml`), over the same Geofabrik extracts (ODbL). See `docs/routing-design.adoc`. +`public/can/esphome.eds`, the CANopen object dictionary of +https://github.com/mrk-its/esphome-canopen[esphome-canopen] nodes (the +CAN trace names SDO objects by it), is copied from +https://github.com/mrk-its/can2mqtt[can2mqtt] +(`src/can2mqtt/eds/esphome.eds`, commit `815ad0f`, MIT or Apache-2.0, +© mrk-its). Updated by hand. + Not a frontend asset like the above, but also baked into this app's own Docker image (not a separate container the way kiwix-serve is — see `docs/deployment.adoc`/`docs/development.adoc`): three CLI tools diff --git a/lib/maptool/can.rb b/lib/maptool/can.rb index 696bc2f..08278bb 100644 --- a/lib/maptool/can.rb +++ b/lib/maptool/can.rb @@ -137,7 +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 + LOG_SIZE = 5000 # the last frames as they came, for /trace.html (a few seconds of a busy bus) # Signals starting with this aren't taken from the bus (the GNSS # simulation's, put by #put, stand in for the node's meanwhile). @@ -213,11 +213,11 @@ module Maptool end end - # log: the frames after seq `since` (none without it). + # log: the frames after seq `since` (none without it); log_seq: the last one's. 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 + since ? snap.merge(log: @log.select { |f| f[:seq] > since }, log_seq: @seq) : snap end end end diff --git a/public/can/esphome.eds b/public/can/esphome.eds new file mode 100644 index 0000000..a6c2317 --- /dev/null +++ b/public/can/esphome.eds @@ -0,0 +1,169 @@ +[DeviceInfo] +VendorName=ESPHome +VendorNumber=1 +BaudRate_10=0 +BaudRate_20=0 +BaudRate_50=0 +BaudRate_125=1 +BaudRate_250=1 +BaudRate_500=1 +BaudRate_800=0 +BaudRate_1000=1 +SimpleBootUpMaster=0 +SimpleBootUpSlave=1 +Granularity=8 +DynamicChannelsSupported=0 +CompactPDO=0 +GroupMessaging=0 + +NrOfRXPDO=0 +NrOfTXPDO=4 +LSS_Supported=0 + +[1008] +ParameterName=DeviceName +ObjectType=7 +DataType=9 +AccessType=R + +[1009] +ParameterName=HardwareVersion +ObjectType=7 +DataType=9 +AccessType=R + +[100a] +ParameterName=SoftwareVersion +ObjectType=7 +DataType=9 +AccessType=R + +[1010] +ParameterName=ParamStore +ObjectType=9 + +[1010sub0] +ParameterName=Number of ParamStore Entries +ObjectType=7 +DataType=5 +AccessType=R + +[1010sub1] +ParameterName=Store All +ObjectType=7 +DataType=7 +AccessType=RW + +[1010sub2] +ParameterName=Store Comm +ObjectType=7 +DataType=7 +AccessType=RW + +[1011] +ParameterName=ParamReset +ObjectType=9 + +[1011sub0] +ParameterName=Number of ParamStore Entries +ObjectType=7 +DataType=5 +AccessType=R + +[1011sub1] +ParameterName=Reset All Params +ObjectType=7 +DataType=7 +AccessType=RW + +[1011sub2] +ParameterName=Reset Comm Params +ObjectType=7 +DataType=7 +AccessType=RW + + + +[1017] +ParameterName=ProducerHeartbeatTime +ObjectType=7 +DataType=6 +AccessType=RW + +[1018] +ParameterName=Identity +ObjectType=9 + +[1018sub0] +ParameterName=Number of Entries +ObjectType=7 +DataType=5 +AccessType=R + +[1018sub1] +ParameterName=VendorId +ObjectType=7 +DataType=7 +AccessType=R + +[1018sub2] +ParameterName=ProductCode +ObjectType=7 +DataType=7 +AccessType=R + +[1018sub3] +ParameterName=RevisionNumber +ObjectType=7 +DataType=7 +AccessType=R + +[1018sub4] +ParameterName=SerialNumber +ObjectType=7 +DataType=7 +AccessType=R + +[3000] +ParameterName=Firmware +ObjectType=9 + +[3000sub0] +ParameterName=Firmware Max Index +ObjectType=7 +DataType=5 +AccessType=R +DefaultValue=0 + +[3000sub1] +ParameterName=Firmware Command +ObjectType=7 +DataType=7 +AccessType=RW +DefaultValue=0 + +[3000sub2] +ParameterName=Firmware Size +ObjectType=7 +DataType=7 +AccessType=RW +DefaultValue=0 + +[3000sub3] +ParameterName=Firmware MD5 +ObjectType=7 +DataType=0xf +AccessType=W + +[3000sub4] +ParameterName=Firmware Data +ObjectType=7 +DataType=0xf +AccessType=W + +[3000sub5] +ParameterName=Firmware Flags +ObjectType=7 +DataType=7 +AccessType=R + diff --git a/test/test_can.rb b/test/test_can.rb index 0da0658..558041b 100644 --- a/test/test_can.rb +++ b/test/test_can.rb @@ -67,6 +67,7 @@ class CanTest < Minitest::Test 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]) assert_equal [3, 4], store.snapshot(since: 2)[:log].map { |f| f[:seq] } + assert_equal [[], 4], store.snapshot(since: 99).values_at(:log, :log_seq) assert_equal "3081" "11", store.snapshot(since: 3)[:log].first[:data] end diff --git a/views/_debug_nav.erb b/views/_debug_nav.erb index e75e2fa..96b9ca4 100644 --- a/views/_debug_nav.erb +++ b/views/_debug_nav.erb @@ -1,4 +1,4 @@ -<%# The debug pages' switcher, on top of each (status, CAN, GNSS simulation). %> +<%# The debug pages' switcher, on top of each (status, CAN, CAN trace, GNSS simulation). %>