diff --git a/FprimeZephyrReference/Components/CMakeLists.txt b/FprimeZephyrReference/Components/CMakeLists.txt index 69f8c33e..10c9dad2 100644 --- a/FprimeZephyrReference/Components/CMakeLists.txt +++ b/FprimeZephyrReference/Components/CMakeLists.txt @@ -1,4 +1,4 @@ # Include project-wide components here add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler") -add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Led") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog") diff --git a/FprimeZephyrReference/Components/Led/Led.cpp b/FprimeZephyrReference/Components/Led/Led.cpp deleted file mode 100644 index 7fbdde09..00000000 --- a/FprimeZephyrReference/Components/Led/Led.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// ====================================================================== -// \title Led.cpp -// \author ortega -// \brief cpp file for Led component implementation class -// ====================================================================== - -#include "FprimeZephyrReference/Components/Led/Led.hpp" -#include "config/FpConfig.hpp" - -namespace Components { - -// ---------------------------------------------------------------------- -// Component construction and destruction -// ---------------------------------------------------------------------- - -Led ::Led(const char* const compName) : LedComponentBase(compName) {} - -Led ::~Led() {} - -// ---------------------------------------------------------------------- -// Handler implementations for user-defined typed input ports -// ---------------------------------------------------------------------- - -void Led ::run_handler(FwIndexType portNum, U32 context) { - U32 interval = this->m_blinkInterval; // Get the blink interval from the member variable - - // Only perform actions when set to blinking - if (this->m_blinking && (interval != 0)) { - // If toggling state - if (this->m_toggleCounter == 0) { - // Toggle state - this->m_state = (this->m_state == Fw::On::ON) ? Fw::On::OFF : Fw::On::ON; - this->m_transitions++; - this->tlmWrite_LedTransitions(this->m_transitions); - - // Port may not be connected, so check before sending output - if (this->isConnected_gpioSet_OutputPort(0)) { - this->gpioSet_out(0, (Fw::On::ON == this->m_state) ? Fw::Logic::HIGH : Fw::Logic::LOW); - } - - this->log_ACTIVITY_LO_LedState(this->m_state); - } - - this->m_toggleCounter = (this->m_toggleCounter + 1) % interval; - } - // We are not blinking - else { - if (this->m_state == Fw::On::ON) { - // Port may not be connected, so check before sending output - if (this->isConnected_gpioSet_OutputPort(0)) { - this->gpioSet_out(0, Fw::Logic::LOW); - } - - this->m_state = Fw::On::OFF; - this->log_ACTIVITY_LO_LedState(this->m_state); - } - } -} - -// ---------------------------------------------------------------------- -// Handler implementations for commands -// ---------------------------------------------------------------------- - -void Led ::BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Fw::On onOff) { - this->m_toggleCounter = 0; // Reset count on any successful command - this->m_blinking = Fw::On::ON == onOff; // Update blinking state - - this->log_ACTIVITY_HI_SetBlinkingState(onOff); - - this->tlmWrite_BlinkingState(onOff); - - // Provide command response - this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); -} - -void Led ::SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, U32 interval) { - // Update the member variable - this->m_blinkInterval = interval; - - // Log the event - this->log_ACTIVITY_HI_BlinkIntervalSet(interval); - - // Provide command response - this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); -} - -} // namespace Components diff --git a/FprimeZephyrReference/Components/Led/Led.fpp b/FprimeZephyrReference/Components/Led/Led.fpp deleted file mode 100644 index a190f6ef..00000000 --- a/FprimeZephyrReference/Components/Led/Led.fpp +++ /dev/null @@ -1,67 +0,0 @@ -module Components { - @ Component to blink an LED driven by a rate group - active component Led { - - @ Command to turn on or off the blinking LED - async command BLINKING_ON_OFF( - onOff: Fw.On @< Indicates whether the blinking should be on or off - ) - - @ Command to set the LED blink interval - async command SET_BLINK_INTERVAL( - interval: U32 @< Blink interval in rate group ticks - ) - - @ Telemetry channel to report blinking state. - telemetry BlinkingState: Fw.On - - @ Telemetry channel counting LED transitions - telemetry LedTransitions: U64 - - @ Reports the state we set to blinking. - event SetBlinkingState($state: Fw.On) \ - severity activity high \ - format "Set blinking state to {}." - - @ Event logged when the LED turns on or off - event LedState(onOff: Fw.On) \ - severity activity low \ - format "LED is {}" - - @ Event logged when the LED blink interval is updated - event BlinkIntervalSet(interval: U32) \ - severity activity high \ - format "LED blink interval set to {}" - - @ Port receiving calls from the rate group - async input port run: Svc.Sched - - @ Port sending calls to the GPIO driver - output port gpioSet: Drv.GpioWrite - - ############################################################################### - # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # - ############################################################################### - @ Port for requesting the current time - time get port timeCaller - - @ Port for sending command registrations - command reg port cmdRegOut - - @ Port for receiving commands - command recv port cmdIn - - @ Port for sending command responses - command resp port cmdResponseOut - - @ Port for sending textual representation of events - text event port logTextOut - - @ Port for sending events to downlink - event port logOut - - @ Port for sending telemetry channels to downlink - telemetry port tlmOut - - } -} diff --git a/FprimeZephyrReference/Components/Led/Led.hpp b/FprimeZephyrReference/Components/Led/Led.hpp deleted file mode 100644 index f24cd3b2..00000000 --- a/FprimeZephyrReference/Components/Led/Led.hpp +++ /dev/null @@ -1,71 +0,0 @@ -// ====================================================================== -// \title Led.hpp -// \author ortega -// \brief hpp file for Led component implementation class -// ====================================================================== - -#ifndef Components_Led_HPP -#define Components_Led_HPP - -#include "FprimeZephyrReference/Components/Led/LedComponentAc.hpp" - -namespace Components { - -class Led : public LedComponentBase { - public: - // ---------------------------------------------------------------------- - // Component construction and destruction - // ---------------------------------------------------------------------- - - //! Construct Led object - Led(const char* const compName //!< The component name - ); - - //! Destroy Led object - ~Led(); - - private: - // ---------------------------------------------------------------------- - // Handler implementations for user-defined typed input ports - // ---------------------------------------------------------------------- - - //! Handler implementation for run - //! - //! Port receiving calls from the rate group - void run_handler(FwIndexType portNum, //!< The port number - U32 context //!< The call order - ) override; - - private: - // ---------------------------------------------------------------------- - // Handler implementations for commands - // ---------------------------------------------------------------------- - - //! Handler implementation for command BLINKING_ON_OFF - //! - //! Command to turn on or off the blinking LED - void BLINKING_ON_OFF_cmdHandler(FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - Fw::On onOff //!< Indicates whether the blinking should be on or off - ) override; - - //! Handler implementation for command SET_BLINK_INTERVAL - //! - //! Command to set the LED blink interval - void SET_BLINK_INTERVAL_cmdHandler(FwOpcodeType opCode, //!< The opcode - U32 cmdSeq, //!< The command sequence number - U32 interval //!< Blink interval in rate group ticks - ) override; - - Fw::On m_state = Fw::On::OFF; //! Keeps track if LED is on or off - U64 m_transitions = 0; //! The number of on/off transitions that have occurred - //! from FSW boot up - U32 m_toggleCounter = 0; //! Keeps track of how many ticks the LED has been on for - bool m_blinking = false; //! Flag: if true then LED blinking will occur else - //! no blinking will happen - U32 m_blinkInterval = 10; //! Blink interval in rate group ticks (FIX FOR ZEPHYR) -}; - -} // namespace Components - -#endif diff --git a/FprimeZephyrReference/Components/Led/CMakeLists.txt b/FprimeZephyrReference/Components/Watchdog/CMakeLists.txt similarity index 87% rename from FprimeZephyrReference/Components/Led/CMakeLists.txt rename to FprimeZephyrReference/Components/Watchdog/CMakeLists.txt index 9b5d865d..8cbd3a3b 100644 --- a/FprimeZephyrReference/Components/Led/CMakeLists.txt +++ b/FprimeZephyrReference/Components/Watchdog/CMakeLists.txt @@ -16,9 +16,9 @@ register_fprime_library( AUTOCODER_INPUTS - "${CMAKE_CURRENT_LIST_DIR}/Led.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Watchdog.fpp" SOURCES - "${CMAKE_CURRENT_LIST_DIR}/Led.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Watchdog.cpp" # DEPENDS # MyPackage_MyOtherModule ) diff --git a/FprimeZephyrReference/Components/Watchdog/Watchdog.cpp b/FprimeZephyrReference/Components/Watchdog/Watchdog.cpp new file mode 100644 index 00000000..106a3c73 --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/Watchdog.cpp @@ -0,0 +1,54 @@ +// ====================================================================== +// \title Watchdog.cpp +// \author moisesmata +// \brief cpp file for Watchdog component implementation class +// ====================================================================== + +#include "FprimeZephyrReference/Components/Watchdog/Watchdog.hpp" +#include "config/FpConfig.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Watchdog ::Watchdog(const char* const compName) : WatchdogComponentBase(compName) {} + +Watchdog ::~Watchdog() {} + +// ---------------------------------------------------------------------- +// Handler implementations for user-defined typed input ports +// ---------------------------------------------------------------------- + +void Watchdog ::run_handler(FwIndexType portNum, U32 context) { + // Only perform actions when stop not requested + if (!this->m_stopRequested) { + // Toggle state every rate group call + this->m_state = (this->m_state == Fw::On::ON) ? Fw::On::OFF : Fw::On::ON; + this->m_transitions++; + this->tlmWrite_WatchdogTransitions(this->m_transitions); + + this->gpioSet_out(0, (Fw::On::ON == this->m_state) ? Fw::Logic::HIGH : Fw::Logic::LOW); + } +} + +void Watchdog ::stop_handler(FwIndexType portNum) { + // Set the stop flag to stop watchdog petting + this->m_stopRequested = true; + this->log_ACTIVITY_HI_WatchdogStop(); +} + +// ---------------------------------------------------------------------- +// Handler implementations for commands +// ---------------------------------------------------------------------- + +void Watchdog ::TEST_STOP_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) { + // call stop handler + this->stop_handler(0); + + // Provide command response + this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK); +} + +} // namespace Components diff --git a/FprimeZephyrReference/Components/Watchdog/Watchdog.fpp b/FprimeZephyrReference/Components/Watchdog/Watchdog.fpp new file mode 100644 index 00000000..d2842702 --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/Watchdog.fpp @@ -0,0 +1,51 @@ +module Components { + @ Component to blink an LED as a watchdog petter, driven by a rate group + passive component Watchdog { + + @ Command to stop the watchdog petter + sync command TEST_STOP_WATCHDOG( + ) + + @ Telemetry channel counting watchdog petter transitions + telemetry WatchdogTransitions: U32 + + @ Event logged when the watchdog petter LED turns on or off + event WatchdogStop() \ + severity activity high \ + format "Watchdog no longer being pet!" + + @ Port receiving calls from the rate group + sync input port run: Svc.Sched + + @ Port to stop the watchdog petting + sync input port stop: Fw.Signal + + @ Port sending calls to the GPIO driver + output port gpioSet: Drv.GpioWrite + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + @ Port for sending command registrations + command reg port cmdRegOut + + @ Port for receiving commands + command recv port cmdIn + + @ Port for sending command responses + command resp port cmdResponseOut + + @ Port for sending textual representation of events + text event port logTextOut + + @ Port for sending events to downlink + event port logOut + + @ Port for sending telemetry channels to downlink + telemetry port tlmOut + + } +} diff --git a/FprimeZephyrReference/Components/Watchdog/Watchdog.hpp b/FprimeZephyrReference/Components/Watchdog/Watchdog.hpp new file mode 100644 index 00000000..b81c4201 --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/Watchdog.hpp @@ -0,0 +1,62 @@ +// ====================================================================== +// \title Watchdog.hpp +// \author moisesmata +// \brief hpp file for Watchdog component implementation class +// ====================================================================== + +#ifndef Components_Watchdog_HPP +#define Components_Watchdog_HPP + +#include "FprimeZephyrReference/Components/Watchdog/WatchdogComponentAc.hpp" +// Need to explicitly include because Fw.On is no longer a tlm channel I believe +#include +#include "Fw/Types/OnEnumAc.hpp" + +namespace Components { + +class Watchdog : public WatchdogComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Watchdog object + Watchdog(const char* const compName //!< The component name + ); + + //! Destroy Watchdog object + ~Watchdog(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for user-defined typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for run + //! + //! Port receiving calls from the rate group + void run_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + //! Handler implementation for stop + //! + //! Port to stop the watchdog petting + void stop_handler(FwIndexType portNum) override; + + private: + // ---------------------------------------------------------------------- + // Handler implementations for commands + // ---------------------------------------------------------------------- + + void TEST_STOP_WATCHDOG_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) override; + + std::atomic_bool m_stopRequested{false}; //! Flag to stop the watchdog petting + Fw::On m_state = Fw::On::OFF; //! Keeps track of GPIO state + U32 m_transitions = 0; //! The number of on/off transitions that have occurred + //! from FSW boot up +}; + +} // namespace Components + +#endif diff --git a/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg b/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg new file mode 100644 index 00000000..1f807474 --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg @@ -0,0 +1 @@ +WatchdogrunstopgpioSettimeCallercmdRegOutcmdIncmdResponseOutlogTextOutlogOuttlmOut diff --git a/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg:Zone.Identifier b/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg:Zone.Identifier new file mode 100644 index 00000000..8d3a7c71 --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/docs/img/diagram.svg:Zone.Identifier @@ -0,0 +1,3 @@ +[ZoneTransfer] +ZoneId=3 +HostUrl=vscode-webview://06sutmqocciejudt1q6dk9i4j0ftrdfegqfv7aiu1ujtv9um6nfr/ diff --git a/FprimeZephyrReference/Components/Watchdog/docs/sdd.md b/FprimeZephyrReference/Components/Watchdog/docs/sdd.md new file mode 100644 index 00000000..32efcb2f --- /dev/null +++ b/FprimeZephyrReference/Components/Watchdog/docs/sdd.md @@ -0,0 +1,54 @@ +# Components::Watchdog Component + +## 1. Introduction + +The `Components::Watchdog` component provides the mechanism to "pet" the physical watchdog circuit on the PROVES FC Board and provides a visual indicator by blinking an LED at a fixed interval. The component is driven by a rate group and oscillates the watchdog GPIO every rategroup tick. + +## 2. Requirements + +The requirements for `Components::Watchdog` are as follows: + +Requirement | Description | Verification Method | Verified? +----------- | ----------- | ------------------- | --------- +WD-001 | The `Components::Watchdog` component shall activate upon startup. | Inspection | Yes +WD-002 | The `Components::Watchdog` component shall oscillate the watchdog GPIO pin (24) on/off on each rategroup tick. | Inspection | Yes +WD-003 | The `Components::Watchdog` component shall provide telemetry for watchdog transition count. | Integration Test | In Progress +WD-004 | The `Components::Watchdog` component shall respond to stop signals to halt the watchdog petting. | Integration Test | Yes +WD-005 | The `Components::Watchdog` component shall provide a test command to stop the watchdog petting. | Integration Test | Yes +WD-006 | The `Components::Watchdog` component shall emit an event when the watchdog petting stops. | Integration Test | Yes + +## 3. Design + +### 3.1 Context + +#### 3.1.1 Component Diagram + +The `Components::Watchdog` component has the following component diagram: + +![`Components::Watchdog` Diagram](img/diagram.svg) + +#### 3.1.2 Ports + +Port Data Type | Name | Direction | Kind | Usage +-------------- | ---- | --------- | ---- | ----- +[`Svc::Sched`]| run | Input | Synchronous | Receive periodic calls from rate group +[`Fw::Signal`]| stop | Input | Synchronous | Receive stop signal to stop watchdog petter +[`Drv::GpioWrite`]| gpioSet | Output | n/a | Control GPIO state through driver + +#### 3.1.3 Commands + +Name | Kind | Description +---- | ---- | ----- +TEST_STOP_WATCHDOG | Synchronous | calls the port `stop_runhandler` to stop the watchdog petter. + +#### 3.1.4 Events + +Name | Description +---- | ----- +WatchdogStop | Emits once the watchdog petting has stopped. . + +#### 3.1.5 Telemetry + +Name | Type | Description +---- | ---- | ----- +WatchdogTransitions | U32 | Number of times the GPIO has oscillated from on/off during watchdog petting diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/CMakeLists.txt b/FprimeZephyrReference/ReferenceDeployment/Top/CMakeLists.txt index 1204d230..d84487ac 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/CMakeLists.txt +++ b/FprimeZephyrReference/ReferenceDeployment/Top/CMakeLists.txt @@ -14,6 +14,7 @@ register_fprime_module( AUTOCODER_INPUTS "${CMAKE_CURRENT_LIST_DIR}/instances.fpp" "${CMAKE_CURRENT_LIST_DIR}/topology.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ReferenceDeploymentPackets.fppi" SOURCES "${CMAKE_CURRENT_LIST_DIR}/ReferenceDeploymentTopology.cpp" DEPENDS diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi index 4215d626..fc1846de 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi +++ b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentPackets.fppi @@ -31,8 +31,7 @@ telemetry packets ReferenceDeploymentPackets { } packet Led id 5 group 4 { - ReferenceDeployment.led.LedTransitions - ReferenceDeployment.led.BlinkingState + ReferenceDeployment.watchdog.WatchdogTransitions } diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp index b450324b..3912dbb4 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/ReferenceDeploymentTopologyDefs.hpp @@ -53,6 +53,9 @@ enum { WARN = 3, FATAL = 5 }; namespace ReferenceDeployment_rateGroup1Hz { enum { WARN = 3, FATAL = 5 }; } +namespace ReferenceDeployment_prmDb { +enum { WARN = 3, FATAL = 5 }; +} } // namespace PingEntries // Definitions are placed within a namespace named after the deployment diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp index 8f3f7fb1..d3bce3e6 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/instances.fpp @@ -36,10 +36,10 @@ module ReferenceDeployment { stack size Default.STACK_SIZE \ priority 4 - instance led: Components.Led base id 0x10003000 \ + instance prmDb: Svc.PrmDb base id 0x10003000 \ queue size Default.QUEUE_SIZE \ stack size Default.STACK_SIZE \ - priority 5 + priority 6 # ---------------------------------------------------------------------- # Queued component instances @@ -62,4 +62,5 @@ module ReferenceDeployment { instance gpioDriver: Zephyr.ZephyrGpioDriver base id 0x10015000 + instance watchdog: Components.Watchdog base id 0x10016000 } diff --git a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp index 02cba056..f1946b87 100644 --- a/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp +++ b/FprimeZephyrReference/ReferenceDeployment/Top/topology.fpp @@ -27,7 +27,8 @@ module ReferenceDeployment { instance timer instance comDriver instance gpioDriver - instance led + instance watchdog + instance prmDb # ---------------------------------------------------------------------- # Pattern graph specifiers @@ -39,6 +40,7 @@ module ReferenceDeployment { health connections instance CdhCore.$health time connections instance chronoTime telemetry connections instance CdhCore.tlmSend + param connections instance prmDb # ---------------------------------------------------------------------- # Telemetry packets (only used when TlmPacketizer is used) @@ -89,13 +91,11 @@ module ReferenceDeployment { rateGroup1Hz.RateGroupMemberOut[1] -> CdhCore.$health.Run rateGroup1Hz.RateGroupMemberOut[2] -> ComCcsds.commsBufferManager.schedIn rateGroup1Hz.RateGroupMemberOut[3] -> CdhCore.tlmSend.Run + rateGroup1Hz.RateGroupMemberOut[4] -> watchdog.run } - connections LedBlinker { - # Rate Group 1 (1Hz cycle) output is connected to led's run input - rateGroup1Hz.RateGroupMemberOut[4] -> led.run - # led's gpioSet output is connected to gpioDriver's gpioWrite input - led.gpioSet -> gpioDriver.gpioWrite + connections Watchdog { + watchdog.gpioSet -> gpioDriver.gpioWrite } connections ReferenceDeployment { diff --git a/FprimeZephyrReference/test/int/README.md b/FprimeZephyrReference/test/int/README.md new file mode 100644 index 00000000..55debf97 --- /dev/null +++ b/FprimeZephyrReference/test/int/README.md @@ -0,0 +1,7 @@ +### To run Integration Tests: + +First, start GDS with: + + +Run Integration Test: +pytest integration_test.py --deployment ../../../build-artifacts/zephyr/fprime-zephyr-deployment diff --git a/FprimeZephyrReference/test/int/integration_test.py b/FprimeZephyrReference/test/int/integration_test.py new file mode 100644 index 00000000..48fdd32c --- /dev/null +++ b/FprimeZephyrReference/test/int/integration_test.py @@ -0,0 +1,64 @@ +""" +integration_test.py: + +Simple integration tests for the Watchdog component. +Tests are ordered so that stop tests run last. +""" + +def get_watchdog_transitions(fprime_test_api): + """Helper function to request packet and get fresh WatchdogTransitions telemetry""" + fprime_test_api.clear_histories() + fprime_test_api.send_and_assert_command("CdhCore.tlmSend.SEND_PKT", ["5"], max_delay=2) + result = fprime_test_api.assert_telemetry( + "ReferenceDeployment.watchdog.WatchdogTransitions", + start="NOW", timeout=3 + ) + return result.get_val() + + +def test_01_watchdog_telemetry_basic(fprime_test_api): + """Test that we can read WatchdogTransitions telemetry""" + value = get_watchdog_transitions(fprime_test_api) + assert value >= 0, f"WatchdogTransitions should be >= 0, got {value}" + + +def test_02_watchdog_increments(fprime_test_api): + """Test that WatchdogTransitions increments over time""" + import time + + initial_value = get_watchdog_transitions(fprime_test_api) + time.sleep(2.0) # Wait for watchdog to run more cycles + updated_value = get_watchdog_transitions(fprime_test_api) + + assert updated_value > initial_value, \ + f"WatchdogTransitions should increase. Initial: {initial_value}, Updated: {updated_value}" + + +def test_03_stop_watchdog_command(fprime_test_api): + """Test TEST_STOP_WATCHDOG command sends and emits WatchdogStop event""" + fprime_test_api.clear_histories() + + fprime_test_api.send_and_assert_command( + "ReferenceDeployment.watchdog.TEST_STOP_WATCHDOG", + max_delay=2 + ) + + fprime_test_api.assert_event( + "ReferenceDeployment.watchdog.WatchdogStop", + timeout=2 + ) + + +def test_04_watchdog_stops_incrementing(fprime_test_api): + """Test that WatchdogTransitions stops incrementing after TEST_STOP_WATCHDOG""" + import time + + # Get initial value (should be from stopped watchdog from previous test) + initial_value = get_watchdog_transitions(fprime_test_api) + + # Wait and check that it's not incrementing (watchdog should already be stopped) + time.sleep(2.0) + final_value = get_watchdog_transitions(fprime_test_api) + + assert final_value == initial_value, \ + f"Watchdog should remain stopped. Initial: {initial_value}, Final: {final_value}" diff --git a/lib/fprime-zephyr b/lib/fprime-zephyr index 4a149bbe..638549d3 160000 --- a/lib/fprime-zephyr +++ b/lib/fprime-zephyr @@ -1 +1 @@ -Subproject commit 4a149bbed5c7c86fbac44ab8a65791eff97370f9 +Subproject commit 638549d3a19919490351012bd4d9eb3411320983