Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watchdog component #45

Merged
merged 3 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ jobs:
- uses: fprime-community/project-builder@main
with:
build_location: BroncoDeployment
target_platform: rpipico
- name: Archive binary
uses: actions/upload-artifact@v4
with:
Expand Down
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