Skip to content
Closed
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
2 changes: 2 additions & 0 deletions FprimeZephyrReference/Components/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Include project-wide components here

add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Drv/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComDelay/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/FatalHandler")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ImuManager/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/NullPrmDb/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Watchdog")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/BootloaderTrigger/")
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/ComDelay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/ComDelay.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/ComDelay.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/ComDelay.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/ComDelayTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/ComDelayTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
70 changes: 70 additions & 0 deletions FprimeZephyrReference/Components/ComDelay/ComDelay.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// ======================================================================
// \title ComDelay.cpp
// \author starchmd
// \brief cpp file for ComDelay component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/ComDelay/ComDelay.hpp"
#include "FprimeZephyrReference/Components/ComDelay/FppConstantsAc.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

ComDelay ::ComDelay(const char* const compName)
: ComDelayComponentBase(compName), m_last_status_valid(false), m_last_status(Fw::Success::FAILURE) {}

ComDelay ::~ComDelay() {}

void ComDelay ::parameterUpdated(FwPrmIdType id) {
switch (id) {
case ComDelay::PARAMID_DIVIDER: {
Fw::ParamValid is_valid;
U8 new_divider = this->paramGet_DIVIDER(is_valid);
if ((is_valid != Fw::ParamValid::INVALID) && (is_valid != Fw::ParamValid::UNINIT)) {
this->log_ACTIVITY_HI_DividerSet(new_divider);
}
} break;
default:
FW_ASSERT(0);
break; // Fallthrough from assert (static analysis)
}
}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

void ComDelay ::comStatusIn_handler(FwIndexType portNum, Fw::Success& condition) {
this->m_last_status = condition;
this->m_last_status_valid = true;
}

void ComDelay ::run_handler(FwIndexType portNum, U32 context) {
// On the cycle after the tick count is reset, attempt to output any current com status
if (this->m_tick_count == 0) {
bool expected = true;
// Receive the current "last status" validity flag and atomically exchange it with false. This effectively
// "consumes" a valid status. When valid, the last status is sent out.
bool valid = this->m_last_status_valid.compare_exchange_strong(expected, false);
if (valid) {
this->comStatusOut_out(0, this->m_last_status);
}
}

// Unless there is corruption, the parameter should always be valid via its default value; however, in the interest
// of failing-safe and continuing some sort of communication we default the current_divisor to the default value.
Fw::ParamValid is_valid;
U8 current_divisor = this->paramGet_DIVIDER(is_valid);

// Increment and module the tick count by the divisor
if ((is_valid == Fw::ParamValid::INVALID) || (is_valid == Fw::ParamValid::UNINIT)) {
current_divisor = Components::DEFAULT_DIVIDER;
}
// Count this new tick, resetting whenever the current count is at or higher than the current divider.
this->m_tick_count = (this->m_tick_count >= current_divisor) ? 0 : this->m_tick_count + 1;
}

} // namespace Components
48 changes: 48 additions & 0 deletions FprimeZephyrReference/Components/ComDelay/ComDelay.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module Components {
constant DEFAULT_DIVIDER = 30
@ A component to delay com status until some further point
passive component ComDelay {
@ Rate schedule port used to trigger radio transmission
sync input port run: Svc.Sched

@ Input comStatus from radio component
sync input port comStatusIn: Fw.SuccessCondition

@ Output comStatus to be called on rate group
output port comStatusOut: Fw.SuccessCondition

@ Divider of the incoming rate tick
param DIVIDER: U8 default DEFAULT_DIVIDER # Start slow i.e. on a 1S tick, transmit every 30S

@ Divider set event
event DividerSet(divider: U8) severity activity high \
format "Set divider to: {}"

###############################################################################
# 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 to return the value of a parameter
param get port prmGetOut

@Port to set the value of a parameter
param set port prmSetOut
}
}
61 changes: 61 additions & 0 deletions FprimeZephyrReference/Components/ComDelay/ComDelay.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// ======================================================================
// \title ComDelay.hpp
// \author starchmd
// \brief hpp file for ComDelay component implementation class
// ======================================================================

#ifndef Components_ComDelay_HPP
#define Components_ComDelay_HPP

#include <atomic>
#include "FprimeZephyrReference/Components/ComDelay/ComDelayComponentAc.hpp"

namespace Components {

class ComDelay final : public ComDelayComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct ComDelay object
ComDelay(const char* const compName //!< The component name
);

//! Destroy ComDelay object
~ComDelay();

private:
void parameterUpdated(FwPrmIdType id //!< The parameter ID
) override;

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for comStatusIn
//!
//! Input comStatus from radio component
void comStatusIn_handler(FwIndexType portNum, //!< The port number
Fw::Success& condition //!< Condition success/failure
) override;

//! Handler implementation for run
//!
//! Rate schedule port used to trigger radio transmission
void run_handler(FwIndexType portNum, //!< The port number
U32 context //!< The call order
) override;

private:
//! Count of incoming run ticks
U8 m_tick_count;
//! Stores if the last status is currently valid
std::atomic<bool> m_last_status_valid;
//! Stores the last status
Fw::Success m_last_status;
};

} // namespace Components

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

`Components::ComDelay` is a parameterized rate group schedule divider. On the initial run invocation and on each multiple of the divider thereafter any received com status is sent out. This effectively delays the com status until the next (divided) run call.

# 1 Requirements

| Requirement ID | Description | Validation |
|----------------|----------------------------------------------------------------------|------------|
| COM_DELAY_001 | The `Svc::ComDelay` component shall accept com status in. | Unit-Test |
| COM_DELAY_002 | The `Svc::ComDelay` component shall emit com status once for each DIVIDER number of rate group ticks. | Unit-Test |
| COM_DELAY_003 | The `Svc::ComDelay` component shall set the DIVIDER via a parameter. | Unit-Test |

# 2 Parameters

| Name | Description |
|---------|-----------------------------------------------------------|
| DIVIDER | Number of rate group ticks received before sending status |
36 changes: 36 additions & 0 deletions FprimeZephyrReference/Components/NullPrmDb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
####
# F Prime CMakeLists.txt:
#
# SOURCES: list of source files (to be compiled)
# AUTOCODER_INPUTS: list of files to be passed to the autocoders
# DEPENDS: list of libraries that this module depends on
#
# More information in the F´ CMake API documentation:
# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/
#
####

# Module names are derived from the path from the nearest project/library/framework
# root when not specifically overridden by the developer. i.e. The module defined by
# `Ref/SignalGen/CMakeLists.txt` will be named `Ref_SignalGen`.

register_fprime_library(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/NullPrmDb.fpp"
SOURCES
"${CMAKE_CURRENT_LIST_DIR}/NullPrmDb.cpp"
# DEPENDS
# MyPackage_MyOtherModule
)

### Unit Tests ###
# register_fprime_ut(
# AUTOCODER_INPUTS
# "${CMAKE_CURRENT_LIST_DIR}/NullPrmDb.fpp"
# SOURCES
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/NullPrmDbTestMain.cpp"
# "${CMAKE_CURRENT_LIST_DIR}/test/ut/NullPrmDbTester.cpp"
# DEPENDS
# STest # For rules-based testing
# UT_AUTO_HELPERS
# )
29 changes: 29 additions & 0 deletions FprimeZephyrReference/Components/NullPrmDb/NullPrmDb.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// ======================================================================
// \title NullPrmDb.cpp
// \author starchmd
// \brief cpp file for NullPrmDb component implementation class
// ======================================================================

#include "FprimeZephyrReference/Components/NullPrmDb/NullPrmDb.hpp"

namespace Components {

// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

NullPrmDb ::NullPrmDb(const char* const compName) : NullPrmDbComponentBase(compName) {}

NullPrmDb ::~NullPrmDb() {}

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

Fw::ParamValid NullPrmDb ::getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {
return Fw::ParamValid::INVALID;
}

void NullPrmDb ::setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer& val) {}

} // namespace Components
10 changes: 10 additions & 0 deletions FprimeZephyrReference/Components/NullPrmDb/NullPrmDb.fpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Components {
@ Null parameter database
passive component NullPrmDb {
@ Port to get parameter values
sync input port getPrm: Fw.PrmGet

@ Port to update parameters
sync input port setPrm: Fw.PrmSet
}
}
52 changes: 52 additions & 0 deletions FprimeZephyrReference/Components/NullPrmDb/NullPrmDb.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ======================================================================
// \title NullPrmDb.hpp
// \author starchmd
// \brief hpp file for NullPrmDb component implementation class
// ======================================================================

#ifndef Components_NullPrmDb_HPP
#define Components_NullPrmDb_HPP

#include "FprimeZephyrReference/Components/NullPrmDb/NullPrmDbComponentAc.hpp"

namespace Components {

class NullPrmDb final : public NullPrmDbComponentBase {
public:
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------

//! Construct NullPrmDb object
NullPrmDb(const char* const compName //!< The component name
);

//! Destroy NullPrmDb object
~NullPrmDb();

private:
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for getPrm
//!
//! Port to get parameter values
Fw::ParamValid getPrm_handler(FwIndexType portNum, //!< The port number
FwPrmIdType id, //!< Parameter ID
Fw::ParamBuffer& val //!< Buffer containing serialized parameter value.
//!< Unmodified if param not found.
) override;

//! Handler implementation for setPrm
//!
//! Port to update parameters
void setPrm_handler(FwIndexType portNum, //!< The port number
FwPrmIdType id, //!< Parameter ID
Fw::ParamBuffer& val //!< Buffer containing serialized parameter value
) override;
};

} // namespace Components

#endif
Loading
Loading