Nodes describe themselves: an SDO client (Can::Sdo) reads each esphome-canopen node's TPDOs and entities (type, name, unit, range) on its first heartbeat, cached by the TPDO layout hash, decoded with no hand-written signals — can.json keeps aliases (with unit conversion) and foreign devices; design doc (NPS planning, cockpit instruments, Unigrid band) with color tokens, the dashboard in cockpit colors; starting the simulation turns the GNSS follow on, the GNSS position an arrow by its course
This commit is contained in:
1 parent
ce290f2162
commit
e92f01db12
12 files changed
+713
-76
No files matched your search
@@ -12,6 +12,7 @@ require_relative "lib/maptool/google_saved"
|
||||
require_relative "lib/maptool/routing"
|
||||
require_relative "lib/maptool/mqtt_client"
|
||||
require_relative "lib/maptool/can"
|
||||
require_relative "lib/maptool/can_discovery"
|
||||
require_relative "lib/maptool/gnss_sim"
|
||||
require_relative "lib/maptool/trip"
|
||||
require_relative "lib/maptool/updater"
|
||||
@@ -431,6 +432,12 @@ module Maptool
|
||||
|
||||
if CAN_CONFIG && !test?
|
||||
decoder = CAN_DECODER
|
||||
# Our esphome-canopen nodes describe themselves over SDO (can_discovery.rb);
|
||||
# can.json's "aliases" name their signals ({"XIAO STM32C5 2.Latitude": "gnss.lat"}).
|
||||
if CAN_CONFIG.fetch("discover", true) && (interface = CAN_CONFIG.fetch("interfaces", []).first)
|
||||
Can::Discoverer.new(store: CAN_STORE, decoder: decoder, cache_dir: File.join(DATA_DIR, "can_nodes"),
|
||||
aliases: CAN_CONFIG.fetch("aliases", {}), interface: interface).start
|
||||
end
|
||||
CAN_CONFIG.fetch("interfaces", []).each do |interface|
|
||||
Thread.new do
|
||||
Can.listen(interface, decoder: decoder, store: CAN_STORE, start_nodes: CAN_CONFIG["nmt_start"]) do |values|
|
||||
@@ -1310,7 +1317,7 @@ module Maptool
|
||||
get "/api/can" do
|
||||
require_login!
|
||||
snapshot = CAN_STORE.snapshot
|
||||
units = (CAN_CONFIG || {}).fetch("signals", []).to_h { |signal| [signal["name"], signal["unit"]] }
|
||||
units = CAN_DECODER ? CAN_DECODER.units : {}
|
||||
snapshot[:signals] = snapshot[:signals].to_h { |name, signal| [name, units[name] ? signal.merge(unit: units[name]) : signal] }
|
||||
json snapshot.merge(available: !CAN_CONFIG.nil?)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user