From 90f270141a1858559de7061f1b0cb08879fba6a1 Mon Sep 17 00:00:00 2001 From: caila-marashaj Date: Tue, 3 Dec 2024 13:54:07 -0500 Subject: [PATCH] move msg back to motormessage queue, simulator fixes --- stm32-modules/heater-shaker/simulator/motor_thread.cpp | 8 ++++++++ .../include/heater-shaker/heater-shaker/motor_task.hpp | 2 +- .../thermocycler-gen2/simulator/motor_thread.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/stm32-modules/heater-shaker/simulator/motor_thread.cpp b/stm32-modules/heater-shaker/simulator/motor_thread.cpp index bd7d3cc9f..ac3e1fcf6 100644 --- a/stm32-modules/heater-shaker/simulator/motor_thread.cpp +++ b/stm32-modules/heater-shaker/simulator/motor_thread.cpp @@ -109,6 +109,12 @@ struct SimMotorPolicy { } } + auto last_reset_reason() -> uint16_t { return reset_reason; } + + auto set_last_reset_reason(uint16_t sim_reason) -> void { + reset_reason = sim_reason; + } + private: int16_t rpm_setpoint = 0; int16_t rpm_current = 0; @@ -116,6 +122,8 @@ struct SimMotorPolicy { float sim_plate_lock_power = 0; bool sim_plate_lock_enabled = false; bool sim_plate_lock_braked = false; + // Simulated reset reason from HAL RCC flag + uint16_t reset_reason = 0; }; struct motor_thread::TaskControlBlock { diff --git a/stm32-modules/include/heater-shaker/heater-shaker/motor_task.hpp b/stm32-modules/include/heater-shaker/heater-shaker/motor_task.hpp index 6cb081a0d..f74e84136 100644 --- a/stm32-modules/include/heater-shaker/heater-shaker/motor_task.hpp +++ b/stm32-modules/include/heater-shaker/heater-shaker/motor_task.hpp @@ -538,7 +538,7 @@ class MotorTask { auto response = messages::GetResetReasonResponse{ .responding_to_id = msg.id, .reason = reason}; - static_cast(_task_registry->comms->get_message_queue().try_send( + static_cast(task_registry->comms->get_message_queue().try_send( messages::HostCommsMessage(response))); } diff --git a/stm32-modules/thermocycler-gen2/simulator/motor_thread.cpp b/stm32-modules/thermocycler-gen2/simulator/motor_thread.cpp index 70c7868d8..1733f627f 100644 --- a/stm32-modules/thermocycler-gen2/simulator/motor_thread.cpp +++ b/stm32-modules/thermocycler-gen2/simulator/motor_thread.cpp @@ -119,6 +119,12 @@ class SimMotorPolicy : public SimTMC2130Policy { auto seal_switches_are_shared() -> bool { return false; } + auto last_reset_reason() -> uint16_t { return reset_reason; } + + auto set_last_reset_reason(uint16_t sim_reason) -> void { + reset_reason = sim_reason; + } + private: // Lowest position the lid can move before stalling static constexpr uint32_t min_lid_steps = @@ -132,6 +138,8 @@ class SimMotorPolicy : public SimTMC2130Policy { static constexpr double open_switch_pos_angle = 90.0F; // Simulated width of each lid switch in degrees static constexpr double switch_width_angle = 1.0F; + // Simulated reset reason from HAL RCC flag + uint16_t reset_reason = 0; // Check if open switch is triggered [[nodiscard]] static auto open_switch_triggered(double angle) -> bool {