Skip to content

Commit

Permalink
Add watchdog component
Browse files Browse the repository at this point in the history
  • Loading branch information
nateinaction committed Oct 25, 2024
1 parent cd4eec6 commit 53d3835
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 1 deletion.
4 changes: 4 additions & 0 deletions BroncoDeployment/Top/BroncoDeploymentPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<channel name="hubComDriver.Status"/>
</packet>

<packet name="WatchdogChannels" id="9" level="1">
<channel name="watchdog.WatchdogPets"/>
</packet>

<!-- Ignored packets -->

<ignore>
Expand Down
3 changes: 3 additions & 0 deletions BroncoDeployment/Top/BroncoDeploymentTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void configureTopology() {
// Framer and Deframer components need to be passed a protocol handler
framer.setup(framing);
deframer.setup(deframing);

// Open the Watchdog GPIO pin
gpioDriver.open(21, Arduino::GpioDriver::GpioDirection::OUT);
}

// Public functions for use in main program are namespaced with deployment name BroncoDeployment
Expand Down
6 changes: 6 additions & 0 deletions BroncoDeployment/Top/instances.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ module BroncoDeployment {
stack size Default.STACK_SIZE \
priority 97

instance watchdog: Components.Watchdog base id 0x0400 \
queue size Default.QUEUE_SIZE \
stack size Default.STACK_SIZE \
priority 96

# ----------------------------------------------------------------------
# Queued component instances
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -75,4 +80,5 @@ module BroncoDeployment {
# Custom Connections

instance broncoOreMessageHandler: Components.BroncoOreMessageHandler base id 0x6000
instance gpioDriver: Arduino.GpioDriver base id 0x4C00
}
10 changes: 9 additions & 1 deletion BroncoDeployment/Top/topology.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module BroncoDeployment {
instance fatalAdapter
instance fatalHandler
instance framer
instance gpioDriver
instance rateDriver
instance rateGroup1
instance rateGroupDriver
Expand All @@ -44,6 +45,7 @@ module BroncoDeployment {

#custom instances
instance broncoOreMessageHandler
instance watchdog

# ----------------------------------------------------------------------
# Pattern graph specifiers
Expand Down Expand Up @@ -72,6 +74,9 @@ module BroncoDeployment {
rateGroup1.RateGroupMemberOut[0] -> commDriver.schedIn
rateGroup1.RateGroupMemberOut[1] -> tlmSend.Run
rateGroup1.RateGroupMemberOut[2] -> systemResources.run

# Rate Group 1 (1Hz cycle) ouput is connected to watchdog's run input
rateGroup1.RateGroupMemberOut[3] -> watchdog.run
}
connections FaultProtection {
Expand Down Expand Up @@ -107,7 +112,10 @@ module BroncoDeployment {
connections BroncoDeployment {
# Add here connections to user-defined components
broncoOreMessageHandler.send_message -> hub.portIn[0]
hub.portOut[0] -> broncoOreMessageHandler.recv_message
hub.portOut[0] -> broncoOreMessageHandler.recv_message
# watchdog's gpioSet output is connected to gpioDriver's gpioWrite input
watchdog.gpioSet -> gpioDriver.gpioWrite
}
connections HubConnections {
Expand Down
1 change: 1 addition & 0 deletions Components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BroncoOreMessageHandler/")

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Radio/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog/")
14 changes: 14 additions & 0 deletions Components/WatchDog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
####
# F prime CMakeLists.txt:
#
# SOURCE_FILES: combined list of source and autocoding files
# MOD_DEPS: (optional) module dependencies
# UT_SOURCE_FILES: list of source files for unit tests
#
####
set(SOURCE_FILES
"${CMAKE_CURRENT_LIST_DIR}/Watchdog.fpp"
"${CMAKE_CURRENT_LIST_DIR}/Watchdog.cpp"
)

register_fprime_module()
34 changes: 34 additions & 0 deletions Components/WatchDog/WatchDog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ======================================================================
// \title Watchdog.cpp
// \author nateinaction
// \brief cpp file for Watchdog component implementation class
// ======================================================================

#include "Components/Watchdog/Watchdog.hpp"
#include "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(NATIVE_INT_TYPE portNum, NATIVE_UINT_TYPE context) {
// TODO (nateinaction): Convet this to use the gpio output port when it works...
digitalWrite(21, (this->cycle_count % 2) == 0 ? HIGH : LOW);

this->pet_count += (this->cycle_count % 2) == 0 ? 1 : 0;
this->tlmWrite_WatchdogPets(pet_count);

this->cycle_count += 1;
}

} // namespace Components
29 changes: 29 additions & 0 deletions Components/WatchDog/WatchDog.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module Components {
@ Petting the Watch Dog to keep the satellite alive.
active component Watchdog {

@ 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

@ Telemetry channel to report watchdog pet count.
telemetry WatchdogPets: U64

###############################################################################
# Standard AC Ports: Required for Channels, Events, Commands, and Parameters #
###############################################################################
@ Port for requesting the current time
time get port timeCaller

@ 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
}
}
47 changes: 47 additions & 0 deletions Components/WatchDog/WatchDog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// ======================================================================
// \title Watchdog.hpp
// \author nate
// \brief hpp file for Watchdog component implementation class
// ======================================================================

#ifndef Components_Watchdog_HPP
#define Components_Watchdog_HPP

#include "Components/Watchdog/WatchdogComponentAc.hpp"
#include <Arduino.h>

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(NATIVE_INT_TYPE portNum, //!< The port number
NATIVE_UINT_TYPE context //!< The call order
) override;

PRIVATE:
U64 pet_count = 0;
U64 cycle_count = 0;
};

} // namespace Components

#endif
66 changes: 66 additions & 0 deletions Components/WatchDog/docs/sdd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Components::Watchdog

Petting the Watch Dog to keep the satellite alive.

## Usage Examples
Add usage examples here

### Diagrams
Add diagrams here

### Typical Usage
And the typical usage of the component here

## Class Diagram
Add a class diagram here

## Port Descriptions
| Name | Description |
|---|---|
|---|---|

## Component States
Add component states in the chart below
| Name | Description |
|---|---|
|---|---|

## Sequence Diagrams
Add sequence diagrams here

## Parameters
| Name | Description |
|---|---|
|---|---|

## Commands
| Name | Description |
|---|---|
|---|---|

## Events
| Name | Description |
|---|---|
|---|---|

## Telemetry
| Name | Description |
|---|---|
|---|---|

## Unit Tests
Add unit test descriptions in the chart below
| Name | Description | Output | Coverage |
|---|---|---|---|
|---|---|---|---|

## Requirements
Add requirements in the chart below
| Name | Description | Validation |
|---|---|---|
|---|---|---|

## Change Log
| Date | Description |
|---|---|
|---| Initial Draft |

0 comments on commit 53d3835

Please sign in to comment.