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
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void DetumbleManager ::systemModeChanged_handler(FwIndexType portNum, const Comp
// Handler implementations for commands
// ----------------------------------------------------------------------

void DetumbleManager ::SET_MODE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Components::DetumbleMode mode) {
void DetumbleManager ::SET_MODE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Components::DetumbleMode& mode) {
this->setMode_handler(0, mode);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DetumbleManager final : public DetumbleManagerComponentBase {
//! Command to set the operating mode
void SET_MODE_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Components::DetumbleMode mode) override;
const Components::DetumbleMode& mode) override;

public:
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void RtcManager ::timeGetPort_handler(FwIndexType portNum, Fw::Time& time) {
// Handler implementations for commands
// ----------------------------------------------------------------------

void RtcManager ::TIME_SET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Drv::TimeData t) {
void RtcManager ::TIME_SET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Drv::TimeData& t) {
// Check device readiness
if (!device_is_ready(this->m_dev)) {
// Emit device not ready event
Expand Down Expand Up @@ -188,7 +188,7 @@ void RtcManager ::parameterUpdated(FwPrmIdType id) {
this->log_ACTIVITY_HI_TimeBaseChanged(timeBase);
}

void RtcManager ::ALARM_SET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Drv::TimeData t) {
void RtcManager ::ALARM_SET_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Drv::TimeData& t) {
// retrieve info about current alarm

uint16_t mask = this->m_curr_mask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,17 @@ class RtcManager final : public RtcManagerComponentBase {
//! Handler implementation for command TIME_SET
//!
//! TIME_SET command to set the time on the RTC
void TIME_SET_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Drv::TimeData t //!< Set the time
void TIME_SET_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
const Drv::TimeData& t //!< Set the time
) override;

//! Handler implementation for command ALARM_SET
//!
//! ALARM_SET command to set an alarm on the RTC
void ALARM_SET_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Drv::TimeData t //!< Time to set the alarm for
void ALARM_SET_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
const Drv::TimeData& t //!< Time to set the alarm for
) override;

//! Handler implementation for command ALARM_CANCEL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ ModeManager ::ModeManager(const char* const compName)

ModeManager ::~ModeManager() {}

void ModeManager ::init(FwSizeType queueDepth, FwEnumStoreType instance) {
ModeManagerComponentBase::init(queueDepth, instance);
void ModeManager ::restorePersistentState() {
this->loadState();
}

Expand Down Expand Up @@ -150,7 +149,8 @@ void ModeManager ::runSafeModeSequence() {
Fw::ParamValid is_valid;
Fw::ParamString safe_mode_sequence = this->paramGet_SAFEMODE_SEQUENCE_FILE(is_valid);
FW_ASSERT(is_valid == Fw::ParamValid::VALID || is_valid == Fw::ParamValid::DEFAULT);
this->runSequence_out(0, safe_mode_sequence);
const Svc::SeqArgs no_args;
this->runSequence_out(0, safe_mode_sequence, no_args);
}

void ModeManager ::completeSequence_handler(FwIndexType portNum,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ class ModeManager : public ModeManagerComponentBase {
//! Destroy ModeManager object
~ModeManager();

//! Initialize the component
void init(FwSizeType queueDepth, //!< Queue depth for async ports
FwEnumStoreType instance = 0 //!< Instance ID
);
//! Restore persisted mode and bring the hardware in line with it
//!
//! Must be called from the topology after ports are connected and the GPIO
//! drivers are open. This does real I/O -- it drives the load switches --
//! so it cannot run from init(), which the topology calls before
//! connectComponents() and configureTopology().
void restorePersistentState();

private:
// ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion PROVESFlightControllerReference/Components/SBand/SBand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ SBand::Status SBand ::configureRadio() {
// Handler implementations for commands
// ----------------------------------------------------------------------

void SBand ::TRANSMIT_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, SBandTransmitState enabled) {
void SBand ::TRANSMIT_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const SBandTransmitState& enabled) {
// Invoke internal port to handle state change asynchronously
// This prevents concurrent access issues with m_transmit_enabled
this->deferredTransmitCmd_internalInterfaceInvoke(enabled);
Expand Down
2 changes: 1 addition & 1 deletion PROVESFlightControllerReference/Components/SBand/SBand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class SBand final : public SBandComponentBase {
//! Handler implementation for command TRANSMIT
//!
//! Start/stop transmission on the S-Band module
void TRANSMIT_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, SBandTransmitState enabled) override;
void TRANSMIT_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const SBandTransmitState& enabled) override;

private:
//! Enable receive mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,23 @@ Fw::Time StartupManager ::get_uptime() {
return time;
}

void StartupManager ::startupsequenceStarted_handler(FwIndexType portNum, const Fw::StringBase& fileName) {
void StartupManager ::startupsequenceStarted_handler(FwIndexType portNum,
const Fw::StringBase& fileName,
const Svc::SeqArgs& args) {
(void)portNum;
this->onSequenceStarted(fileName);
}

void StartupManager ::safeModeSequenceStarted_handler(FwIndexType portNum, const Fw::StringBase& fileName) {
void StartupManager ::safeModeSequenceStarted_handler(FwIndexType portNum,
const Fw::StringBase& fileName,
const Svc::SeqArgs& args) {
(void)portNum;
this->onSequenceStarted(fileName);
}

void StartupManager ::payloadSequenceStarted_handler(FwIndexType portNum, const Fw::StringBase& fileName) {
void StartupManager ::payloadSequenceStarted_handler(FwIndexType portNum,
const Fw::StringBase& fileName,
const Svc::SeqArgs& args) {
(void)portNum;
this->onSequenceStarted(fileName);
}
Expand Down Expand Up @@ -291,7 +297,8 @@ void StartupManager ::run_handler(FwIndexType portNum, U32 context) {

Fw::ParamString first_sequence = this->paramGet_STARTUP_SEQUENCE_FILE(is_valid);
FW_ASSERT(is_valid == Fw::ParamValid::VALID || is_valid == Fw::ParamValid::DEFAULT);
this->runSequence_out(0, first_sequence);
const Svc::SeqArgs no_args;
this->runSequence_out(0, first_sequence, no_args);
this->m_transmit_enable_ticks = this->paramGet_TRANSMIT_ENABLE_TICKS(is_valid);
FW_ASSERT(is_valid == Fw::ParamValid::VALID || is_valid == Fw::ParamValid::DEFAULT);
} else if (!this->m_boot_count_persisted) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ class StartupManager final : public StartupManagerComponentBase {
) override;

//! Handler implementation for startupsequenceStarted
void startupsequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName //!< The file path for start-up sequence
void startupsequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName, //!< The file path for start-up sequence
const Svc::SeqArgs& args //!< Sequence arguments
) override;

//! Handler implementation for safeModeCompleteSequence
Expand All @@ -90,8 +91,9 @@ class StartupManager final : public StartupManagerComponentBase {
) override;

//! Handler implementation for safeModeSequenceStarted
void safeModeSequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName //!< The sequence file
void safeModeSequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName, //!< The sequence file
const Svc::SeqArgs& args //!< Sequence arguments
) override;

//! Handler implementation for payloadCompleteSequence
Expand All @@ -102,8 +104,9 @@ class StartupManager final : public StartupManagerComponentBase {
) override;

//! Handler implementation for payloadSequenceStarted
void payloadSequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName //!< The sequence file
void payloadSequenceStarted_handler(FwIndexType portNum, //!< The port number
const Fw::StringBase& fileName, //!< The sequence file
const Svc::SeqArgs& args //!< Sequence arguments
) override;

//! Handler implementation for loraFirstStart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ void TcSecurityDeframer ::dataIn_handler(FwIndexType portNum, Fw::Buffer& data,
// end = last octet of the Transfer Frame Data Field (excluding Security Trailer)
// Unverified frames are forwarded with authenticated=false; the router enforces
// the reject-or-bypass policy.
data.setData(data.getData() + Ccsds355_0_B_2::kTCSecurityHeaderSize);
data.setSize(data.getSize() - Ccsds355_0_B_2::kTCSecurityHeaderSize - Ccsds355_0_B_2::kTCSecurityTrailer);
// advance() consumes the leading Security Header: it moves the offset forward and
// shrinks the size by the same amount, so only the trailer is left to trim.
data.advance(Ccsds355_0_B_2::kTCSecurityHeaderSize);
data.setSize(data.getSize() - Ccsds355_0_B_2::kTCSecurityTrailer);

this->dataOut_out(0, data, contextOut);
}
Expand All @@ -106,8 +108,10 @@ void TcSecurityDeframer ::dataReturnIn_handler(FwIndexType portNum,
const ComCfg::FrameContext& context) {
// Restore the original buffer pointer and size stripped in dataIn_handler so the
// upstream BufferManager deallocates the exact allocation it originally handed out.
data.setData(data.getData() - Ccsds355_0_B_2::kTCSecurityHeaderSize);
data.setSize(data.getSize() + Ccsds355_0_B_2::kTCSecurityHeaderSize + Ccsds355_0_B_2::kTCSecurityTrailer);
// Rewinding restores the header bytes to the represented data, so only the trailer
// needs adding back to recover the original allocation extents.
data.advance(-static_cast<FwSignedSizeType>(Ccsds355_0_B_2::kTCSecurityHeaderSize));
data.setSize(data.getSize() + Ccsds355_0_B_2::kTCSecurityTrailer);

this->dataReturnOut_out(0, data, context);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
register_fprime_module(
AUTOCODER_INPUTS
"${CMAKE_CURRENT_LIST_DIR}/instances.fpp"
"${CMAKE_CURRENT_LIST_DIR}/system.fpp"
"${CMAKE_CURRENT_LIST_DIR}/topology.fpp"
"${CMAKE_CURRENT_LIST_DIR}/ReferenceDeploymentPackets.fppi"
SOURCES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,21 @@ telemetry packets ReferenceDeploymentPackets {
cmdSeq.CS_CommandsExecuted
cmdSeq.CS_SequencesCompleted
cmdSeq.CS_Errors
cmdSeq.CS_CurrentSequence
payloadSeq.CS_LoadCommands
payloadSeq.CS_CancelCommands
payloadSeq.CS_CommandsExecuted
payloadSeq.CS_SequencesCompleted
payloadSeq.CS_Errors
payloadSeq.CS_CurrentSequence
safeModeSeq.CS_LoadCommands
safeModeSeq.CS_CancelCommands
safeModeSeq.CS_CommandsExecuted
safeModeSeq.CS_SequencesCompleted
safeModeSeq.CS_Errors
safeModeSeq.CS_CurrentSequence
FileHandling.fileUplink.FilesReceived
FileHandling.fileUplink.FilesReceivedFailed
FileHandling.fileUplink.PacketsReceived
FileHandling.fileDownlink.FilesSent
FileHandling.fileDownlink.PacketsSent
Expand Down Expand Up @@ -313,4 +317,6 @@ telemetry packets ReferenceDeploymentPackets {

watchdog.WatchdogTransitions

CdhCore.events.EventsDropped

}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ void setupTopology(const TopologyState& state) {
configComponents(state);
// Project-specific component configuration. Function provided above. May be inlined, if desired.
configureTopology();
// Restore the persisted mode now that the ports are wired and the GPIO drivers are open.
// This drives the load switches, so it must not run any earlier.
modeManager.restorePersistentState();
// Read parameters from persistent storage
readParameters();
// Autocoded parameter loading. Function provided by autocoder.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ReferenceDeployment {
system ReferenceDeployment: ReferenceDeployment
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module ReferenceDeployment {
rateGroup1Hz
}

topology ReferenceDeployment {
deployment topology ReferenceDeployment {

# ----------------------------------------------------------------------
# Subtopology imports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ constant FwAssertTextSize = 256
@ in FpConfig.h.
constant AssertFatalAdapterEventFileSize = FileNameStringSize

@ The maximum size in bytes for passing sequence arguments through CmdSeqIn ports
@ Note: This must fit within FW_CMD_ARG_BUFFER_MAX_SIZE along with cmd arguments using Svc::SeqArgs
@ Total serialized size: string length prefix + fileName + BlockState + SeqArgs(size + buffer)
constant SequenceArgumentsMaxSize = FW_CMD_ARG_BUFFER_MAX_SIZE - sizeof(FwSizeStoreType) - FileNameStringSize - sizeof(U8) - sizeof(FwSizeType)

# ----------------------------------------------------------------------
# Hub connections. Connections on all deployments should mirror these settings.
# ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ module CdhCoreConfig {
constant tlmSend = 6

}

module CpuAffinities {
constant cmdDisp = Os.TASK_DEFAULT
constant events = Os.TASK_DEFAULT
constant tlmSend = Os.TASK_DEFAULT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ module ComCcsdsConfig {
constant comQueue = 8 # ComQueue has higher priority than data producers (e.g. events, telemetry)
}

module CpuAffinities {
constant aggregator = Os.TASK_DEFAULT
constant comQueue = Os.TASK_DEFAULT
}

# Queue configuration constants
module QueueDepths {
constant events = 50
Expand Down
20 changes: 19 additions & 1 deletion PROVESFlightControllerReference/project/config/ComCfg.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ module ComCfg {
@ Aggregation buffer for ComAggregator component
constant AggregationSize = TmFrameFixedSize - 6 - 6 - 1 - 2 # 2 header (6) + 1 idle byte + 2 trailer bytes

@ Packet Version Numbers are 3 bits with only 2 currently valid values
dictionary enum Pvn : U8 {
SPACE_PACKET_PROTOCOL = 0x0 @< Fully Featured CCSDS Space Packet Protocol
ENCAPSULATION_PACKET_PROTOCOL = 0x7 @< Bare-bones CCSDS Encapsulation Packet Protocol
INVALID_UNINITIALIZED = 0x8 @< Anything equal or higher value is invalid and should not be used
} default INVALID_UNINITIALIZED

@ APIDs are 11 bits in the Space Packet protocol, so we use U16. Max value 7FF
dictionary enum Apid : FwPacketDescriptorType {
# APIDs prefixed with FW are reserved for F Prime and need to be present
Expand All @@ -39,20 +46,31 @@ module ComCfg {
INVALID_UNINITIALIZED = 0x0800 @< Anything equal or higher value is invalid and should not be used
} default INVALID_UNINITIALIZED

@ Reserved SA index sentinel meaning "unset"; SA index 0xFFFF cannot be selected via context
constant SaIndexUnset = 0xFFFF

@ Type used to pass context info between components during framing/deframing
struct FrameContext {
comQueueIndex: FwIndexType @< Queue Index used by the ComQueue, other components shall not modify
apid: Apid @< 11 bits APID in CCSDS
hasSecHdr: bool @< Secondary header flag for SpacePacketFramer
sequenceFlags: U8 @< 2 bit Sequence flags (0b00=continuation, 0b01=first, 0b10=last, 0b11=unsegmented)
sequenceCount: U16 @< 14 bit Sequence count - sequence count is incremented per APID
vcId: U8 @< 6 bit Virtual Channel ID - used for TC and TM
vcId: U8 @< 6 bit Virtual Channel ID - used for AOS, TC, and TM Protocols
pvn: Pvn @< Packet Version Number - used for AOS deframing to identify packet type
sendNow: bool @< Flag to AOS Framer that the Frame this packet goes into should be sent ASAP
saIndex: U16 @< Security Association Index - set by SDLS deframers, read by SDLS framers
authenticated: bool @< Whether the packet has been authenticated
} default {
comQueueIndex = 0
apid = Apid.FW_PACKET_UNKNOWN
hasSecHdr = false
sequenceFlags = 0x3
sequenceCount = 0
vcId = 1
pvn = Pvn.INVALID_UNINITIALIZED
sendNow = false
saIndex = SaIndexUnset
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,27 @@
#ifndef CMDDISPATCHER_COMMANDDISPATCHERIMPLCFG_HPP_
#define CMDDISPATCHER_COMMANDDISPATCHERIMPLCFG_HPP_

#include <Fw/FPrimeBasicTypes.hpp>

// Define configuration values for dispatcher

enum {
CMD_DISPATCHER_DISPATCH_TABLE_SIZE = 350, // !< The size of the table holding opcodes to dispatch
CMD_DISPATCHER_SEQUENCER_TABLE_SIZE = 10, // !< The size of the table holding commands in progress
};

namespace Svc {
namespace CmdDispatcherCfg {

//! Include command opcodes in events when true.
//! When false, opcode fields are set to the maximum FwOpcodeType value.
constexpr bool IncludeCommandOpcodesInEvents = true;

constexpr FwOpcodeType getEventOpcode(const FwOpcodeType opcode) {
return IncludeCommandOpcodesInEvents ? opcode : std::numeric_limits<FwOpcodeType>::max();
}

} // namespace CmdDispatcherCfg
} // namespace Svc

#endif /* CMDDISPATCHER_COMMANDDISPATCHERIMPLCFG_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ module FileHandlingConfig {
constant fileManager = 15
}

module CpuAffinities {
constant fileUplink = Os.TASK_DEFAULT
constant fileDownlink = Os.TASK_DEFAULT
constant fileManager = Os.TASK_DEFAULT
constant prmDb = Os.TASK_DEFAULT
}

# File downlink configuration constants
module DownlinkConfig {
constant timeout = 5000 # File downlink timeout in ms
Expand Down
Loading
Loading