fprime/RPI/RpiDemo/RpiDemoComponentImpl.hpp
Thomas Boyer-Chammard d0246f148b
Add Framer FPP interface, implement FprimeFramer and adapt ComQueue (#3486)
* Initial FprimeFramer and FprimePacketizer

* Code clarity + set up UTs

* Rework ComQueue and ComStub to use DataWithContext

* Add packets to RefPackets.fppi

* Fix ComQueue tests

* Add hotfix to FileDownlink instead of ComQueue

* Fix cancelPacket as well

* Fix ComQueue UTs by removing hotfix

* Refactor DataWithContext to use an FPP object for context instead of Fw.Buffer

* Touch up testing

* Add docs

* more docs

* More docs

* Rework buffer deallocation pattern to pass-through ComQueue

* Update ComStub UTs

* Restore original FileDownlink.cpp

* Formatting tweak

* Update deprecated getSerializeRepr() calls

* deserialization methods

* Fix spelling

* add cast for safety

* CMakefile change

* Bump ComQueue depth

* Update RPI deployment with new Downlink stack

* Rename comQueueIn port to comPktQueueIn

* Fix comQueueIn to comPktQueueIn change

* Remove legacy Svc.Framer

* Fix CMake UTs

* Fix RPI topology config

* Fix FprimeProtocol.fpp module

* Fix namespacing

* Use const reference for FrameContext port

* Review comments EXCEPT port passback refactor

* Rework ComStub with new ByteStream

* New ByteStream - ComInterface model

* Rework TcpClient / TcpServer with new bytestream

* Adapt UDP component for new ByteStream

* Adapt FrameAccumulator for new ByteStream

* Adapt FprimeFramer for new ByteStream

* Update Ref topology with new ByteStream model

* Remove all legacy deallocates from Drivers; reintroduce DEPRECATED model types

* Fix spelling and include error

* More spelling....

* RPI and RpiDemo fixes

* Fix conversion warning on RPI

* static_cast for short int on RPI

* Standardize port names

* Remove legacy Drv types and merge RECV/SEND enum type, delete StreamCrossover

* Update SDDs

* Update SDDs

* Fix ComInterface <-> Framer interfaction, clarify comments and fix annotations

* Switch ComStub from ASSERT to log failure and return buffer

* Add history size check + clarify test handler overrides

* Fix RPI topology to wire comStub on Uplink

* Rename comm to comDriver in RPI topology

* Update communication adapter interface docs
2025-04-29 16:40:36 -07:00

162 lines
5.2 KiB
C++

// ======================================================================
// \title RpiDemoImpl.hpp
// \author tcanham
// \brief hpp file for RpiDemo component implementation class
//
// \copyright
// Copyright 2009-2015, by the California Institute of Technology.
// ALL RIGHTS RESERVED. United States Government Sponsorship
// acknowledged.
//
// ======================================================================
#ifndef RPI_RpiDemoComponentImpl_HPP
#define RPI_RpiDemoComponentImpl_HPP
#include "RPI/RpiDemo/RpiDemoComponentAc.hpp"
#include <RPI/RpiDemo/RpiDemoComponentImplCfg.hpp>
namespace RPI {
class RpiDemoComponentImpl final :
public RpiDemoComponentBase
{
public:
// ----------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------
// A list of contexts for the rate groups
enum {
RG_CONTEXT_1Hz = 10, // 1 Hz cycle
RG_CONTEXT_10Hz = 11 // 10 Hz cycle
};
public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
//! Construct object RpiDemo
//!
RpiDemoComponentImpl(
const char *const compName /*!< The component name*/
);
//! Destroy object RpiDemo
//!
~RpiDemoComponentImpl();
PRIVATE:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
//! Handler implementation for Run
//!
void Run_handler(
const FwIndexType portNum, /*!< The port number*/
U32 context /*!< The call order*/
) override;
//! Handler implementation for UartRead
//!
void UartRead_handler(
const FwIndexType portNum, /*!< The port number*/
Fw::Buffer &serBuffer, /*!< Buffer containing data*/
const Drv::ByteStreamStatus &status /*!< Status of read*/
) override;
//! Handler implementation for UartWriteReturn
//!
//! Input port for getting back buffer ownership and status when using UartWrite
void UartWriteReturn_handler(FwIndexType portNum, //!< The port number
Fw::Buffer& buffer,
const Drv::ByteStreamStatus& status) override;
PRIVATE:
// ----------------------------------------------------------------------
// Command handler implementations
// ----------------------------------------------------------------------
//! Implementation for RD_SendString command handler
//! Command to send a string to the UART
void RD_SendString_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
const Fw::CmdStringArg& text /*!< String to send*/
) override;
//! Implementation for RD_SetGpio command handler
//! Sets a GPIO port value
void RD_SetGpio_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
RpiDemo_GpioOutNum output, /*!< Output GPIO*/
Fw::Logic value /*!< GPIO value*/
) override;
//! Implementation for RD_GetGpio command handler
//! Gets a GPIO port value
void RD_GetGpio_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
RpiDemo_GpioInNum input /*!< Input GPIO*/
) override;
//! Implementation for RD_SendSpi command handler
//! Sends SPI data, prints read data
void RD_SendSpi_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
const Fw::CmdStringArg& data /*!< data to send*/
) override;
//! Implementation for RD_SetLed command handler
//! Sets LED state
void RD_SetLed_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
RpiDemo_LedState value /*!< GPIO value*/
) override;
//! Implementation for RD_SetLedDivider command handler
//! Sets the divided rate of the LED
void RD_SetLedDivider_cmdHandler(
const FwOpcodeType opCode, /*!< The opcode*/
const U32 cmdSeq, /*!< The command sequence number*/
U32 divider /*!< Divide 10Hz by this number*/
) override;
// This will be called once when task starts up
void preamble() override;
// telemetry values
U32 m_uartWriteBytes;
U32 m_uartReadBytes;
U32 m_spiBytes;
Fw::TlmString m_lastUartMsg;
Fw::Logic m_currLedVal;
// serial buffers
Fw::Buffer m_recvBuffers[NUM_RPI_UART_BUFFERS];
// LED enabled
bool m_ledOn;
// toggle LED divider
U32 m_ledDivider;
// 10Hz ticks
U32 m_1HzTicks;
// 10Hz ticks
U32 m_10HzTicks;
};
} // end namespace RPI
#endif