From 6bfd21d135eaff95569ed64de8f6bed643b1e845 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sat, 5 Sep 2026 20:40:14 +0000 Subject: [PATCH] hardware protocol v2: answer a subscription with current state The snapshot sent right after SUBSCRIBE was taken from the previous frame, which on the first frame of a session meant every value came back as UNAVAILABLE. The link now publishes the state of the current frame before the received frames are processed. --- hardware/hardware_manager.cpp | 3 +++ hardware/protocol/protocol_session.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/hardware/hardware_manager.cpp b/hardware/hardware_manager.cpp index a2443aa1..0254dce2 100644 --- a/hardware/hardware_manager.cpp +++ b/hardware/hardware_manager.cpp @@ -202,6 +202,9 @@ void hardware_link::update( double const Deltatime, state_snapshot const &Snapsh m_lastframeerrors = counters; m_session.add_frame_errors( delta ); + // the session answers a subscription with an immediate snapshot, so it needs the current state first + m_session.set_snapshot( Snapshot ); + for( auto const &packet : packets ) { m_session.handle_packet( packet ); diff --git a/hardware/protocol/protocol_session.h b/hardware/protocol/protocol_session.h index 04beee51..f46cf90b 100644 --- a/hardware/protocol/protocol_session.h +++ b/hardware/protocol/protocol_session.h @@ -49,6 +49,8 @@ public: void reset(); // consumes one decoded frame void handle_packet( decoded_packet const &Packet ); + // publishes the state of the current simulation frame, before the received frames are processed + void set_snapshot( state_snapshot const &Snapshot ) { m_snapshot = Snapshot; } // periodic work: heartbeats, subscription updates, timeouts void update( double const Deltatime, state_snapshot const &Snapshot ); // copies the current condition into the debug report