Finish code formatting (#4134)

This commit is contained in:
Thomas Boyer-Chammard 2025-09-10 15:02:07 -07:00 committed by GitHub
parent c8e2d44877
commit ba65039fff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
80 changed files with 2514 additions and 3120 deletions

View File

@ -31,11 +31,16 @@ jobs:
env:
# Svc is currently listing all but Svc/FpySequencer
CHECKED_DIRS: >-
CFDP
default
Drv
FppTestProject
Fw
Os
Ref
Svc
TestUtils
Utils
run: |
fprime-util format --check --dirs $CHECKED_DIRS

View File

@ -19,108 +19,63 @@ static U32 min(const U32 a, const U32 b) {
namespace CFDP {
Checksum ::
Checksum() : m_value(0)
{
Checksum ::Checksum() : m_value(0) {}
}
Checksum ::Checksum(const U32 value) : m_value(value) {}
Checksum ::
Checksum(const U32 value) : m_value(value)
{
}
Checksum ::
Checksum(const Checksum &original)
{
Checksum ::Checksum(const Checksum& original) {
this->m_value = original.getValue();
}
}
Checksum ::
~Checksum()
{
Checksum ::~Checksum() {}
}
Checksum& Checksum ::
operator=(const Checksum& checksum)
{
Checksum& Checksum ::operator=(const Checksum& checksum) {
this->m_value = checksum.m_value;
return *this;
}
}
bool Checksum ::
operator==(const Checksum& checksum) const
{
bool Checksum ::operator==(const Checksum& checksum) const {
return this->m_value == checksum.m_value;
}
}
bool Checksum ::
operator!=(const Checksum& checksum) const
{
return not (*this == checksum);
}
bool Checksum ::operator!=(const Checksum& checksum) const {
return not(*this == checksum);
}
U32 Checksum ::
getValue() const
{
U32 Checksum ::getValue() const {
return this->m_value;
}
}
void Checksum ::
update(
const U8 *const data,
const U32 offset,
const U32 length
)
{
void Checksum ::update(const U8* const data, const U32 offset, const U32 length) {
U32 index = 0;
// Add the first word unaligned if necessary
const U32 offsetMod4 = offset % 4;
if (offsetMod4 != 0) {
const U8 wordLength = static_cast<U8>(min(length, 4 - offsetMod4));
this->addWordUnaligned(
&data[index],
static_cast<U8>(offset + index),
wordLength
);
this->addWordUnaligned(&data[index], static_cast<U8>(offset + index), wordLength);
index += wordLength;
}
// Add the middle words aligned
for ( ; index + 4 <= length; index += 4) {
for (; index + 4 <= length; index += 4) {
addWordAligned(&data[index]);
}
// Add the last word unaligned if necessary
if (index < length) {
const U8 wordLength = static_cast<U8>(length - index);
this->addWordUnaligned(
&data[index],
static_cast<U8>(offset + index),
wordLength
);
this->addWordUnaligned(&data[index], static_cast<U8>(offset + index), wordLength);
}
}
}
void Checksum ::
addWordAligned(const U8 *const word)
{
void Checksum ::addWordAligned(const U8* const word) {
for (U8 i = 0; i < 4; ++i) {
addByteAtOffset(word[i], i);
}
}
}
void Checksum ::
addWordUnaligned(
const U8 *word,
const U8 position,
const U8 length
)
{
void Checksum ::addWordUnaligned(const U8* word, const U8 position, const U8 length) {
FW_ASSERT(length < 4);
U8 offset = position % 4;
for (U8 i = 0; i < length; ++i) {
@ -130,17 +85,12 @@ namespace CFDP {
offset = 0;
}
}
}
void Checksum ::
addByteAtOffset(
const U8 byte,
const U8 offset
)
{
FW_ASSERT(offset < 4);
const U32 addend = static_cast<U32>(byte) << (8*(3-offset));
this->m_value += addend;
}
}
void Checksum ::addByteAtOffset(const U8 byte, const U8 offset) {
FW_ASSERT(offset < 4);
const U32 addend = static_cast<U32>(byte) << (8 * (3 - offset));
this->m_value += addend;
}
} // namespace CFDP

View File

@ -17,49 +17,46 @@
namespace CFDP {
//! \class Checksum
//! \brief Class representing a 32-bit checksum as mandated by the CCSDS File
//! Delivery Protocol.
//!
//! This checksum is calculated by update of an existing 32-bit value
//! with the "next" 32-bit string drawn from the file data. Beginning
//! at the start of the file, a 4-byte window moves up the file by four
//! bytes per update. The update itself replaces the existing checksum
//! with the byte-wise sum of the existing checksum and the file data
//! contained in the window. Overflows in the addition are permitted
//! and the carry discarded.
//!
//! If an update is to be made beginning at an offset into the file
//! which is not aligned to a 4-byte boundary, the window is treated
//! as beginning at the last 4-byte boundary, but is left-zero-padded.
//! Similarly, where the file data for an update ends on an unaligned
//! byte, the window extends up to the next boundary and is
//! right-zero-padded.
//!
//! ## Example
//!
//! For buffer 0xDE 0xAD 0xBE 0xEF 0xCA 0xFE and initial zero checksum:
//!
//! ------------------------------------ Update 1
//! Window 0xDE 0xAD 0xBE 0xEF
//! Checksum 0xDEADBEEF
//!
//! ------------------------------------ Update 2
//! Window 0xCA 0xFE
//! Checksum 0xDEADBEEF+
//! 0xCAFE0000
//! ----------
//! 0xA8ABBEEF <- Final value
class Checksum {
//! \class Checksum
//! \brief Class representing a 32-bit checksum as mandated by the CCSDS File
//! Delivery Protocol.
//!
//! This checksum is calculated by update of an existing 32-bit value
//! with the "next" 32-bit string drawn from the file data. Beginning
//! at the start of the file, a 4-byte window moves up the file by four
//! bytes per update. The update itself replaces the existing checksum
//! with the byte-wise sum of the existing checksum and the file data
//! contained in the window. Overflows in the addition are permitted
//! and the carry discarded.
//!
//! If an update is to be made beginning at an offset into the file
//! which is not aligned to a 4-byte boundary, the window is treated
//! as beginning at the last 4-byte boundary, but is left-zero-padded.
//! Similarly, where the file data for an update ends on an unaligned
//! byte, the window extends up to the next boundary and is
//! right-zero-padded.
//!
//! ## Example
//!
//! For buffer 0xDE 0xAD 0xBE 0xEF 0xCA 0xFE and initial zero checksum:
//!
//! ------------------------------------ Update 1
//! Window 0xDE 0xAD 0xBE 0xEF
//! Checksum 0xDEADBEEF
//!
//! ------------------------------------ Update 2
//! Window 0xCA 0xFE
//! Checksum 0xDEADBEEF+
//! 0xCAFE0000
//! ----------
//! 0xA8ABBEEF <- Final value
class Checksum {
public:
// ----------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------
public:
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
@ -71,13 +68,12 @@ namespace CFDP {
Checksum(const U32 value);
//! Copy a Checksum object.
Checksum(const Checksum &original);
Checksum(const Checksum& original);
//! Destroy a Checksum object.
~Checksum();
public:
// ----------------------------------------------------------------------
// Public instance methods
// ----------------------------------------------------------------------
@ -107,40 +103,34 @@ namespace CFDP {
U32 getValue() const;
private:
// ----------------------------------------------------------------------
// Private instance methods
// ----------------------------------------------------------------------
//! Add a four-byte aligned word to the checksum value
void addWordAligned(
const U8 *const word //! The word
void addWordAligned(const U8* const word //! The word
);
//! Add a four-byte unaligned word to the checksum value
void addWordUnaligned(
const U8 *const word, //! The word
void addWordUnaligned(const U8* const word, //! The word
const U8 position, //! The position of the word relative to the start of the file
const U8 length //! The number of valid bytes in the word
);
//! Add byte to value at offset in word
void addByteAtOffset(
const U8 byte, //! The byte
void addByteAtOffset(const U8 byte, //! The byte
const U8 offset //! The offset
);
private:
// ----------------------------------------------------------------------
// Private member variables
// ----------------------------------------------------------------------
//! The accumulated checksum value
U32 m_value;
};
};
}
} // namespace CFDP
#endif

View File

@ -14,19 +14,14 @@
namespace CFDP {
namespace GTest {
namespace GTest {
void Checksums ::
compare(
const CFDP::Checksum& expected,
const CFDP::Checksum& actual
)
{
void Checksums ::compare(const CFDP::Checksum& expected, const CFDP::Checksum& actual) {
const U32 expectedValue = expected.getValue();
const U32 actualValue = actual.getValue();
ASSERT_EQ(expectedValue, actualValue);
}
}
}
} // namespace GTest
} // namespace CFDP

View File

@ -19,21 +19,20 @@
namespace CFDP {
namespace GTest {
namespace GTest {
//! Utilities for testing Checksum operations
//!
namespace Checksums {
//! Utilities for testing Checksum operations
//!
namespace Checksums {
void compare(
const CFDP::Checksum& expected, //!< Expected value
void compare(const CFDP::Checksum& expected, //!< Expected value
const CFDP::Checksum& actual //!< Actual value
);
}
}
);
}
} // namespace GTest
} // namespace CFDP
#endif

View File

@ -8,11 +8,10 @@
using namespace CFDP;
const U8 data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
const U8 data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
const U32 expectedValue =
(data[0] << 3*8) + (data[1] << 2*8) + (data[2] << 1*8) + data[3] +
(data[4] << 3*8) + (data[5] << 2*8) + (data[6] << 1*8) + data[7];
const U32 expectedValue = (data[0] << 3 * 8) + (data[1] << 2 * 8) + (data[2] << 1 * 8) + data[3] + (data[4] << 3 * 8) +
(data[5] << 2 * 8) + (data[6] << 1 * 8) + data[7];
TEST(Checksum, OnePacket) {
Checksum checksum;
@ -49,8 +48,7 @@ TEST(Checksum, ThreePackets) {
ASSERT_EQ(expectedValue, checksum.getValue());
}
int main(int argc, char **argv) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,31 +1,25 @@
#include <Ref/BlockDriver/BlockDriver.hpp>
#include <Fw/FPrimeBasicTypes.hpp>
#include <Fw/Types/Assert.hpp>
#include <Ref/BlockDriver/BlockDriver.hpp>
namespace Ref {
BlockDriver::BlockDriver(const char* compName) :
BlockDriverComponentBase(compName), m_cycles(0)
{}
BlockDriver::BlockDriver(const char* compName) : BlockDriverComponentBase(compName), m_cycles(0) {}
BlockDriver::~BlockDriver() {}
BlockDriver::~BlockDriver() {}
void BlockDriver::BufferIn_handler(FwIndexType portNum, Drv::DataBuffer& buffer) {
void BlockDriver::BufferIn_handler(FwIndexType portNum, Drv::DataBuffer& buffer) {
// just a pass-through
this->BufferOut_out(0,buffer);
}
void BlockDriver::Sched_handler(FwIndexType portNum, U32 context) {
this->tlmWrite_BD_Cycles(this->m_cycles++);
}
void BlockDriver::PingIn_handler(
const FwIndexType portNum,
U32 key
)
{
// call ping output port
this->PingOut_out(0,key);
}
this->BufferOut_out(0, buffer);
}
void BlockDriver::Sched_handler(FwIndexType portNum, U32 context) {
this->tlmWrite_BD_Cycles(this->m_cycles++);
}
void BlockDriver::PingIn_handler(const FwIndexType portNum, U32 key) {
// call ping output port
this->PingOut_out(0, key);
}
} // namespace Ref

View File

@ -5,31 +5,26 @@
namespace Ref {
class BlockDriver final : public BlockDriverComponentBase {
class BlockDriver final : public BlockDriverComponentBase {
public:
// Only called by derived class
BlockDriver(const char* compName);
~BlockDriver();
private:
// downcalls for input ports
void BufferIn_handler(FwIndexType portNum, Drv::DataBuffer& buffer);
void Sched_handler(FwIndexType portNum, U32 context);
//! Handler implementation for PingIn
//!
void PingIn_handler(
const FwIndexType portNum, /*!< The port number*/
void PingIn_handler(const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
);
// cycle count
U32 m_cycles;
};
}
};
} // namespace Ref
#endif

View File

@ -8,32 +8,23 @@
namespace Ref {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
BlockDriverTester ::
BlockDriverTester() :
BlockDriverGTestBase("BlockDriverTester", BlockDriverTester::MAX_HISTORY_SIZE),
component("BlockDriver")
{
BlockDriverTester ::BlockDriverTester()
: BlockDriverGTestBase("BlockDriverTester", BlockDriverTester::MAX_HISTORY_SIZE), component("BlockDriver") {
this->initComponents();
this->connectPorts();
}
}
BlockDriverTester ::
~BlockDriverTester()
{
BlockDriverTester ::~BlockDriverTester() {}
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void BlockDriverTester ::
testDataLoopBack()
{
void BlockDriverTester ::testDataLoopBack() {
const U8 data[] = {1, 2, 3, 4, 5, 6, 7};
Drv::DataBuffer dataBuffer(data, 7);
@ -47,11 +38,9 @@ namespace Ref {
// verify data output
ASSERT_from_BufferOut_SIZE(1);
ASSERT_from_BufferOut(0, dataBuffer);
}
}
void BlockDriverTester ::
testPing()
{
void BlockDriverTester ::testPing() {
const U32 key = 42;
this->clearHistory();
@ -64,15 +53,13 @@ namespace Ref {
// verify Ping output
ASSERT_from_PingOut_SIZE(1);
ASSERT_from_PingOut(0, key);
}
}
void BlockDriverTester ::
testCycleIncrement()
{
void BlockDriverTester ::testCycleIncrement() {
this->clearHistory();
// call ISR
this->invoke_to_Sched(0,0);
this->invoke_to_Sched(0, 0);
this->component.doDispatch();
// there shall be one report with 0 cycle
@ -81,13 +68,13 @@ namespace Ref {
ASSERT_TLM_BD_Cycles(0, 0);
// call ISR once again
this->invoke_to_Sched(0,0);
this->invoke_to_Sched(0, 0);
this->component.doDispatch();
// there shall be one more report with 1 cycle
ASSERT_TLM_SIZE(2);
ASSERT_TLM_BD_Cycles_SIZE(2);
ASSERT_TLM_BD_Cycles(1, 1);
}
}
} // namespace Ref

View File

@ -7,17 +7,13 @@
#ifndef Ref_BlockDriverTester_HPP
#define Ref_BlockDriverTester_HPP
#include "Ref/BlockDriver/BlockDriverGTestBase.hpp"
#include "Ref/BlockDriver/BlockDriver.hpp"
#include "Ref/BlockDriver/BlockDriverGTestBase.hpp"
namespace Ref {
class BlockDriverTester final :
public BlockDriverGTestBase
{
class BlockDriverTester final : public BlockDriverGTestBase {
public:
// ----------------------------------------------------------------------
// Constants
// ----------------------------------------------------------------------
@ -32,7 +28,6 @@ namespace Ref {
static const FwSizeType TEST_INSTANCE_QUEUE_DEPTH = 10;
public:
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
@ -44,7 +39,6 @@ namespace Ref {
~BlockDriverTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
@ -59,7 +53,6 @@ namespace Ref {
void testCycleIncrement();
private:
// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------
@ -71,16 +64,14 @@ namespace Ref {
void initComponents();
private:
// ----------------------------------------------------------------------
// Member variables
// ----------------------------------------------------------------------
//! The component under test
BlockDriver component;
};
};
}
} // namespace Ref
#endif

View File

@ -8,23 +8,23 @@
namespace Ref {
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Component construction and destruction
// ----------------------------------------------------------------------
DpDemo ::DpDemo(const char* const compName) : DpDemoComponentBase(compName) {
DpDemo ::DpDemo(const char* const compName) : DpDemoComponentBase(compName) {
this->selectedColor = DpDemo_ColorEnum::RED;
this->numRecords = 0;
this->dpPriority = 0;
}
}
DpDemo ::~DpDemo() {}
DpDemo ::~DpDemo() {}
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------
void DpDemo ::run_handler(FwIndexType portNum, U32 context) {
void DpDemo ::run_handler(FwIndexType portNum, U32 context) {
// If a Data product is being generated, store records
if (this->dpInProgress) {
this->dpContainer.serializeRecord_StringRecord(Fw::String("Test string"));
@ -39,133 +39,70 @@ namespace Ref {
Fw::String str0("String array element 0");
Fw::String str1("String array element 1");
Fw::String str2("String array element 2");
const Fw::StringBase* strings[3] = { &str0, &str1, &str2 };
const Fw::StringBase* strings[3] = {&str0, &str1, &str2};
this->dpContainer.serializeRecord_StringArrayRecord(strings, 3);
// Array record of arrays
const DpDemo_StringArray arrayArray[1] = {
DpDemo_StringArray({
Fw::String("0 - String array record element 0"),
Fw::String("0 - String array record element 1")
})
};
const DpDemo_StringArray arrayArray[1] = {DpDemo_StringArray(
{Fw::String("0 - String array record element 0"), Fw::String("0 - String array record element 1")})};
this->dpContainer.serializeRecord_ArrayArrayRecord(arrayArray, 1);
// Array record of structs
const DpDemo_StructWithStringMembers structArray[2] = {
DpDemo_StructWithStringMembers(
Fw::String("0 - String member"),
DpDemo_StringArray({
Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")
})
),
DpDemo_StructWithStringMembers(
Fw::String("1 - String member"),
DpDemo_StringArray({
Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")
})
)
};
DpDemo_StructWithStringMembers(Fw::String("0 - String member"),
DpDemo_StringArray({Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")})),
DpDemo_StructWithStringMembers(Fw::String("1 - String member"),
DpDemo_StringArray({Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")}))};
this->dpContainer.serializeRecord_StructArrayRecord(structArray, 2);
this->dpContainer.serializeRecord_ArrayOfStringArrayRecord(
DpDemo_ArrayOfStringArray({
DpDemo_StringArray({
Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")
}),
DpDemo_StringArray({
Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")
}),
DpDemo_StringArray({
Fw::String("2 - String array element 0"),
Fw::String("2 - String array element 1")
})
})
);
this->dpContainer.serializeRecord_ArrayOfStructsRecord(
DpDemo_ArrayOfStructs({
DpDemo_StructWithStringMembers(
Fw::String("0 - String member"),
DpDemo_StringArray({
Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")
})
),
DpDemo_StructWithStringMembers(
Fw::String("1 - String member"),
DpDemo_StringArray({
Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")
})
),
DpDemo_StructWithStringMembers(
Fw::String("2 - String member"),
DpDemo_StringArray({
Fw::String("2 - String array element 0"),
Fw::String("2 - String array element 1")
})
)
})
);
this->dpContainer.serializeRecord_EnumArrayRecord(DpDemo_EnumArray({DpDemo_ColorEnum::RED, DpDemo_ColorEnum::GREEN, DpDemo_ColorEnum::BLUE}));
this->dpContainer.serializeRecord_ArrayOfStringArrayRecord(DpDemo_ArrayOfStringArray(
{DpDemo_StringArray({Fw::String("0 - String array element 0"), Fw::String("0 - String array element 1")}),
DpDemo_StringArray({Fw::String("1 - String array element 0"), Fw::String("1 - String array element 1")}),
DpDemo_StringArray(
{Fw::String("2 - String array element 0"), Fw::String("2 - String array element 1")})}));
this->dpContainer.serializeRecord_ArrayOfStructsRecord(DpDemo_ArrayOfStructs(
{DpDemo_StructWithStringMembers(Fw::String("0 - String member"),
DpDemo_StringArray({Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")})),
DpDemo_StructWithStringMembers(Fw::String("1 - String member"),
DpDemo_StringArray({Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")})),
DpDemo_StructWithStringMembers(Fw::String("2 - String member"),
DpDemo_StringArray({Fw::String("2 - String array element 0"),
Fw::String("2 - String array element 1")}))}));
this->dpContainer.serializeRecord_EnumArrayRecord(
DpDemo_EnumArray({DpDemo_ColorEnum::RED, DpDemo_ColorEnum::GREEN, DpDemo_ColorEnum::BLUE}));
this->dpContainer.serializeRecord_StructWithEverythingRecord(DpDemo_StructWithEverything(
-1,
2.5,
Fw::String("String Member"),
false,
this->selectedColor,
{
DpDemo_U32Array({1, 2, 3, 4, 5}),
DpDemo_U32Array({6, 7, 8, 9, 10})
},
DpDemo_F32Array({4.4f, 5.5f, 6.6f}),
-1, 2.5, Fw::String("String Member"), false, this->selectedColor,
{DpDemo_U32Array({1, 2, 3, 4, 5}), DpDemo_U32Array({6, 7, 8, 9, 10})}, DpDemo_F32Array({4.4f, 5.5f, 6.6f}),
DpDemo_U32Array({6, 7, 8, 9, 10}),
DpDemo_EnumArray({DpDemo_ColorEnum::RED, DpDemo_ColorEnum::GREEN, DpDemo_ColorEnum::BLUE}),
DpDemo_StringArray({
Fw::String("String array element 0"),
Fw::String("String array element 1")
}),
DpDemo_StringArray({Fw::String("String array element 0"), Fw::String("String array element 1")}),
DpDemo_BooleanArray({true, false}),
DpDemo_StructWithStringMembers(
Fw::String("String member"),
DpDemo_StringArray({
Fw::String("String array element 0"),
Fw::String("String array element 1")
})
),
DpDemo_ArrayOfStringArray({
DpDemo_StringArray({
Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")
}),
DpDemo_StringArray({
Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")
}),
DpDemo_StringArray({
Fw::String("2 - String array element 0"),
Fw::String("2 - String array element 1")
})
})
));
DpDemo_StringArray({Fw::String("String array element 0"), Fw::String("String array element 1")})),
DpDemo_ArrayOfStringArray({DpDemo_StringArray({Fw::String("0 - String array element 0"),
Fw::String("0 - String array element 1")}),
DpDemo_StringArray({Fw::String("1 - String array element 0"),
Fw::String("1 - String array element 1")}),
DpDemo_StringArray({Fw::String("2 - String array element 0"),
Fw::String("2 - String array element 1")})})));
this->log_ACTIVITY_LO_DpComplete(this->numRecords);
this->cleanupAndSendDp();
}
}
}
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations for commands
// ----------------------------------------------------------------------
void DpDemo ::SelectColor_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Ref::DpDemo_ColorEnum color) {
void DpDemo ::SelectColor_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, Ref::DpDemo_ColorEnum color) {
this->selectedColor = color;
log_ACTIVITY_HI_ColorSelected(color);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void DpDemo ::Dp_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, DpDemo_DpReqType reqType, U32 priority) {
}
void DpDemo ::Dp_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, DpDemo_DpReqType reqType, U32 priority) {
// make sure DPs are available
if (!this->isConnected_productGetOut_OutputPort(0) || !this->isConnected_productRequestOut_OutputPort(0)) {
this->log_WARNING_HI_DpsNotConnected();
@ -174,26 +111,18 @@ namespace Ref {
}
this->numRecords = 15; // 15 records in current demo
FwSizeType dpSize = DpDemo_StringAlias::SERIALIZED_SIZE +
sizeof(DpDemo_BoolAlias) +
sizeof(DpDemo_I32Alias) +
sizeof(DpDemo_F64Alias) +
DpDemo_U32Array::SERIALIZED_SIZE +
DpDemo_F32Array::SERIALIZED_SIZE +
DpDemo_BooleanArray::SERIALIZED_SIZE +
DpDemo_EnumArray::SERIALIZED_SIZE +
DpDemo_StringArray::SERIALIZED_SIZE +
DpDemo_StructWithEverything::SERIALIZED_SIZE +
DpDemo_StructWithStringMembers::SERIALIZED_SIZE +
(DpDemo_StringArray::SERIALIZED_SIZE * 3) +
FwSizeType dpSize = DpDemo_StringAlias::SERIALIZED_SIZE + sizeof(DpDemo_BoolAlias) + sizeof(DpDemo_I32Alias) +
sizeof(DpDemo_F64Alias) + DpDemo_U32Array::SERIALIZED_SIZE + DpDemo_F32Array::SERIALIZED_SIZE +
DpDemo_BooleanArray::SERIALIZED_SIZE + DpDemo_EnumArray::SERIALIZED_SIZE +
DpDemo_StringArray::SERIALIZED_SIZE + DpDemo_StructWithEverything::SERIALIZED_SIZE +
DpDemo_StructWithStringMembers::SERIALIZED_SIZE + (DpDemo_StringArray::SERIALIZED_SIZE * 3) +
(DpDemo_StringArray::SERIALIZED_SIZE * 1) +
(DpDemo_StructWithStringMembers::SERIALIZED_SIZE * 2) +
DpDemo_ArrayOfStringArray::SERIALIZED_SIZE +
(numRecords * sizeof(FwDpIdType));
DpDemo_ArrayOfStringArray::SERIALIZED_SIZE + (numRecords * sizeof(FwDpIdType));
this->dpPriority = static_cast<FwDpPriorityType>(priority);
this->log_ACTIVITY_LO_DpMemRequested(dpSize);
if(reqType == DpDemo_DpReqType::IMMEDIATE) {
if (reqType == DpDemo_DpReqType::IMMEDIATE) {
Fw::Success stat = this->dpGet_DpDemoContainer(dpSize, this->dpContainer);
// make sure we got the memory we wanted
if (Fw::Success::FAILURE == stat) {
@ -207,21 +136,19 @@ namespace Ref {
this->dpContainer.setPriority(priority);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
}
else if (reqType == DpDemo_DpReqType::ASYNC) {
} else if (reqType == DpDemo_DpReqType::ASYNC) {
this->dpRequest_DpDemoContainer(dpSize);
}
else {
} else {
// should never get here
FW_ASSERT(0, reqType.e);
}
}
}
// ----------------------------------------------------------------------
// Handler implementations for data products
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations for data products
// ----------------------------------------------------------------------
void DpDemo ::dpRecv_DpDemoContainer_handler(DpContainer& container, Fw::Success::T status) {
void DpDemo ::dpRecv_DpDemoContainer_handler(DpContainer& container, Fw::Success::T status) {
// Make sure we got the buffer we wanted or quit
if (Fw::Success::SUCCESS == status) {
this->dpContainer = container;
@ -235,12 +162,12 @@ namespace Ref {
this->dpInProgress = false;
this->numRecords = 0;
}
}
}
void DpDemo ::cleanupAndSendDp() {
void DpDemo ::cleanupAndSendDp() {
this->dpSend(this->dpContainer);
this->dpInProgress = false;
this->numRecords = 0;
}
}
} // namespace Ref

View File

@ -19,7 +19,6 @@
// Used to get the Os::Console
#include <Os/Os.hpp>
/**
* \brief print commandline help message
*

View File

@ -10,7 +10,7 @@
namespace Ref {
typedef PingReceiverComponentImpl PingReceiver;
typedef PingReceiverComponentImpl PingReceiver;
}

View File

@ -10,53 +10,37 @@
//
// ======================================================================
#include <Ref/PingReceiver/PingReceiverComponentImpl.hpp>
#include <Fw/FPrimeBasicTypes.hpp>
#include <Ref/PingReceiver/PingReceiverComponentImpl.hpp>
namespace Ref {
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
PingReceiverComponentImpl ::
PingReceiverComponentImpl(
const char *const compName
) : PingReceiverComponentBase(compName), m_inhibitPings(false), m_pingsRecvd(0)
{
PingReceiverComponentImpl ::PingReceiverComponentImpl(const char* const compName)
: PingReceiverComponentBase(compName), m_inhibitPings(false), m_pingsRecvd(0) {}
}
PingReceiverComponentImpl ::~PingReceiverComponentImpl() {}
PingReceiverComponentImpl ::
~PingReceiverComponentImpl()
{
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
}
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
void PingReceiverComponentImpl ::
PingIn_handler(
const FwIndexType portNum,
U32 key
)
{
//this->log_DIAGNOSTIC_PR_PingReceived(key);
void PingReceiverComponentImpl ::PingIn_handler(const FwIndexType portNum, U32 key) {
// this->log_DIAGNOSTIC_PR_PingReceived(key);
this->tlmWrite_PR_NumPings(this->m_pingsRecvd++);
if (not this->m_inhibitPings) {
PingOut_out(0,key);
}
PingOut_out(0, key);
}
}
void PingReceiverComponentImpl::PR_StopPings_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void PingReceiverComponentImpl::PR_StopPings_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
) {
) {
this->m_inhibitPings = true;
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
} // end namespace Ref

View File

@ -17,20 +17,15 @@
namespace Ref {
class PingReceiverComponentImpl final :
public PingReceiverComponentBase
{
class PingReceiverComponentImpl final : public PingReceiverComponentBase {
public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
//! Construct object PingReceiver
//!
PingReceiverComponentImpl(
const char *const compName /*!< The component name*/
PingReceiverComponentImpl(const char* const compName /*!< The component name*/
);
//! Destroy object PingReceiver
@ -38,28 +33,23 @@ namespace Ref {
~PingReceiverComponentImpl();
private:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------
//! Handler implementation for PingIn
//!
void PingIn_handler(
const FwIndexType portNum, /*!< The port number*/
void PingIn_handler(const FwIndexType portNum, /*!< The port number*/
U32 key /*!< Value to return to pinger*/
);
void PR_StopPings_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void PR_StopPings_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
);
bool m_inhibitPings;
U32 m_pingsRecvd;
};
};
} // end namespace Ref

View File

@ -10,7 +10,7 @@
namespace Ref {
typedef RecvBuffImpl RecvBuff;
typedef RecvBuffImpl RecvBuff;
}

View File

@ -1,7 +1,7 @@
#include <Ref/RecvBuffApp/RecvBuffComponentImpl.hpp>
#include <Fw/FPrimeBasicTypes.hpp>
#include <Os/Console.hpp>
#include <Fw/Types/Assert.hpp>
#include <Os/Console.hpp>
#include <Ref/RecvBuffApp/RecvBuffComponentImpl.hpp>
#include <cstdio>
@ -9,38 +9,34 @@
namespace Ref {
RecvBuffImpl::RecvBuffImpl(const char* compName) :
RecvBuffComponentBase(compName) {
RecvBuffImpl::RecvBuffImpl(const char* compName) : RecvBuffComponentBase(compName) {
this->m_firstBuffReceived = 0;
this->m_sensor1 = 1000.0;
this->m_sensor2 = 10.0;
this->m_stats.set_BuffRecv(0);
this->m_stats.set_BuffErr(0);
this->m_stats.set_PacketStatus(PacketRecvStatus::PACKET_STATE_NO_PACKETS);
}
}
RecvBuffImpl::~RecvBuffImpl() {
}
void RecvBuffImpl::Data_handler(FwIndexType portNum, Drv::DataBuffer &buff) {
RecvBuffImpl::~RecvBuffImpl() {}
void RecvBuffImpl::Data_handler(FwIndexType portNum, Drv::DataBuffer& buff) {
this->m_stats.set_BuffRecv(++this->m_buffsReceived);
// reset deserialization of buffer
buff.resetDeser();
// deserialize packet ID
U32 id = 0;
Fw::SerializeStatus stat = buff.deserializeTo(id);
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(stat));
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
// deserialize data
U8 testData[24] = {0};
FwSizeType size = sizeof(testData);
stat = buff.deserializeTo(testData,size);
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(stat));
stat = buff.deserializeTo(testData, size);
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
// deserialize checksum
U32 csum = 0;
stat = buff.deserializeTo(csum);
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK,static_cast<FwAssertArgType>(stat));
FW_ASSERT(stat == Fw::FW_SERIALIZE_OK, static_cast<FwAssertArgType>(stat));
// if first packet, send event
if (not this->m_firstBuffReceived) {
this->log_ACTIVITY_LO_FirstPacketReceived(id);
@ -69,13 +65,12 @@ namespace Ref {
this->tlmWrite_Sensor1(this->m_sensor1);
this->tlmWrite_Sensor2(this->m_sensor2);
this->tlmWrite_PktState(this->m_stats);
}
}
void RecvBuffImpl::parameterUpdated(FwPrmIdType id) {
void RecvBuffImpl::parameterUpdated(FwPrmIdType id) {
this->log_ACTIVITY_LO_BuffRecvParameterUpdated(id);
Fw::ParamValid valid;
switch(id) {
switch (id) {
case PARAMID_PARAMETER1: {
U32 val = this->paramGet_parameter1(valid);
this->tlmWrite_Parameter1(val);
@ -87,9 +82,9 @@ namespace Ref {
break;
}
default:
FW_ASSERT(0,id);
FW_ASSERT(0, id);
break;
}
}
}
} // namespace Ref

View File

@ -5,18 +5,16 @@
namespace Ref {
class RecvBuffImpl final : public RecvBuffComponentBase {
class RecvBuffImpl final : public RecvBuffComponentBase {
public:
// Only called by derived class
RecvBuffImpl(const char* compName);
~RecvBuffImpl();
private:
// downcall for input port
void Data_handler(FwIndexType portNum, Drv::DataBuffer &buff);
void Data_handler(FwIndexType portNum, Drv::DataBuffer& buff);
Ref::PacketStat m_stats;
U32 m_buffsReceived; // !< number of buffers received
bool m_firstBuffReceived; // !< first buffer received or not
@ -26,9 +24,8 @@ namespace Ref {
// parameter update notification
void parameterUpdated(FwPrmIdType id);
};
};
}
} // namespace Ref
#endif

View File

@ -10,7 +10,7 @@
namespace Ref {
typedef SendBuffImpl SendBuff;
typedef SendBuffImpl SendBuff;
}

View File

@ -1,7 +1,7 @@
#include <Ref/SendBuffApp/SendBuffComponentImpl.hpp>
#include <Fw/FPrimeBasicTypes.hpp>
#include <Fw/Types/Assert.hpp>
#include <Os/Console.hpp>
#include <Ref/SendBuffApp/SendBuffComponentImpl.hpp>
#include <cstring>
#include <cstdio>
@ -10,8 +10,7 @@
namespace Ref {
SendBuffImpl::SendBuffImpl(const char* compName) :
SendBuffComponentBase(compName) {
SendBuffImpl::SendBuffImpl(const char* compName) : SendBuffComponentBase(compName) {
this->m_currPacketId = 0;
this->m_invocations = 0;
this->m_buffsSent = 0;
@ -21,14 +20,11 @@ namespace Ref {
this->m_currPacketId = 0;
this->m_firstPacketSent = false;
this->m_state = SendBuff_ActiveState::SEND_IDLE;
}
}
SendBuffImpl::~SendBuffImpl() {
}
void SendBuffImpl::SchedIn_handler(FwIndexType portNum, U32 context) {
SendBuffImpl::~SendBuffImpl() {}
void SendBuffImpl::SchedIn_handler(FwIndexType portNum, U32 context) {
// first, dequeue any messages
MsgDispatchStatus stat = MSG_DISPATCH_OK;
@ -58,7 +54,7 @@ namespace Ref {
// write data
U8 testData[24];
FwSizeType dataSize = static_cast<FwSizeType>(sizeof(testData));
memset(testData,0xFF,static_cast<size_t>(dataSize));
memset(testData, 0xFF, static_cast<size_t>(dataSize));
// compute checksum
U32 csum = 0;
for (U32 byte = 0; byte < dataSize; byte++) {
@ -69,50 +65,47 @@ namespace Ref {
this->m_injectError = false;
this->m_errorsInjected++;
testData[5] = 0;
this->log_WARNING_HI_PacketErrorInserted(this->m_currPacketId-1);
this->log_WARNING_HI_PacketErrorInserted(this->m_currPacketId - 1);
}
// serialize data
serStat = this->m_testBuff.serialize(testData,dataSize);
serStat = this->m_testBuff.serialize(testData, dataSize);
FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK);
// serialize checksum
serStat = this->m_testBuff.serialize(csum);
FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK);
// send data
this->Data_out(0,this->m_testBuff);
this->Data_out(0, this->m_testBuff);
}
this->m_invocations++;
this->tlmWrite_SendState(this->m_state);
}
}
void SendBuffImpl::SB_START_PKTS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
void SendBuffImpl::SB_START_PKTS_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
this->m_sendPackets = true;
this->m_state = SendBuff_ActiveState::SEND_ACTIVE;
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void SendBuffImpl::SB_INJECT_PKT_ERROR_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
void SendBuffImpl::SB_INJECT_PKT_ERROR_cmdHandler(FwOpcodeType opCode, U32 cmdSeq) {
this->m_injectError = true;
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void SendBuffImpl::SB_GEN_FATAL_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SendBuffImpl::SB_GEN_FATAL_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 arg1, /*!< First FATAL Argument*/
U32 arg2, /*!< Second FATAL Argument*/
U32 arg3 /*!< Third FATAL Argument*/
) {
this->log_FATAL_SendBuffFatal(arg1,arg2,arg3);
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
) {
this->log_FATAL_SendBuffFatal(arg1, arg2, arg3);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
//! Handler for command SB_GEN_ASSERT
/* Generate an ASSERT */
void SendBuffImpl::SB_GEN_ASSERT_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
//! Handler for command SB_GEN_ASSERT
/* Generate an ASSERT */
void SendBuffImpl::SB_GEN_ASSERT_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 arg1, /*!< First ASSERT Argument*/
U32 arg2, /*!< Second ASSERT Argument*/
@ -120,15 +113,15 @@ namespace Ref {
U32 arg4, /*!< Fourth ASSERT Argument*/
U32 arg5, /*!< Fifth ASSERT Argument*/
U32 arg6 /*!< Sixth ASSERT Argument*/
) {
FW_ASSERT(0,arg1,arg2,arg3,arg4,arg5,arg6);
this->cmdResponse_out(opCode,cmdSeq,Fw::CmdResponse::OK);
}
) {
FW_ASSERT(0, arg1, arg2, arg3, arg4, arg5, arg6);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
void SendBuffImpl::parameterUpdated(FwPrmIdType id) {
void SendBuffImpl::parameterUpdated(FwPrmIdType id) {
this->log_ACTIVITY_LO_BuffSendParameterUpdated(id);
Fw::ParamValid valid;
switch(id) {
switch (id) {
case PARAMID_PARAMETER3: {
U8 val = this->paramGet_parameter3(valid);
this->tlmWrite_Parameter3(val);
@ -140,8 +133,8 @@ namespace Ref {
break;
}
default:
FW_ASSERT(0,id);
FW_ASSERT(0, id);
break;
}
}
}
} // namespace Ref

View File

@ -5,22 +5,19 @@
namespace Ref {
/// This component sends a data buffer to a driver each time it is invoked by a scheduler
/// This component sends a data buffer to a driver each time it is invoked by a scheduler
class SendBuffImpl final : public SendBuffComponentBase {
class SendBuffImpl final : public SendBuffComponentBase {
public:
// Only called by derived class
SendBuffImpl(const char* compName); //!< constructor
~SendBuffImpl(); //!< destructor
private:
void SchedIn_handler(FwIndexType portNum, U32 context); //!< downcall for input port
void SB_START_PKTS_cmdHandler(FwOpcodeType opcode, U32 cmdSeq); //!< START_PKTS command handler
void SB_INJECT_PKT_ERROR_cmdHandler(FwOpcodeType opcode, U32 cmdSeq); //!< START_PKTS command handler
void SB_GEN_FATAL_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SB_GEN_FATAL_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 arg1, /*!< First FATAL Argument*/
U32 arg2, /*!< Second FATAL Argument*/
@ -29,8 +26,7 @@ namespace Ref {
//! Handler for command SB_GEN_ASSERT
/* Generate an ASSERT */
void SB_GEN_ASSERT_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SB_GEN_ASSERT_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 arg1, /*!< First ASSERT Argument*/
U32 arg2, /*!< Second ASSERT Argument*/
@ -57,6 +53,6 @@ namespace Ref {
SendBuff_ActiveState m_state;
};
}
} // namespace Ref
#endif

View File

@ -17,18 +17,17 @@
// TKC - don't know why it's undefined in VxWorks
#ifdef TGT_OS_TYPE_VXWORKS
#define M_PI (22.0/7.0)
#define M_PI (22.0 / 7.0)
#endif
namespace Ref {
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------
SignalGen ::
SignalGen(const char* name) :
SignalGenComponentBase(name),
SignalGen ::SignalGen(const char* name)
: SignalGenComponentBase(name),
sampleFrequency(25),
signalFrequency(1),
signalAmplitude(0.0f),
@ -42,17 +41,15 @@ namespace Ref {
m_dpInProgress(false),
m_numDps(0),
m_currDp(0),
m_dpPriority(0)
{}
m_dpPriority(0) {}
SignalGen ::~SignalGen() {}
SignalGen :: ~SignalGen() { }
// ----------------------------------------------------------------------
// Handler implementations
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations
// ----------------------------------------------------------------------
F32 SignalGen::generateSample(U32 ticks) {
F32 SignalGen::generateSample(U32 ticks) {
F32 val = 0.0f;
if (this->skipOne) {
return val;
@ -62,26 +59,23 @@ namespace Ref {
U32 halfSamplesPerPeriod = samplesPerPeriod / 2;
/* Signals courtesy of the open source Aquila DSP Library */
switch (this->sigType.e) {
case SignalType::TRIANGLE:
{
case SignalType::TRIANGLE: {
F32 m = this->signalAmplitude / static_cast<F32>(halfSamplesPerPeriod);
val = m * static_cast<F32>(ticks % halfSamplesPerPeriod);
break;
}
case SignalType::SINE:
{
case SignalType::SINE: {
F32 normalizedFrequency = 1.0f / samplesPerPeriod;
val = this->signalAmplitude * std::sin((2.0 * M_PI * normalizedFrequency *
static_cast<F32>(ticks)) + (this->signalPhase * 2.0 * M_PI));
val = this->signalAmplitude * std::sin((2.0 * M_PI * normalizedFrequency * static_cast<F32>(ticks)) +
(this->signalPhase * 2.0 * M_PI));
break;
}
case SignalType::SQUARE:
{
val = this->signalAmplitude * ((ticks % static_cast<U32>(samplesPerPeriod) < halfSamplesPerPeriod) ? 1.0f : -1.0f);
case SignalType::SQUARE: {
val = this->signalAmplitude *
((ticks % static_cast<U32>(samplesPerPeriod) < halfSamplesPerPeriod) ? 1.0f : -1.0f);
break;
}
case SignalType::NOISE:
{
case SignalType::NOISE: {
val = this->signalAmplitude * (std::rand() / static_cast<double>(RAND_MAX));
break;
}
@ -89,13 +83,11 @@ namespace Ref {
FW_ASSERT(0); // Should never happen
}
return val;
}
}
void SignalGen::schedIn_handler(
FwIndexType portNum, /*!< The port number*/
void SignalGen::schedIn_handler(FwIndexType portNum, /*!< The port number*/
U32 context /*!< The call order*/
)
{
) {
F32 value = 0.0f;
// This is a queued component, so it must intentionally run the dispatch of commands and queue processing on this
// synchronous scheduled call
@ -140,10 +132,10 @@ namespace Ref {
this->m_dpBytes += SignalInfo::SERIALIZED_SIZE;
// check for full data product
if (Fw::SerializeStatus::FW_SERIALIZE_NO_ROOM_LEFT == stat) {
this->log_WARNING_LO_DpRecordFull(this->m_currDp,this->m_dpBytes);
this->log_WARNING_LO_DpRecordFull(this->m_currDp, this->m_dpBytes);
this->cleanupAndSendDp();
} else if (this->m_currDp == this->m_numDps) { // if we reached the target number of DPs
this->log_ACTIVITY_LO_DpComplete(this->m_numDps,this->m_dpBytes);
this->log_ACTIVITY_LO_DpComplete(this->m_numDps, this->m_dpBytes);
this->cleanupAndSendDp();
}
@ -152,17 +144,14 @@ namespace Ref {
}
this->ticks += 1;
}
}
void SignalGen::Settings_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SignalGen::Settings_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 Frequency,
F32 Amplitude,
F32 Phase,
Ref::SignalType SigType
)
{
Ref::SignalType SigType) {
this->signalFrequency = Frequency;
this->signalAmplitude = Amplitude;
this->signalPhase = Phase;
@ -176,38 +165,32 @@ namespace Ref {
this->sigPairHistory[i].set_time(0.0f);
this->sigPairHistory[i].set_value(0.0f);
}
this->log_ACTIVITY_LO_SettingsChanged(this->signalFrequency, this->signalAmplitude, this->signalPhase, this->sigType);
this->log_ACTIVITY_LO_SettingsChanged(this->signalFrequency, this->signalAmplitude, this->signalPhase,
this->sigType);
this->tlmWrite_Type(SigType);
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
}
void SignalGen::Toggle_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SignalGen::Toggle_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
)
{
) {
this->running = !this->running;
this->ticks = 0;
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
}
void SignalGen::Skip_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void SignalGen::Skip_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
)
{
) {
this->skipOne = true;
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
}
}
void SignalGen::Dp_cmdHandler(
FwOpcodeType opCode,
void SignalGen::Dp_cmdHandler(FwOpcodeType opCode,
U32 cmdSeq,
Ref::SignalGen_DpReqType reqType,
U32 records,
U32 priority
)
{
U32 priority) {
// at least one record
if (0 == records) {
this->log_WARNING_HI_InSufficientDpRecords();
@ -216,9 +199,7 @@ namespace Ref {
}
// make sure DPs are available
if (
not this->isConnected_productGetOut_OutputPort(0)
) {
if (not this->isConnected_productGetOut_OutputPort(0)) {
this->log_WARNING_HI_DpsNotConnected();
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
return;
@ -226,13 +207,13 @@ namespace Ref {
// get DP buffer. Use sync or async request depending on
// requested type
FwSizeType dpSize = records*(SignalInfo::SERIALIZED_SIZE + sizeof(FwDpIdType));
FwSizeType dpSize = records * (SignalInfo::SERIALIZED_SIZE + sizeof(FwDpIdType));
this->m_numDps = records;
this->m_currDp = 0;
this->m_dpPriority = static_cast<FwDpPriorityType>(priority);
this->log_ACTIVITY_LO_DpMemRequested(dpSize);
if (Ref::SignalGen_DpReqType::IMMEDIATE == reqType) {
Fw::Success stat = this->dpGet_DataContainer(dpSize,this->m_dpContainer);
Fw::Success stat = this->dpGet_DataContainer(dpSize, this->m_dpContainer);
// make sure we got the memory we wanted
if (Fw::Success::FAILURE == stat) {
this->log_WARNING_HI_DpMemoryFail();
@ -250,32 +231,23 @@ namespace Ref {
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
} else {
// should never get here
FW_ASSERT(0,reqType.e);
FW_ASSERT(0, reqType.e);
}
}
}
void SignalGen::cleanupAndSendDp() {
void SignalGen::cleanupAndSendDp() {
this->dpSend(this->m_dpContainer);
this->m_dpInProgress = false;
this->m_dpBytes = 0;
this->m_numDps = 0;
this->m_currDp = 0;
}
}
// ----------------------------------------------------------------------
// Handler implementations for data products
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Handler implementations for data products
// ----------------------------------------------------------------------
void SignalGen ::
dpRecv_DataContainer_handler(
DpContainer& container,
Fw::Success::T status
)
{
void SignalGen ::dpRecv_DataContainer_handler(DpContainer& container, Fw::Success::T status) {
// Make sure we got the buffer we wanted or quit
if (Fw::Success::SUCCESS == status) {
this->m_dpContainer = container;
@ -291,6 +263,6 @@ namespace Ref {
this->m_numDps = 0;
this->m_currDp = 0;
}
}
}
} // namespace Ref

View File

@ -22,62 +22,48 @@
namespace Ref {
class SignalGen final :
public SignalGenComponentBase
{
class SignalGen final : public SignalGenComponentBase {
private:
void schedIn_handler(
FwIndexType portNum, /*!< The port number*/
void schedIn_handler(FwIndexType portNum, /*!< The port number*/
U32 context /*!< The call order*/
) final;
void Settings_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void Settings_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq, /*!< The command sequence number*/
U32 Frequency,
F32 Amplitude,
F32 Phase,
Ref::SignalType SigType
) final;
Ref::SignalType SigType) final;
void Toggle_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void Toggle_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
) final;
void Skip_cmdHandler(
FwOpcodeType opCode, /*!< The opcode*/
void Skip_cmdHandler(FwOpcodeType opCode, /*!< The opcode*/
U32 cmdSeq /*!< The command sequence number*/
) final;
//! Handler implementation for command Dp
//!
//! Signal Generator Settings
void Dp_cmdHandler(
FwOpcodeType opCode, //!< The opcode
void Dp_cmdHandler(FwOpcodeType opCode, //!< The opcode
U32 cmdSeq, //!< The command sequence number
Ref::SignalGen_DpReqType reqType,
U32 records,
U32 priority
) final;
U32 priority) final;
// ----------------------------------------------------------------------
// Handler implementations for data products
// ----------------------------------------------------------------------
//! Receive a container of type DataContainer
void dpRecv_DataContainer_handler(
DpContainer& container, //!< The container
void dpRecv_DataContainer_handler(DpContainer& container, //!< The container
Fw::Success::T status //!< The container status
) final;
public:
//! Construct a SignalGen
SignalGen(
const char* compName //!< The component name
SignalGen(const char* compName //!< The component name
);
//! Destroy a SignalGen
@ -107,7 +93,6 @@ namespace Ref {
U32 m_currDp; //!< current DP number
U32 m_dpBytes; //!< currently serialized records
FwDpPriorityType m_dpPriority; //!< stored priority for current DP
};
}
};
} // namespace Ref
#endif

View File

@ -9,7 +9,7 @@ TEST(Nominal, TestStart) {
tester.test_start();
}
int main(int argc, char **argv) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -14,74 +14,54 @@
namespace Ref {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
SignalGenTester ::
SignalGenTester() :
SignalGenGTestBase("Tester", MAX_HISTORY_SIZE),
component("SignalGen")
{
SignalGenTester ::SignalGenTester() : SignalGenGTestBase("Tester", MAX_HISTORY_SIZE), component("SignalGen") {
this->initComponents();
this->connectPorts();
this->m_reqDpBuff.set(this->m_dpBuff,sizeof(this->m_dpBuff));
}
this->m_reqDpBuff.set(this->m_dpBuff, sizeof(this->m_dpBuff));
}
SignalGenTester ::
~SignalGenTester()
{
SignalGenTester ::~SignalGenTester() {}
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void SignalGenTester ::
test_start()
{
void SignalGenTester ::test_start() {
ASSERT_TLM_Output_SIZE(0);
sendCmd_Toggle(0, 0);
component.doDispatch();
invoke_to_schedIn(0, 0);
component.doDispatch();
ASSERT_TLM_Output_SIZE(1);
sendCmd_Dp(0,10,Ref::SignalGen_DpReqType::IMMEDIATE,1,1);
sendCmd_Dp(0, 10, Ref::SignalGen_DpReqType::IMMEDIATE, 1, 1);
component.doDispatch();
// verify request for data product buffer
ASSERT_PRODUCT_GET_SIZE(1);
// run 2 cycles, should output data product on second
invoke_to_schedIn(0, 0);
ASSERT_PRODUCT_SEND_SIZE(1);
}
}
//! Handle a text event
void SignalGenTester::textLogIn(
FwEventIdType id, //!< The event ID
//! Handle a text event
void SignalGenTester::textLogIn(FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
) {
TextLogEntry e = { id, timeTag, severity, text };
) {
TextLogEntry e = {id, timeTag, severity, text};
printTextLogHistoryEntry(e, stdout);
}
}
Fw::Success::T SignalGenTester ::
productGet_handler(
FwDpIdType id,
FwSizeType dataSize,
Fw::Buffer& buffer
)
{
printf ("Component requested %" PRI_FwSizeType " bytes.\n",dataSize);
buffer.set(this->m_dpBuff,dataSize);
Fw::Success::T SignalGenTester ::productGet_handler(FwDpIdType id, FwSizeType dataSize, Fw::Buffer& buffer) {
printf("Component requested %" PRI_FwSizeType " bytes.\n", dataSize);
buffer.set(this->m_dpBuff, dataSize);
this->pushProductGetEntry(id, dataSize);
return Fw::Success::SUCCESS;
}
}
} // end namespace Ref

View File

@ -13,14 +13,12 @@
#ifndef TESTER_HPP
#define TESTER_HPP
#include "SignalGenGTestBase.hpp"
#include "Ref/SignalGen/SignalGen.hpp"
#include "SignalGenGTestBase.hpp"
namespace Ref {
class SignalGenTester :
public SignalGenGTestBase
{
class SignalGenTester : public SignalGenGTestBase {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
@ -42,7 +40,6 @@ namespace Ref {
~SignalGenTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
@ -52,7 +49,6 @@ namespace Ref {
void test_start();
private:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
@ -66,19 +62,16 @@ namespace Ref {
void initComponents();
private:
//! Handle a data product get from the component under test
//!
//! By default, (1) call pushProductGetEntry; (2) do not allocate a buffer
//! and return FAILURE. You can override this behavior, e.g., to call
//! pushProductGetEntry, allocate a buffer and return SUCCESS.
Fw::Success::T productGet_handler (
FwDpIdType id, //!< The container ID (input)
Fw::Success::T productGet_handler(FwDpIdType id, //!< The container ID (input)
FwSizeType dataSize, //!< The data size of the requested buffer (input)
Fw::Buffer& buffer //!< The buffer (output)
) override;
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
@ -87,8 +80,7 @@ namespace Ref {
//!
SignalGen component;
void textLogIn(
FwEventIdType id, //!< The event ID
void textLogIn(FwEventIdType id, //!< The event ID
const Fw::Time& timeTag, //!< The time
const Fw::LogSeverity severity, //!< The severity
const Fw::TextLogString& text //!< The event string
@ -96,8 +88,7 @@ namespace Ref {
U8 m_dpBuff[1024];
Fw::Buffer m_reqDpBuff;
};
};
} // end namespace Ref

View File

@ -15,7 +15,6 @@
// Necessary project-specified types
#include <Fw/Types/MallocAllocator.hpp>
// Allows easy reference to objects in FPP/autocoder required namespaces
using namespace Ref;
@ -78,7 +77,7 @@ void setupTopology(const TopologyState& state) {
loadParameters();
// Autocoded task kick-off (active components). Function provided by autocoder.
startTasks(state);
//Initialize socket client communication if and only if there is a valid specification
// Initialize socket client communication if and only if there is a valid specification
if (state.hostname != nullptr && state.port != 0) {
Os::TaskString name("ReceiveTask");
comDriver.start(name, COMM_PRIORITY, Default::STACK_SIZE);
@ -102,7 +101,7 @@ void teardownTopology(const TopologyState& state) {
stopTasks(state);
freeThreads(state);
//Stop the comDriver component, free thread
// Stop the comDriver component, free thread
comDriver.stop();
(void)comDriver.join();

View File

@ -67,12 +67,13 @@ void teardownTopology(const TopologyState& state);
/**
* \brief cycle the rate group driver based in a system timer
*
* In order to be a portable demonstration, the reference topology does not have a direct hardware timer that is typically used
* in embedded applications. Instead, a linux system timer is used to drive the rate groups at 1Hz. The slower rate groups are
* derived from this fundamental rate using the RateGroupDriver component to divide the rate down to slower rates.
* In order to be a portable demonstration, the reference topology does not have a direct hardware timer that is
* typically used in embedded applications. Instead, a linux system timer is used to drive the rate groups at 1Hz. The
* slower rate groups are derived from this fundamental rate using the RateGroupDriver component to divide the rate down
* to slower rates.
*
* For embedded Linux, this could be used to drive the system rate groups. For other embedded systems, projects should write components
* that implement whatever timers are available for that platform in place of Svc/LinuxTimer.
* For embedded Linux, this could be used to drive the system rate groups. For other embedded systems, projects should
* write components that implement whatever timers are available for that platform in place of Svc/LinuxTimer.
*
* This loop is stopped via a stopRateGroups call.
*

View File

@ -10,19 +10,18 @@
// ======================================================================
#include <Fw/FPrimeBasicTypes.hpp>
#include <Utils/CRCChecker.hpp>
#include <Fw/Types/Assert.hpp>
#include <Fw/Types/FileNameString.hpp>
#include <Os/File.hpp>
#include <Os/FileSystem.hpp>
#include <Utils/CRCChecker.hpp>
#include <Utils/Hash/Hash.hpp>
#include <Fw/Types/FileNameString.hpp>
namespace Utils {
static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
"Cannot use CRC checker without full string formatting");
crc_stat_t create_checksum_file(const char* const fname)
{
crc_stat_t create_checksum_file(const char* const fname) {
FW_ASSERT(fname != nullptr);
FwSizeType i;
@ -40,26 +39,22 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
U8 block_data[CRC_FILE_READ_BLOCK];
fs_stat = Os::FileSystem::getFileSize(fname, filesize);
if(fs_stat != Os::FileSystem::OP_OK)
{
if (fs_stat != Os::FileSystem::OP_OK) {
return FAILED_FILE_SIZE;
}
// Open file
stat = f.open(fname, Os::File::OPEN_READ);
if(stat != Os::File::OP_OK)
{
if (stat != Os::File::OP_OK) {
return FAILED_FILE_OPEN;
}
// Read file
bytes_to_read = CRC_FILE_READ_BLOCK;
blocks = filesize / CRC_FILE_READ_BLOCK;
for(i = 0; i < blocks; i++)
{
for (i = 0; i < blocks; i++) {
stat = f.read(block_data, bytes_to_read);
if(stat != Os::File::OP_OK || bytes_to_read != CRC_FILE_READ_BLOCK)
{
if (stat != Os::File::OP_OK || bytes_to_read != CRC_FILE_READ_BLOCK) {
f.close();
return FAILED_FILE_READ;
}
@ -69,11 +64,9 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
remaining_bytes = filesize % CRC_FILE_READ_BLOCK;
bytes_to_read = remaining_bytes;
if(remaining_bytes > 0)
{
if (remaining_bytes > 0) {
stat = f.read(block_data, bytes_to_read);
if(stat != Os::File::OP_OK || bytes_to_read != remaining_bytes)
{
if (stat != Os::File::OP_OK || bytes_to_read != remaining_bytes) {
f.close();
return FAILED_FILE_READ;
}
@ -92,16 +85,14 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
FW_ASSERT(formatStatus == Fw::FormatStatus::SUCCESS);
stat = f.open(hashFilename.toChar(), Os::File::OPEN_WRITE);
if(stat != Os::File::OP_OK)
{
if (stat != Os::File::OP_OK) {
return FAILED_FILE_CRC_OPEN;
}
// Write checksum file
bytes_to_write = sizeof(checksum);
stat = f.write(reinterpret_cast<U8*>(&checksum), bytes_to_write);
if(stat != Os::File::OP_OK || sizeof(checksum) != bytes_to_write)
{
if (stat != Os::File::OP_OK || sizeof(checksum) != bytes_to_write) {
f.close();
return FAILED_FILE_CRC_WRITE;
}
@ -110,9 +101,9 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
f.close();
return PASSED_FILE_CRC_WRITE;
}
}
crc_stat_t read_crc32_from_file(const char* const fname, U32 &checksum_from_file) {
crc_stat_t read_crc32_from_file(const char* const fname, U32& checksum_from_file) {
Os::File f;
Os::File::Status stat;
Fw::FileNameString hashFilename;
@ -122,16 +113,14 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
FW_ASSERT(formatStatus == Fw::FormatStatus::SUCCESS);
stat = f.open(hashFilename.toChar(), Os::File::OPEN_READ);
if(stat != Os::File::OP_OK)
{
if (stat != Os::File::OP_OK) {
return FAILED_FILE_CRC_OPEN;
}
// Read checksum file
FwSizeType checksum_from_file_size = static_cast<FwSizeType>(sizeof(checksum_from_file));
stat = f.read(reinterpret_cast<U8*>(&checksum_from_file), checksum_from_file_size);
if(stat != Os::File::OP_OK || checksum_from_file_size != sizeof(checksum_from_file))
{
if (stat != Os::File::OP_OK || checksum_from_file_size != sizeof(checksum_from_file)) {
f.close();
return FAILED_FILE_CRC_READ;
}
@ -139,10 +128,9 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
// close checksum file
f.close();
return PASSED_FILE_CRC_CHECK;
}
}
crc_stat_t verify_checksum(const char* const fname, U32 &expected, U32 &actual)
{
crc_stat_t verify_checksum(const char* const fname, U32& expected, U32& actual) {
FW_ASSERT(fname != nullptr);
FwSizeType i;
@ -159,26 +147,22 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
U8 block_data[CRC_FILE_READ_BLOCK];
fs_stat = Os::FileSystem::getFileSize(fname, filesize);
if(fs_stat != Os::FileSystem::OP_OK)
{
if (fs_stat != Os::FileSystem::OP_OK) {
return FAILED_FILE_SIZE;
}
// Open file
stat = f.open(fname, Os::File::OPEN_READ);
if(stat != Os::File::OP_OK)
{
if (stat != Os::File::OP_OK) {
return FAILED_FILE_OPEN;
}
// Read file
bytes_to_read = CRC_FILE_READ_BLOCK;
blocks = filesize / CRC_FILE_READ_BLOCK;
for(i = 0; i < blocks; i++)
{
for (i = 0; i < blocks; i++) {
stat = f.read(block_data, bytes_to_read);
if(stat != Os::File::OP_OK || bytes_to_read != CRC_FILE_READ_BLOCK)
{
if (stat != Os::File::OP_OK || bytes_to_read != CRC_FILE_READ_BLOCK) {
f.close();
return FAILED_FILE_READ;
}
@ -188,11 +172,9 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
remaining_bytes = filesize % CRC_FILE_READ_BLOCK;
bytes_to_read = remaining_bytes;
if(remaining_bytes > 0)
{
if (remaining_bytes > 0) {
stat = f.read(block_data, bytes_to_read);
if(stat != Os::File::OP_OK || bytes_to_read != remaining_bytes)
{
if (stat != Os::File::OP_OK || bytes_to_read != remaining_bytes) {
f.close();
return FAILED_FILE_READ;
}
@ -211,8 +193,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
}
// compare checksums
if(checksum != checksum_from_file)
{
if (checksum != checksum_from_file) {
expected = checksum_from_file;
actual = checksum;
return FAILED_FILE_CRC_CHECK;
@ -221,6 +202,6 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
expected = checksum_from_file;
actual = checksum;
return PASSED_FILE_CRC_CHECK;
}
}
} // namespace Utils

View File

@ -17,11 +17,9 @@
namespace Utils {
static const FwSignedSizeType CRC_FILE_READ_BLOCK = CONFIG_CRC_FILE_READ_BLOCK ;
static const FwSignedSizeType CRC_FILE_READ_BLOCK = CONFIG_CRC_FILE_READ_BLOCK;
typedef enum
{
typedef enum {
PASSED_FILE_CRC_CHECK = 0,
PASSED_FILE_CRC_WRITE,
FAILED_FILE_SIZE,
@ -32,12 +30,12 @@ namespace Utils {
FAILED_FILE_CRC_READ,
FAILED_FILE_CRC_WRITE,
FAILED_FILE_CRC_CHECK
} crc_stat_t;
} crc_stat_t;
crc_stat_t create_checksum_file(const char* const filename);
crc_stat_t read_crc32_from_file(const char* const fname, U32 &checksum_from_file);
crc_stat_t verify_checksum(const char* const filename, U32 &expected, U32 &actual);
crc_stat_t create_checksum_file(const char* const filename);
crc_stat_t read_crc32_from_file(const char* const fname, U32& checksum_from_file);
crc_stat_t verify_checksum(const char* const filename, U32& expected, U32& actual);
}
} // namespace Utils
#endif

View File

@ -13,23 +13,20 @@
#ifndef UTILS_HASH_HPP
#define UTILS_HASH_HPP
#include "Fw/Types/StringType.hpp"
#include <Utils/Hash/HashBuffer.hpp>
#include "Fw/Types/StringType.hpp"
namespace Utils {
//! \class Hash
//! \brief A generic interface for creating and comparing hash values
//!
class Hash {
//! \class Hash
//! \brief A generic interface for creating and comparing hash values
//!
class Hash {
public:
// ----------------------------------------------------------------------
// Types
// ----------------------------------------------------------------------
public:
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
@ -43,7 +40,6 @@ namespace Utils {
~Hash();
public:
// ----------------------------------------------------------------------
// Public static methods
// ----------------------------------------------------------------------
@ -52,14 +48,9 @@ namespace Utils {
//! \param data: pointer to start of data
//! \param len: length of the data
//! \param buffer: filled with resulting hash value
static void hash(
const void *data,
const FwSizeType len,
HashBuffer& buffer
);
static void hash(const void* data, const FwSizeType len, HashBuffer& buffer);
public:
// ----------------------------------------------------------------------
// Public instance methods
// ----------------------------------------------------------------------
@ -70,27 +61,22 @@ namespace Utils {
//! Set hash value to specified value
//!
void setHashValue(
HashBuffer &value //! Hash value
void setHashValue(HashBuffer& value //! Hash value
);
//! Update an incremental computation with new data
//! \param data: pointer to start of data to add to hash calculation
//! \param len: length of data to add to hash calculation
void update(
const void *const data,
const FwSizeType len
void update(const void* const data, const FwSizeType len);
//! Finalize an incremental computation and return the result
//!
void final(HashBuffer& buffer //! The result
);
//! Finalize an incremental computation and return the result
//!
void final(
HashBuffer& buffer //! The result
);
//! Finalize an incremental computation and return the result
//!
void final(U32 &hashvalue);
void final(U32& hashvalue);
//! Get the file extension for the supported hash type
//! E.g., could return "SHA256"
@ -99,8 +85,7 @@ namespace Utils {
//! Add the extension for the supported hash type
//!
static void addFileExtension(
const Fw::StringBase& baseName, //!< The base name
static void addFileExtension(const Fw::StringBase& baseName, //!< The base name
Fw::StringBase& extendedName //!< The extended name
);
@ -109,7 +94,6 @@ namespace Utils {
static FwSizeType getFileExtensionLength();
private:
// ----------------------------------------------------------------------
// Private member variables
// ----------------------------------------------------------------------
@ -117,9 +101,8 @@ namespace Utils {
//! The hash handle
//!
HASH_HANDLE_TYPE hash_handle;
};
};
}
} // namespace Utils
#endif

View File

@ -2,26 +2,18 @@
namespace Utils {
const char* Hash ::
getFileExtensionString()
{
const char* Hash ::getFileExtensionString() {
return HASH_EXTENSION_STRING;
}
}
void Hash ::
addFileExtension(
const Fw::StringBase& baseName,
Fw::StringBase& extendedName
) {
void Hash ::addFileExtension(const Fw::StringBase& baseName, Fw::StringBase& extendedName) {
extendedName.format("%s%s", baseName.toChar(), HASH_EXTENSION_STRING);
}
}
FwSizeType Hash ::
getFileExtensionLength()
{
FwSizeType Hash ::getFileExtensionLength() {
// Size of returns the size including the '\0' character.
// We want to return just the size of the string.
return sizeof(HASH_EXTENSION_STRING) - 1;
}
}
} // namespace Utils

View File

@ -14,80 +14,62 @@
static_assert(sizeof(unsigned long) >= sizeof(U32), "CRC32 cannot fit in CRC32 library chosen types");
namespace Utils {
Hash ::
Hash()
{
Hash ::Hash() {
this->init();
}
}
Hash ::
~Hash()
{
}
Hash ::~Hash() {}
void Hash ::
hash(const void *const data, const FwSizeType len, HashBuffer& buffer)
{
void Hash ::hash(const void* const data, const FwSizeType len, HashBuffer& buffer) {
HASH_HANDLE_TYPE local_hash_handle;
local_hash_handle = 0xffffffffL;
FW_ASSERT(data);
char c;
for(FwSizeType index = 0; index < len; index++) {
for (FwSizeType index = 0; index < len; index++) {
c = static_cast<const char*>(data)[index];
local_hash_handle = static_cast<HASH_HANDLE_TYPE>(update_crc_32(local_hash_handle, c));
}
HashBuffer bufferOut;
// For CRC32 we need to return the one's complement of the result:
Fw::SerializeStatus status = bufferOut.serialize(~(local_hash_handle));
FW_ASSERT( Fw::FW_SERIALIZE_OK == status );
FW_ASSERT(Fw::FW_SERIALIZE_OK == status);
buffer = bufferOut;
}
}
void Hash ::
init()
{
void Hash ::init() {
this->hash_handle = 0xffffffffL;
}
}
void Hash ::
update(const void *const data, FwSizeType len)
{
void Hash ::update(const void* const data, FwSizeType len) {
FW_ASSERT(data);
char c;
for(FwSizeType index = 0; index < len; index++) {
for (FwSizeType index = 0; index < len; index++) {
c = static_cast<const char*>(data)[index];
this->hash_handle = static_cast<HASH_HANDLE_TYPE>(update_crc_32(this->hash_handle, c));
}
}
}
void Hash ::
final(HashBuffer& buffer)
{
void Hash ::final(HashBuffer& buffer) {
HashBuffer bufferOut;
// For CRC32 we need to return the one's complement of the result:
Fw::SerializeStatus status = bufferOut.serialize(~(this->hash_handle));
FW_ASSERT( Fw::FW_SERIALIZE_OK == status );
FW_ASSERT(Fw::FW_SERIALIZE_OK == status);
buffer = bufferOut;
}
}
void Hash ::
final(U32 &hashvalue)
{
void Hash ::final(U32& hashvalue) {
FW_ASSERT(sizeof(this->hash_handle) == sizeof(U32));
// For CRC32 we need to return the one's complement of the result:
hashvalue = ~(this->hash_handle);
}
}
void Hash ::
setHashValue(HashBuffer &value)
{
void Hash ::setHashValue(HashBuffer& value) {
Fw::SerializeStatus status = value.deserialize(this->hash_handle);
FW_ASSERT( Fw::FW_SERIALIZE_OK == status );
FW_ASSERT(Fw::FW_SERIALIZE_OK == status);
// Expecting `value` to already be one's complement; so doing one's complement
// here for correct hash updates
this->hash_handle = ~this->hash_handle;
}
}
} // namespace Utils

View File

@ -3,7 +3,7 @@
// Include the lic crc c library:
extern "C" {
#include <Utils/Hash/libcrc/lib_crc.h>
#include <Utils/Hash/libcrc/lib_crc.h>
}
//! Define the hash handle type for this

View File

@ -1,3 +1,4 @@
// clang-format off
#include "lib_crc.h"

View File

@ -1,3 +1,4 @@
// clang-format off
/*******************************************************************\
* *
* Library : lib_crc *

View File

@ -1,3 +1,4 @@
// clang-format off
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -14,49 +14,36 @@
namespace Utils {
Hash ::
Hash()
{
Hash ::Hash() {
this->init();
}
}
Hash ::
~Hash()
{
}
Hash ::~Hash() {}
void Hash ::
hash(const void *const data, const FwSizeType len, HashBuffer& buffer)
{
void Hash ::hash(const void* const data, const FwSizeType len, HashBuffer& buffer) {
U8 out[SHA256_DIGEST_LENGTH];
U8* ret = SHA256(static_cast<const U8*>(data), len, out);
FW_ASSERT(ret != nullptr);
HashBuffer bufferOut(out, sizeof(out));
buffer = bufferOut;
}
}
void Hash ::
init()
{
void Hash ::init() {
int ret = SHA256_Init(&this->hash_handle);
FW_ASSERT(ret == 1);
}
}
void Hash ::
update(const void *const data, FwSizeType len)
{
void Hash ::update(const void* const data, FwSizeType len) {
int ret = SHA256_Update(&this->hash_handle, static_cast<const U8*>(data), len);
FW_ASSERT(ret == 1);
}
}
void Hash ::
final(HashBuffer& buffer)
{
void Hash ::final(HashBuffer& buffer) {
U8 out[SHA256_DIGEST_LENGTH];
int ret = SHA256_Final(out, &this->hash_handle);
FW_ASSERT(ret == 1);
HashBuffer bufferOut(out, sizeof(out));
buffer = bufferOut;
}
}
} // namespace Utils

View File

@ -1,3 +1,4 @@
// clang-format off
/* crypto/sha/sha.h */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.

View File

@ -13,83 +13,46 @@
namespace Utils {
RateLimiter ::
RateLimiter (
U32 counterCycle,
U32 timeCycle
) :
m_counterCycle(counterCycle),
m_timeCycle(timeCycle)
{
RateLimiter ::RateLimiter(U32 counterCycle, U32 timeCycle) : m_counterCycle(counterCycle), m_timeCycle(timeCycle) {
this->reset();
}
}
RateLimiter ::
RateLimiter () :
m_counterCycle(0),
m_timeCycle(0)
{
RateLimiter ::RateLimiter() : m_counterCycle(0), m_timeCycle(0) {
this->reset();
}
}
void RateLimiter ::
setCounterCycle(
U32 counterCycle
)
{
void RateLimiter ::setCounterCycle(U32 counterCycle) {
this->m_counterCycle = counterCycle;
}
}
void RateLimiter ::
setTimeCycle(
U32 timeCycle
)
{
void RateLimiter ::setTimeCycle(U32 timeCycle) {
this->m_timeCycle = timeCycle;
}
}
void RateLimiter ::
reset()
{
void RateLimiter ::reset() {
this->resetCounter();
this->resetTime();
}
}
void RateLimiter ::
resetCounter()
{
void RateLimiter ::resetCounter() {
this->m_counter = 0;
}
}
void RateLimiter ::
resetTime()
{
void RateLimiter ::resetTime() {
this->m_time = Fw::Time();
this->m_timeAtNegativeInfinity = true;
}
}
void RateLimiter ::
setCounter(
U32 counter
)
{
void RateLimiter ::setCounter(U32 counter) {
this->m_counter = counter;
}
}
void RateLimiter ::
setTime(
Fw::Time time
)
{
void RateLimiter ::setTime(Fw::Time time) {
this->m_time = time;
this->m_timeAtNegativeInfinity = false;
}
}
bool RateLimiter ::
trigger(
Fw::Time time
)
{
bool RateLimiter ::trigger(Fw::Time time) {
// NB: this implements a 4-bit decision, logically equivalent to this pseudo-code
//
// A = HAS_COUNTER, B = HAS_TIME, C = COUNTER_TRIGGER, D = TIME_TRIGGER
@ -122,29 +85,23 @@ namespace Utils {
}
return shouldTrigger;
}
}
bool RateLimiter ::
trigger()
{
bool RateLimiter ::trigger() {
FW_ASSERT(this->m_timeCycle == 0);
return trigger(Fw::Time::zero());
}
}
bool RateLimiter ::
shouldCounterTrigger()
{
bool RateLimiter ::shouldCounterTrigger() {
FW_ASSERT(this->m_counterCycle > 0);
// trigger at 0
bool shouldTrigger = (this->m_counter == 0);
return shouldTrigger;
}
}
bool RateLimiter ::
shouldTimeTrigger(Fw::Time time)
{
bool RateLimiter ::shouldTimeTrigger(Fw::Time time) {
FW_ASSERT(this->m_timeCycle > 0);
// trigger at prev trigger time + time cycle seconds OR when time is at negative infinity
@ -153,11 +110,9 @@ namespace Utils {
bool shouldTrigger = (time >= nextTrigger) || this->m_timeAtNegativeInfinity;
return shouldTrigger;
}
}
void RateLimiter ::
updateCounter(bool triggered)
{
void RateLimiter ::updateCounter(bool triggered) {
FW_ASSERT(this->m_counterCycle > 0);
if (triggered) {
@ -170,11 +125,9 @@ namespace Utils {
this->m_counter = 0;
}
}
}
}
void RateLimiter ::
updateTime(bool triggered, Fw::Time time)
{
void RateLimiter ::updateTime(bool triggered, Fw::Time time) {
FW_ASSERT(this->m_timeCycle > 0);
if (triggered) {
@ -182,6 +135,6 @@ namespace Utils {
this->m_time = time;
}
this->m_timeAtNegativeInfinity = false;
}
}
} // end namespace Utils

View File

@ -18,11 +18,8 @@
namespace Utils {
class RateLimiter
{
class RateLimiter {
public:
// Construct with defined cycles
RateLimiter(U32 counterCycle, U32 timeCycle);
@ -30,7 +27,6 @@ namespace Utils {
RateLimiter();
public:
// Adjust cycles at run-time
void setCounterCycle(U32 counterCycle);
void setTimeCycle(U32 timeCycle);
@ -58,7 +54,6 @@ namespace Utils {
void setTime(Fw::Time time);
private:
// Helper functions to update each independently
bool shouldCounterTrigger();
bool shouldTimeTrigger(Fw::Time time);
@ -66,7 +61,6 @@ namespace Utils {
void updateTime(bool triggered, Fw::Time time);
private:
// parameters
U32 m_counterCycle;
U32 m_timeCycle;
@ -75,7 +69,7 @@ namespace Utils {
U32 m_counter;
Fw::Time m_time;
bool m_timeAtNegativeInfinity;
};
};
} // end namespace Utils

View File

@ -36,7 +36,6 @@
//
// See below for detailed descriptions
// SEND_CMD
//
// Send a command and expect a response status. This command essentially calls
@ -50,11 +49,10 @@
// SEND_CMD(PWR_SW_MGR_SET_DUTY_CYCLE, Fw::CmdResponse::OK, channel, dutyCycle);
// SEND_CMD(PWR_SW_MGR_PWR_ON, Fw::COMMAND_EXECUTION_ERROR, illegalChannel);
//
#define SEND_CMD(cmd, status, ...) \
SEND_CMD_COMP(TEST_COMP, cmd, status, ## __VA_ARGS__)
#define SEND_CMD(cmd, status, ...) SEND_CMD_COMP(TEST_COMP, cmd, status, ##__VA_ARGS__)
#define SEND_CMD_COMP(comp, cmd, status, ...) \
this->sendCmd_ ## cmd(INSTANCE, CMD_SEQ, ## __VA_ARGS__); \
this->sendCmd_##cmd(INSTANCE, CMD_SEQ, ##__VA_ARGS__); \
this->component.doDispatch(); \
ASSERT_LAST_CMD(cmd, status);
@ -67,11 +65,10 @@
// SEND_CMD_NO_EXPECT(FILE_DWN_SEND_APID, 100, 0, 0, 0);
// // ...
//
#define SEND_CMD_NO_EXPECT(cmd, ...) \
SEND_CMD_COMP_NO_EXPECT(TEST_COMP, cmd, ## __VA_ARGS__)
#define SEND_CMD_NO_EXPECT(cmd, ...) SEND_CMD_COMP_NO_EXPECT(TEST_COMP, cmd, ##__VA_ARGS__)
#define SEND_CMD_COMP_NO_EXPECT(comp, cmd, ...) \
this->sendCmd_ ## cmd(INSTANCE, CMD_SEQ, ## __VA_ARGS__); \
this->sendCmd_##cmd(INSTANCE, CMD_SEQ, ##__VA_ARGS__); \
this->component.doDispatch();
// ASSERT_LAST_CMD
@ -86,12 +83,11 @@
// // ...
// ASSERT_LAST_CMD(FILE_DWN_SEND_APID, Fw::CmdResponse::OK);
//
#define ASSERT_LAST_CMD(cmd, status) \
ASSERT_LAST_CMD_COMP(TEST_COMP, cmd, status)
#define ASSERT_LAST_CMD(cmd, status) ASSERT_LAST_CMD_COMP(TEST_COMP, cmd, status)
#define ASSERT_LAST_CMD_COMP(comp, cmd, status) \
ASSERT_GT(this->cmdResponseHistory->size(), 0); \
ASSERT_CMD_RESPONSE(this->cmdResponseHistory->size()-1, comp::OPCODE_ ## cmd, CMD_SEQ, status);
ASSERT_CMD_RESPONSE(this->cmdResponseHistory->size() - 1, comp::OPCODE_##cmd, CMD_SEQ, status);
// ASSERT_LAST_TLM
//
@ -103,8 +99,8 @@
// ASSERT_LAST_TLM(NeaCamManager_PatternDataSize, 0);
//
#define ASSERT_LAST_TLM(name, value) \
ASSERT_GT(this->tlmHistory_ ## name->size(), 0); \
ASSERT_TLM_ ## name(this->tlmHistory_ ## name->size()-1, value);
ASSERT_GT(this->tlmHistory_##name->size(), 0); \
ASSERT_TLM_##name(this->tlmHistory_##name->size() - 1, value);
// ASSERT_LAST_EVENT
//
@ -116,8 +112,8 @@
// ASSERT_LAST_EVENT(PwrSwitchManager_DutyCyclingNotEnabled, i);
//
#define ASSERT_LAST_EVENT(name, ...) \
ASSERT_GT(this->eventHistory_ ## name->size(), 0); \
ASSERT_EVENTS_ ## name(this->eventHistory_ ## name->size()-1, ## __VA_ARGS__);
ASSERT_GT(this->eventHistory_##name->size(), 0); \
ASSERT_EVENTS_##name(this->eventHistory_##name->size() - 1, ##__VA_ARGS__);
// ASSERT_LAST_PORT_OUT
//
@ -130,8 +126,7 @@
// ASSERT_LAST_PORT_OUT(PingResponse, 0, 0xDEADBEEF);
//
#define ASSERT_LAST_PORT_OUT(port, ...) \
ASSERT_GT(this->fromPortHistory_ ## port->size(), 0); \
ASSERT_from_ ## port(__VA_ARGS__);
ASSERT_GT(this->fromPortHistory_##port->size(), 0); \
ASSERT_from_##port(__VA_ARGS__);
#endif

View File

@ -15,97 +15,57 @@
namespace Utils {
TokenBucket ::
TokenBucket (
U32 replenishInterval,
U32 maxTokens,
U32 replenishRate,
U32 startTokens,
Fw::Time startTime
) :
m_replenishInterval(replenishInterval),
TokenBucket ::TokenBucket(U32 replenishInterval, U32 maxTokens, U32 replenishRate, U32 startTokens, Fw::Time startTime)
: m_replenishInterval(replenishInterval),
m_maxTokens(maxTokens),
m_replenishRate(replenishRate),
m_tokens(startTokens),
m_time(startTime)
{
}
m_time(startTime) {}
TokenBucket ::
TokenBucket (
U32 replenishInterval,
U32 maxTokens
) :
m_replenishInterval(replenishInterval),
TokenBucket ::TokenBucket(U32 replenishInterval, U32 maxTokens)
: m_replenishInterval(replenishInterval),
m_maxTokens(maxTokens),
m_replenishRate(1),
m_tokens(maxTokens),
m_time(0, 0)
{
m_time(0, 0) {
FW_ASSERT(this->m_maxTokens <= MAX_TOKEN_BUCKET_TOKENS, static_cast<FwAssertArgType>(this->m_maxTokens));
}
}
void TokenBucket ::
setReplenishInterval(
U32 replenishInterval
)
{
void TokenBucket ::setReplenishInterval(U32 replenishInterval) {
this->m_replenishInterval = replenishInterval;
}
}
void TokenBucket ::
setMaxTokens(
U32 maxTokens
)
{
void TokenBucket ::setMaxTokens(U32 maxTokens) {
this->m_maxTokens = maxTokens;
}
}
void TokenBucket ::
setReplenishRate(
U32 replenishRate
)
{
void TokenBucket ::setReplenishRate(U32 replenishRate) {
this->m_replenishRate = replenishRate;
}
}
void TokenBucket ::
replenish()
{
void TokenBucket ::replenish() {
if (this->m_tokens < this->m_maxTokens) {
this->m_tokens = this->m_maxTokens;
}
}
}
U32 TokenBucket ::
getReplenishInterval() const
{
U32 TokenBucket ::getReplenishInterval() const {
return this->m_replenishInterval;
}
}
U32 TokenBucket ::
getMaxTokens() const
{
U32 TokenBucket ::getMaxTokens() const {
return this->m_maxTokens;
}
}
U32 TokenBucket ::
getReplenishRate() const
{
U32 TokenBucket ::getReplenishRate() const {
return this->m_replenishRate;
}
}
U32 TokenBucket ::
getTokens() const
{
U32 TokenBucket ::getTokens() const {
return this->m_tokens;
}
}
bool TokenBucket ::
trigger(
const Fw::Time time
)
{
bool TokenBucket ::trigger(const Fw::Time time) {
// attempt replenishing
if (this->m_replenishRate > 0) {
Fw::Time replenishInterval = Fw::Time(this->m_replenishInterval / 1000000, this->m_replenishInterval % 1000000);
@ -129,6 +89,6 @@ namespace Utils {
} else {
return false;
}
}
}
} // end namespace Utils

View File

@ -21,11 +21,8 @@
namespace Utils {
class TokenBucket
{
class TokenBucket {
public:
// Full constructor
//
// replenishInterval is in microseconds
@ -36,7 +33,6 @@ namespace Utils {
TokenBucket(U32 replenishInterval, U32 maxTokens);
public:
// Adjust settings at runtime
void setMaxTokens(U32 maxTokens);
void setReplenishInterval(U32 replenishInterval);
@ -61,7 +57,6 @@ namespace Utils {
bool trigger(const Fw::Time time);
private:
// parameters
U32 m_replenishInterval;
U32 m_maxTokens;
@ -70,7 +65,7 @@ namespace Utils {
// state
U32 m_tokens;
Fw::Time m_time;
};
};
} // end namespace Utils

View File

@ -18,27 +18,15 @@
namespace Types {
CircularBuffer :: CircularBuffer() :
m_store(nullptr),
m_store_size(0),
m_head_idx(0),
m_allocated_size(0),
m_high_water_mark(0)
{
CircularBuffer ::CircularBuffer()
: m_store(nullptr), m_store_size(0), m_head_idx(0), m_allocated_size(0), m_high_water_mark(0) {}
}
CircularBuffer :: CircularBuffer(U8* const buffer, const FwSizeType size) :
m_store(nullptr),
m_store_size(0),
m_head_idx(0),
m_allocated_size(0),
m_high_water_mark(0)
{
CircularBuffer ::CircularBuffer(U8* const buffer, const FwSizeType size)
: m_store(nullptr), m_store_size(0), m_head_idx(0), m_allocated_size(0), m_high_water_mark(0) {
setup(buffer, size);
}
void CircularBuffer :: setup(U8* const buffer, const FwSizeType size) {
void CircularBuffer ::setup(U8* const buffer, const FwSizeType size) {
FW_ASSERT(size > 0);
FW_ASSERT(buffer != nullptr);
FW_ASSERT(m_store == nullptr && m_store_size == 0); // Not already setup
@ -51,22 +39,22 @@ void CircularBuffer :: setup(U8* const buffer, const FwSizeType size) {
m_high_water_mark = 0;
}
FwSizeType CircularBuffer :: get_allocated_size() const {
FwSizeType CircularBuffer ::get_allocated_size() const {
return m_allocated_size;
}
FwSizeType CircularBuffer :: get_free_size() const {
FwSizeType CircularBuffer ::get_free_size() const {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
FW_ASSERT(m_allocated_size <= m_store_size, static_cast<FwAssertArgType>(m_allocated_size));
return m_store_size - m_allocated_size;
}
FwSizeType CircularBuffer :: advance_idx(FwSizeType idx, FwSizeType amount) const {
FwSizeType CircularBuffer ::advance_idx(FwSizeType idx, FwSizeType amount) const {
FW_ASSERT(idx < m_store_size, static_cast<FwAssertArgType>(idx));
return (idx + amount) % m_store_size;
}
Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const FwSizeType size) {
Fw::SerializeStatus CircularBuffer ::serialize(const U8* const buffer, const FwSizeType size) {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
FW_ASSERT(buffer != nullptr);
// Check there is sufficient space
@ -86,12 +74,12 @@ Fw::SerializeStatus CircularBuffer :: serialize(const U8* const buffer, const Fw
return Fw::FW_SERIALIZE_OK;
}
Fw::SerializeStatus CircularBuffer :: peek(char& value, FwSizeType offset) const {
Fw::SerializeStatus CircularBuffer ::peek(char& value, FwSizeType offset) const {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
return peek(reinterpret_cast<U8&>(value), offset);
}
Fw::SerializeStatus CircularBuffer :: peek(U8& value, FwSizeType offset) const {
Fw::SerializeStatus CircularBuffer ::peek(U8& value, FwSizeType offset) const {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
// Check there is sufficient data
if ((sizeof(U8) + offset) > m_allocated_size) {
@ -103,7 +91,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8& value, FwSizeType offset) const {
return Fw::FW_SERIALIZE_OK;
}
Fw::SerializeStatus CircularBuffer :: peek(U32& value, FwSizeType offset) const {
Fw::SerializeStatus CircularBuffer ::peek(U32& value, FwSizeType offset) const {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
// Check there is sufficient data
if ((sizeof(U32) + offset) > m_allocated_size) {
@ -121,7 +109,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U32& value, FwSizeType offset) const
return Fw::FW_SERIALIZE_OK;
}
Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, FwSizeType size, FwSizeType offset) const {
Fw::SerializeStatus CircularBuffer ::peek(U8* buffer, FwSizeType size, FwSizeType offset) const {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
FW_ASSERT(buffer != nullptr);
// Check there is sufficient data
@ -138,7 +126,7 @@ Fw::SerializeStatus CircularBuffer :: peek(U8* buffer, FwSizeType size, FwSizeTy
return Fw::FW_SERIALIZE_OK;
}
Fw::SerializeStatus CircularBuffer :: rotate(FwSizeType amount) {
Fw::SerializeStatus CircularBuffer ::rotate(FwSizeType amount) {
FW_ASSERT(m_store != nullptr && m_store_size != 0); // setup method was called
// Check there is sufficient data
if (amount > m_allocated_size) {
@ -162,4 +150,4 @@ void CircularBuffer ::clear_high_water_mark() {
m_high_water_mark = 0;
}
} //End Namespace Types
} // End Namespace Types

View File

@ -23,7 +23,6 @@
namespace Types {
class CircularBuffer {
friend class CircularBufferTester;
public:
@ -155,6 +154,5 @@ class CircularBuffer {
//! Maximum allocated size
FwSizeType m_high_water_mark;
};
} //End Namespace Types
} // End Namespace Types
#endif

View File

@ -14,32 +14,28 @@ namespace Types {
Queue::Queue() : m_internal(), m_message_size(0) {}
void Queue::setup(U8* const storage, const FwSizeType storage_size, const FwSizeType depth, const FwSizeType message_size) {
void Queue::setup(U8* const storage,
const FwSizeType storage_size,
const FwSizeType depth,
const FwSizeType message_size) {
// Ensure that enough storage was supplied
const FwSizeType total_needed_size = depth * message_size;
FW_ASSERT(
storage_size >= total_needed_size,
static_cast<FwAssertArgType>(storage_size),
static_cast<FwAssertArgType>(depth),
static_cast<FwAssertArgType>(message_size));
FW_ASSERT(storage_size >= total_needed_size, static_cast<FwAssertArgType>(storage_size),
static_cast<FwAssertArgType>(depth), static_cast<FwAssertArgType>(message_size));
m_internal.setup(storage, total_needed_size);
m_message_size = message_size;
}
Fw::SerializeStatus Queue::enqueue(const U8* const message, const FwSizeType size) {
FW_ASSERT(m_message_size > 0, static_cast<FwAssertArgType>(m_message_size)); // Ensure initialization
FW_ASSERT(
m_message_size == size,
static_cast<FwAssertArgType>(size),
FW_ASSERT(m_message_size == size, static_cast<FwAssertArgType>(size),
static_cast<FwAssertArgType>(m_message_size)); // Message size is as expected
return m_internal.serialize(message, m_message_size);
}
Fw::SerializeStatus Queue::dequeue(U8* const message, const FwSizeType size) {
FW_ASSERT(m_message_size > 0); // Ensure initialization
FW_ASSERT(
m_message_size <= size,
static_cast<FwAssertArgType>(size),
FW_ASSERT(m_message_size <= size, static_cast<FwAssertArgType>(size),
static_cast<FwAssertArgType>(m_message_size)); // Sufficient storage space for read message
Fw::SerializeStatus result = m_internal.peek(message, m_message_size, 0);
if (result != Fw::FW_SERIALIZE_OK) {
@ -62,5 +58,4 @@ FwSizeType Queue::getQueueSize() const {
return m_internal.get_allocated_size() / m_message_size;
}
} // namespace Types

View File

@ -6,7 +6,4 @@
#include "CircularBufferTester.hpp"
namespace Types {
}
namespace Types {}

View File

@ -11,20 +11,17 @@
namespace Types {
class CircularBufferTester{
class CircularBufferTester {
public:
static void tester_m_allocated_size_decrement(Types::CircularBuffer &circular_buffer){
static void tester_m_allocated_size_decrement(Types::CircularBuffer& circular_buffer) {
circular_buffer.m_allocated_size--;
}
static FwSizeType tester_get_m_head_idx(Types::CircularBuffer &circular_buffer){
static FwSizeType tester_get_m_head_idx(Types::CircularBuffer& circular_buffer) {
return circular_buffer.m_head_idx;
}
};
};
}
} // namespace Types
#endif

View File

@ -9,84 +9,64 @@
*/
#include "CircularRules.hpp"
#include <cstdlib>
#include <cmath>
#include <cstdlib>
namespace Types {
RandomizeRule::RandomizeRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
RandomizeRule::RandomizeRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool RandomizeRule::precondition(const MockTypes::CircularState& state) {
bool RandomizeRule::precondition(const MockTypes::CircularState& state) {
return true;
}
}
void RandomizeRule::action(MockTypes::CircularState& truth) {
(void)truth.generateRandomBuffer();
}
void RandomizeRule::action(MockTypes::CircularState& truth) {
(void) truth.generateRandomBuffer();
}
SerializeOkRule::SerializeOkRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
SerializeOkRule::SerializeOkRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool SerializeOkRule::precondition(const MockTypes::CircularState& state) {
bool SerializeOkRule::precondition(const MockTypes::CircularState& state) {
return state.getRemainingSize() >= state.getRandomSize();
}
}
void SerializeOkRule::action(MockTypes::CircularState& state) {
void SerializeOkRule::action(MockTypes::CircularState& state) {
state.checkSizes();
Fw::SerializeStatus status = state.getTestBuffer().serialize(state.getBuffer(), state.getRandomSize());
state.setRemainingSize(state.getRemainingSize() - state.getRandomSize());
ASSERT_TRUE(state.addInfinite(state.getBuffer(), state.getRandomSize()));
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
state.checkSizes();
}
}
SerializeOverflowRule::SerializeOverflowRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
SerializeOverflowRule::SerializeOverflowRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool SerializeOverflowRule::precondition(const MockTypes::CircularState& state) {
bool SerializeOverflowRule::precondition(const MockTypes::CircularState& state) {
return state.getRemainingSize() < state.getRandomSize();
}
}
void SerializeOverflowRule::action(MockTypes::CircularState& state) {
void SerializeOverflowRule::action(MockTypes::CircularState& state) {
Fw::SerializeStatus status = state.getTestBuffer().serialize(state.getBuffer(), state.getRandomSize());
ASSERT_EQ(status, Fw::FW_SERIALIZE_NO_ROOM_LEFT);
}
}
PeekOkRule::PeekOkRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
PeekOkRule::PeekOkRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool PeekOkRule::precondition(const MockTypes::CircularState& state) {
bool PeekOkRule::precondition(const MockTypes::CircularState& state) {
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
if (state.getPeekType() == 0 ) {
if (state.getPeekType() == 0) {
return peek_available >= sizeof(I8) + state.getPeekOffset();
}
else if (state.getPeekType() == 1) {
} else if (state.getPeekType() == 1) {
return peek_available >= sizeof(U8) + state.getPeekOffset();
}
else if (state.getPeekType() == 2) {
} else if (state.getPeekType() == 2) {
return peek_available >= sizeof(U32) + state.getPeekOffset();
}
else if (state.getPeekType() == 3) {
} else if (state.getPeekType() == 3) {
return peek_available >= state.getRandomSize() + state.getPeekOffset();
}
return false;
}
}
void PeekOkRule::action(MockTypes::CircularState& state) {
void PeekOkRule::action(MockTypes::CircularState& state) {
U8* buffer = nullptr;
char peek_char = 0;
U8 peek_u8 = 0;
@ -98,14 +78,12 @@ namespace Types {
peek_char = static_cast<char>(buffer[0]);
ASSERT_EQ(state.getTestBuffer().peek(peek_char, state.getPeekOffset()), Fw::FW_SERIALIZE_OK);
ASSERT_EQ(static_cast<char>(buffer[0]), peek_char);
}
else if (state.getPeekType() == 1) {
} else if (state.getPeekType() == 1) {
ASSERT_TRUE(state.peek(buffer, sizeof(U8), state.getPeekOffset()));
peek_u8 = static_cast<U8>(buffer[0]);
ASSERT_EQ(state.getTestBuffer().peek(peek_u8, state.getPeekOffset()), Fw::FW_SERIALIZE_OK);
ASSERT_EQ(buffer[0], peek_u8);
}
else if (state.getPeekType() == 2) {
} else if (state.getPeekType() == 2) {
ASSERT_TRUE(state.peek(buffer, sizeof(U32), state.getPeekOffset()));
ASSERT_EQ(state.getTestBuffer().peek(peek_u32, state.getPeekOffset()), Fw::FW_SERIALIZE_OK);
// Big-endian U32
@ -115,43 +93,35 @@ namespace Types {
value |= (buffer[2] << 8);
value |= (buffer[3] << 0);
ASSERT_EQ(value, peek_u32);
}
else if (state.getPeekType() == 3) {
} else if (state.getPeekType() == 3) {
ASSERT_TRUE(state.peek(buffer, state.getRandomSize(), state.getPeekOffset()));
ASSERT_EQ(state.getTestBuffer().peek(peek_buffer, state.getRandomSize(), state.getPeekOffset()),
Fw::FW_SERIALIZE_OK);
for (FwSizeType i = 0; i < state.getRandomSize(); i++) {
ASSERT_EQ(buffer[i], peek_buffer[i]);
}
}
else {
} else {
ASSERT_TRUE(false); // Fail the test, bad type
}
}
}
PeekBadRule::PeekBadRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
PeekBadRule::PeekBadRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool PeekBadRule::precondition(const MockTypes::CircularState& state) {
bool PeekBadRule::precondition(const MockTypes::CircularState& state) {
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
if (state.getPeekType() == 0 ) {
if (state.getPeekType() == 0) {
return peek_available < sizeof(I8) + state.getPeekOffset();
}
else if (state.getPeekType() == 1) {
} else if (state.getPeekType() == 1) {
return peek_available < sizeof(U8) + state.getPeekOffset();
}
else if (state.getPeekType() == 2) {
} else if (state.getPeekType() == 2) {
return peek_available < sizeof(U32) + state.getPeekOffset();
}
else if (state.getPeekType() == 3) {
} else if (state.getPeekType() == 3) {
return peek_available < state.getRandomSize() + state.getPeekOffset();
}
return false;
}
}
void PeekBadRule::action(MockTypes::CircularState& state) {
void PeekBadRule::action(MockTypes::CircularState& state) {
char peek_char = 0;
U8 peek_u8 = 0;
U32 peek_u32 = 0;
@ -159,51 +129,41 @@ namespace Types {
// Handle all cases for deserialization
if (state.getPeekType() == 0) {
ASSERT_EQ(state.getTestBuffer().peek(peek_char, state.getPeekOffset()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
else if (state.getPeekType() == 1) {
} else if (state.getPeekType() == 1) {
ASSERT_EQ(state.getTestBuffer().peek(peek_u8, state.getPeekOffset()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
else if (state.getPeekType() == 2) {
} else if (state.getPeekType() == 2) {
ASSERT_EQ(state.getTestBuffer().peek(peek_u32, state.getPeekOffset()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
else if (state.getPeekType() == 3) {
} else if (state.getPeekType() == 3) {
ASSERT_EQ(state.getTestBuffer().peek(peek_buffer, state.getRandomSize(), state.getPeekOffset()),
Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
else {
} else {
ASSERT_TRUE(false); // Fail the test, bad type
}
}
}
RotateOkRule::RotateOkRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
RotateOkRule::RotateOkRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool RotateOkRule::precondition(const MockTypes::CircularState& state) {
bool RotateOkRule::precondition(const MockTypes::CircularState& state) {
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
return rotate_available >= state.getRandomSize();
}
}
void RotateOkRule::action(MockTypes::CircularState& state) {
void RotateOkRule::action(MockTypes::CircularState& state) {
state.checkSizes();
ASSERT_EQ(state.getTestBuffer().rotate(state.getRandomSize()), Fw::FW_SERIALIZE_OK);
ASSERT_TRUE(state.rotate(state.getRandomSize()));
state.setRemainingSize(state.getRemainingSize() + state.getRandomSize());
state.checkSizes();
}
}
RotateBadRule::RotateBadRule(const char* const name) : STest::Rule<MockTypes::CircularState>(name) {}
RotateBadRule::RotateBadRule(const char *const name)
: STest::Rule<MockTypes::CircularState>(name) {}
bool RotateBadRule::precondition(const MockTypes::CircularState& state) {
bool RotateBadRule::precondition(const MockTypes::CircularState& state) {
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
return rotate_available < state.getRandomSize();
}
void RotateBadRule::action(MockTypes::CircularState& state) {
ASSERT_EQ(state.getTestBuffer().rotate(state.getRandomSize()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
}
void RotateBadRule::action(MockTypes::CircularState& state) {
ASSERT_EQ(state.getTestBuffer().rotate(state.getRandomSize()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
}
} // namespace Types

View File

@ -21,123 +21,122 @@
#include <Fw/FPrimeBasicTypes.hpp>
#include <Fw/Types/String.hpp>
#include <Utils/Types/test/ut/CircularBuffer/CircularState.hpp>
#include <STest/STest/Rule/Rule.hpp>
#include <STest/STest/Pick/Pick.hpp>
#include <STest/STest/Rule/Rule.hpp>
#include <Utils/Types/test/ut/CircularBuffer/CircularState.hpp>
namespace Types {
/**
/**
* SetupRandomBufferRule:
*
* This rule sets up a random buffer, and other random state.
*/
struct RandomizeRule : public STest::Rule<MockTypes::CircularState> {
struct RandomizeRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
RandomizeRule(const char *const name);
RandomizeRule(const char* const name);
// Always valid
bool precondition(const MockTypes::CircularState& state);
// Will randomize the test state
void action(MockTypes::CircularState& truth);
};
};
/**
/**
* SerializeOkRule:
*
* This rule tests that the circular buffer can accept data when it is valid for the buffer to accept data.
*/
struct SerializeOkRule : public STest::Rule<MockTypes::CircularState> {
struct SerializeOkRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
SerializeOkRule(const char *const name);
SerializeOkRule(const char* const name);
// Valid precondition for when the buffer should accept data
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer accepting data
void action(MockTypes::CircularState& state);
};
};
/**
/**
* SerializeOverflowRule:
*
* This rule tests that the circular buffer cannot accept data when it is full.
*/
struct SerializeOverflowRule : public STest::Rule<MockTypes::CircularState> {
struct SerializeOverflowRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
SerializeOverflowRule(const char *const name);
SerializeOverflowRule(const char* const name);
// Valid precondition for when the buffer should reject data
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer overflowing with an error
void action(MockTypes::CircularState& state);
};
};
/**
/**
* PeekOkRule:
*
* This rule tests that the circular buffer can peek correctly.
*/
struct PeekOkRule : public STest::Rule<MockTypes::CircularState> {
struct PeekOkRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
PeekOkRule(const char *const name);
PeekOkRule(const char* const name);
// Peek ok available for when buffer size - remaining size <= peek size
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer's ability to peek
void action(MockTypes::CircularState& state);
};
};
/**
/**
* PeekOkRule:
*
* This rule tests that the circular buffer cannot peek when it should not peek.
*/
struct PeekBadRule : public STest::Rule<MockTypes::CircularState> {
struct PeekBadRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
PeekBadRule(const char *const name);
PeekBadRule(const char* const name);
// Peek bad available for when buffer size - remaining size > peek size
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer's ability to peek with a fail
void action(MockTypes::CircularState& state);
};
};
/**
/**
* RotateOkRule:
*
* This rule tests that the circular buffer can rotate correctly.
*/
struct RotateOkRule : public STest::Rule<MockTypes::CircularState> {
struct RotateOkRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
RotateOkRule(const char *const name);
RotateOkRule(const char* const name);
// Rotate is ok when there is more data then rotational size
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer's ability to rotate
void action(MockTypes::CircularState& state);
};
};
/**
/**
* RotateOkRule:
*
* This rule tests that the circular buffer cannot rotate when it should not rotate.
*/
struct RotateBadRule : public STest::Rule<MockTypes::CircularState> {
struct RotateBadRule : public STest::Rule<MockTypes::CircularState> {
// Constructor
RotateBadRule(const char *const name);
RotateBadRule(const char* const name);
// Rotate is bad when there is less data then rotational size
bool precondition(const MockTypes::CircularState& state);
// Action that tests the buffer's ability to rotate
void action(MockTypes::CircularState& state);
};
}
#endif //FPRIME_GROUNDINTERFACERULES_HPP
};
} // namespace Types
#endif // FPRIME_GROUNDINTERFACERULES_HPP

View File

@ -9,15 +9,15 @@
#include <STest/Pick/Pick.hpp>
#include <Utils/Types/test/ut/CircularBuffer/CircularState.hpp>
#include <gtest/gtest.h>
#include <cstdlib>
#include <cstring>
#include <gtest/gtest.h>
U8 CIRCULAR_BUFFER_MEMORY[MAX_BUFFER_SIZE];
namespace MockTypes {
CircularState::CircularState() :
m_remaining_size(static_cast<FwSizeType>(sizeof(CIRCULAR_BUFFER_MEMORY))),
CircularState::CircularState()
: m_remaining_size(static_cast<FwSizeType>(sizeof(CIRCULAR_BUFFER_MEMORY))),
m_random_size(MAX_BUFFER_SIZE),
m_peek_offset(0),
m_peek_type(0),
@ -25,19 +25,18 @@ namespace MockTypes {
m_infinite_read(0),
m_infinite_write(0),
m_infinite_size(0),
m_test_buffer(CIRCULAR_BUFFER_MEMORY, static_cast<FwSizeType>(sizeof(CIRCULAR_BUFFER_MEMORY)))
{
m_test_buffer(CIRCULAR_BUFFER_MEMORY, static_cast<FwSizeType>(sizeof(CIRCULAR_BUFFER_MEMORY))) {
memset(m_buffer, 0, sizeof m_buffer);
}
}
CircularState::~CircularState() {
CircularState::~CircularState() {
if (m_infinite_size != 0) {
std::free(m_infinite_store);
}
}
}
// Generates a random buffer
FwSizeType CircularState::generateRandomBuffer() {
// Generates a random buffer
FwSizeType CircularState::generateRandomBuffer() {
m_peek_offset = static_cast<FwSizeType>(STest::Pick::lowerUpper(0, sizeof(m_buffer)));
m_peek_type = static_cast<FwSizeType>(STest::Pick::lowerUpper(0, 4));
FwSizeType random_size = static_cast<FwSizeType>(STest::Pick::lowerUpper(0, sizeof(m_buffer)));
@ -46,23 +45,23 @@ namespace MockTypes {
}
this->m_random_size = random_size;
return random_size;
}
}
void CircularState::setRandom(FwSizeType random, FwSizeType peek_type, FwSizeType peek_offset) {
void CircularState::setRandom(FwSizeType random, FwSizeType peek_type, FwSizeType peek_offset) {
m_random_size = random;
m_peek_type = peek_type;
m_peek_offset = peek_offset;
}
}
FwSizeType CircularState::getPeekOffset() const {
FwSizeType CircularState::getPeekOffset() const {
return m_peek_offset;
}
}
FwSizeType CircularState::getPeekType() const {
FwSizeType CircularState::getPeekType() const {
return m_peek_type;
}
}
bool CircularState::addInfinite(const U8* buffer, FwSizeType size) {
bool CircularState::addInfinite(const U8* buffer, FwSizeType size) {
// If we are out of "infinite space" add another MB, and check allocation
if ((m_infinite_write + size) > m_infinite_size) {
void* new_pointer = std::realloc(m_infinite_store, m_infinite_size + 1048576);
@ -75,49 +74,49 @@ namespace MockTypes {
std::memcpy(m_infinite_store + m_infinite_write, buffer, size);
m_infinite_write += size;
return true;
}
}
bool CircularState::peek(U8*& buffer, FwSizeType size, FwSizeType offset) {
bool CircularState::peek(U8*& buffer, FwSizeType size, FwSizeType offset) {
FwSizeType final_offset = m_infinite_read + offset;
if ((final_offset + size) > m_infinite_write) {
return false;
}
buffer = m_infinite_store + final_offset;
return true;
}
}
bool CircularState::rotate(FwSizeType size) {
bool CircularState::rotate(FwSizeType size) {
// Fail if we try to rotate too far
if ((m_infinite_read + size) > m_infinite_write) {
return false;
}
m_infinite_read += size;
return true;
}
}
FwSizeType CircularState::getRandomSize() const {
FwSizeType CircularState::getRandomSize() const {
return m_random_size;
}
}
const U8 *CircularState::getBuffer() const {
const U8* CircularState::getBuffer() const {
return m_buffer;
}
}
FwSizeType CircularState::getRemainingSize() const {
FwSizeType CircularState::getRemainingSize() const {
return m_remaining_size;
}
}
void CircularState::setRemainingSize(FwSizeType mRemainingSize) {
void CircularState::setRemainingSize(FwSizeType mRemainingSize) {
m_remaining_size = mRemainingSize;
}
}
Types::CircularBuffer& CircularState::getTestBuffer() {
Types::CircularBuffer& CircularState::getTestBuffer() {
return m_test_buffer;
}
}
void CircularState::checkSizes() const {
void CircularState::checkSizes() const {
const FwSizeType allocated_size = (MAX_BUFFER_SIZE - m_remaining_size);
ASSERT_EQ(m_test_buffer.get_free_size(), m_remaining_size);
ASSERT_EQ(m_test_buffer.get_allocated_size(), allocated_size);
}
}
} // namespace MockTypes

View File

@ -17,7 +17,7 @@
namespace MockTypes {
class CircularState {
class CircularState {
public:
// Constructor
CircularState();
@ -70,7 +70,7 @@ namespace MockTypes {
* Gets a pointer to the random buffer.
* @return random buffer storing data
*/
const U8 *getBuffer() const;
const U8* getBuffer() const;
/**
* Get the remaining size of the circular buffer. This is a shadow field.
* @return shadow field for circular buffer.
@ -106,7 +106,7 @@ namespace MockTypes {
FwSizeType m_infinite_size;
Types::CircularBuffer m_test_buffer;
};
};
}
#endif //FPRIME_CIRCULARSTATE_HPP
} // namespace MockTypes
#endif // FPRIME_CIRCULARSTATE_HPP

View File

@ -6,16 +6,16 @@
* Created on: May 23, 2019
* Author: mstarch
*/
#include <STest/Scenario/Scenario.hpp>
#include <STest/Scenario/RandomScenario.hpp>
#include <STest/Scenario/BoundedScenario.hpp>
#include <STest/Scenario/RandomScenario.hpp>
#include <STest/Scenario/Scenario.hpp>
#include <gtest/gtest.h>
#include <Fw/Test/UnitTest.hpp>
#include <Utils/Types/test/ut/CircularBuffer/CircularRules.hpp>
#include <gtest/gtest.h>
#include <cstdio>
#include <cmath>
#include <cstdio>
#define STEP_COUNT 1000
@ -41,22 +41,13 @@ TEST(CircularBufferTests, RandomCircularTests) {
Types::PeekBadRule rotateBad("rotateBad");
// Setup a list of rules to choose from
STest::Rule<MockTypes::CircularState>* rules[] = {
&randomize,
&serializeOk,
&serializeOverflow,
&peekOk,
&peekBad,
&rotateOk,
&rotateBad
};
STest::Rule<MockTypes::CircularState>* rules[] = {&randomize, &serializeOk, &serializeOverflow, &peekOk,
&peekBad, &rotateOk, &rotateBad};
// Construct the random scenario and run it with the defined bounds
STest::RandomScenario<MockTypes::CircularState> random("Random Rules", rules,
FW_NUM_ARRAY_ELEMENTS(rules));
STest::RandomScenario<MockTypes::CircularState> random("Random Rules", rules, FW_NUM_ARRAY_ELEMENTS(rules));
// Setup a bounded scenario to run rules a set number of times
STest::BoundedScenario<MockTypes::CircularState> bounded("Bounded Random Rules Scenario",
random, STEP_COUNT);
STest::BoundedScenario<MockTypes::CircularState> bounded("Bounded Random Rules Scenario", random, STEP_COUNT);
// Run!
const U32 numSteps = bounded.run(state);
printf("Ran %u steps.\n", numSteps);
@ -82,7 +73,7 @@ TEST(CircularBufferTests, BasicSerializeTest) {
TEST(CircularBufferTests, BasicOverflowTest) {
// Setup state and fill it with garbage
MockTypes::CircularState state;
ASSERT_EQ(Fw::FW_SERIALIZE_OK , state.getTestBuffer().serialize(state.getBuffer(), state.getRandomSize()));
ASSERT_EQ(Fw::FW_SERIALIZE_OK, state.getTestBuffer().serialize(state.getBuffer(), state.getRandomSize()));
state.setRemainingSize(0);
// Create rules, and assign them into the array

View File

@ -13,31 +13,21 @@
#include "RateLimiterTester.hpp"
namespace Utils {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
RateLimiterTester ::
RateLimiterTester()
{
}
RateLimiterTester ::RateLimiterTester() {}
RateLimiterTester ::
~RateLimiterTester()
{
RateLimiterTester ::~RateLimiterTester() {}
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void RateLimiterTester ::
testCounterTriggering()
{
void RateLimiterTester ::testCounterTriggering() {
U32 testCycles[] = {0, 5, 50, 832};
for (U32 i = 0; i < FW_NUM_ARRAY_ELEMENTS(testCycles); i++) {
const U32 cycles = testCycles[i];
@ -68,11 +58,9 @@ namespace Utils {
ASSERT_EQ(triggerCount, expectedCount);
}
}
}
}
void RateLimiterTester ::
testTimeTriggering()
{
void RateLimiterTester ::testTimeTriggering() {
U32 testCycles[] = {0, 5, 50, 832};
for (U32 i = 0; i < FW_NUM_ARRAY_ELEMENTS(testCycles); i++) {
const U32 cycles = testCycles[i];
@ -85,7 +73,7 @@ namespace Utils {
// does not trigger if skipped
if (cycles > 0) {
limiter.setTime(Fw::Time(1,0));
limiter.setTime(Fw::Time(1, 0));
ASSERT_FALSE(limiter.trigger(Fw::Time::zero()));
limiter.reset();
}
@ -98,17 +86,16 @@ namespace Utils {
curTime.add(0, STest::Pick::lowerUpper(1, 5) * 100000);
bool shouldTrigger = (cycles == 0) || (curTime >= nextTriggerTime);
bool triggered = limiter.trigger(curTime);
ASSERT_EQ(shouldTrigger, triggered) << " for cycles " << cycles << " at " << curTime.getSeconds() << "." << curTime.getUSeconds();
ASSERT_EQ(shouldTrigger, triggered)
<< " for cycles " << cycles << " at " << curTime.getSeconds() << "." << curTime.getUSeconds();
if (triggered) {
nextTriggerTime = Fw::Time::add(curTime, timeCyclesTime);
}
}
}
}
}
void RateLimiterTester ::
testCounterAndTimeTriggering()
{
void RateLimiterTester ::testCounterAndTimeTriggering() {
U32 testCounterCycles[] = {37, 981, 4110};
U32 testTimeCycles[] = {12, 294, 1250};
for (U32 i = 0; i < (FW_NUM_ARRAY_ELEMENTS(testCounterCycles) * FW_NUM_ARRAY_ELEMENTS(testTimeCycles)); i++) {
@ -128,25 +115,22 @@ namespace Utils {
Fw::Time nextTriggerTime(0, 0);
for (U32 iter = 0; iter < numIter; iter++) {
curTime.add(0, STest::Pick::lowerUpper(1, 5) * 100000);
bool shouldTrigger = ((iter-lastTriggerIter) % counterCycles == 0) || (curTime >= nextTriggerTime);
bool shouldTrigger = ((iter - lastTriggerIter) % counterCycles == 0) || (curTime >= nextTriggerTime);
bool triggered = limiter.trigger(curTime);
ASSERT_EQ(shouldTrigger, triggered) << " for cycles " << counterCycles << "/" << timeCycles << " at " << iter << "/" << curTime.getSeconds() << "." << curTime.getUSeconds();
ASSERT_EQ(shouldTrigger, triggered) << " for cycles " << counterCycles << "/" << timeCycles << " at "
<< iter << "/" << curTime.getSeconds() << "." << curTime.getUSeconds();
if (triggered) {
nextTriggerTime = Fw::Time::add(curTime, timeCyclesTime);
lastTriggerIter = iter;
}
}
}
}
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
void RateLimiterTester ::
initComponents()
{
}
void RateLimiterTester ::initComponents() {}
} // end namespace Utils

View File

@ -14,22 +14,19 @@
#ifndef RATELIMITERTESTER_HPP
#define RATELIMITERTESTER_HPP
#include "Utils/RateLimiter.hpp"
#include <Fw/FPrimeBasicTypes.hpp>
#include "gtest/gtest.h"
#include <STest/Pick/Pick.hpp>
#include "Utils/RateLimiter.hpp"
#include "gtest/gtest.h"
namespace Utils {
class RateLimiterTester
{
class RateLimiterTester {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
public:
//! Construct object RateLimiterTester
//!
RateLimiterTester();
@ -39,7 +36,6 @@ namespace Utils {
~RateLimiterTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
@ -49,7 +45,6 @@ namespace Utils {
void testCounterAndTimeTriggering();
private:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
@ -59,14 +54,10 @@ namespace Utils {
void initComponents();
private:
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
};
};
} // end namespace Utils

View File

@ -16,28 +16,19 @@
namespace Utils {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
TokenBucketTester ::
TokenBucketTester()
{
}
TokenBucketTester ::TokenBucketTester() {}
TokenBucketTester ::
~TokenBucketTester()
{
TokenBucketTester ::~TokenBucketTester() {}
}
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
void TokenBucketTester ::
testTriggering()
{
void TokenBucketTester ::testTriggering() {
const U32 interval = 1000000;
U32 testMaxTokens[] = {1, 5, 50, 832};
for (U32 i = 0; i < FW_NUM_ARRAY_ELEMENTS(testMaxTokens); i++) {
@ -65,11 +56,9 @@ namespace Utils {
U32 expected = maxTokens + (attempts - 1) / 4;
ASSERT_EQ(expected, triggerCount);
}
}
}
void TokenBucketTester ::
testReconfiguring()
{
void TokenBucketTester ::testReconfiguring() {
U32 initialInterval = 1000000;
U32 initialMaxTokens = 5;
@ -80,44 +69,43 @@ namespace Utils {
// trigger
bucket.trigger(Fw::Time(0, 0));
ASSERT_EQ(bucket.getTokens(), initialMaxTokens-1);
ASSERT_EQ(bucket.getTokens(), initialMaxTokens - 1);
// replenished, then triggered
bucket.trigger(Fw::Time(1, 0));
ASSERT_EQ(bucket.getTokens(), initialMaxTokens-1);
ASSERT_EQ(bucket.getTokens(), initialMaxTokens - 1);
// set new interval, can't replenish using old interval
U32 newInterval = 2000000;
bucket.setReplenishInterval(newInterval);
ASSERT_EQ(bucket.getReplenishInterval(), newInterval);
ASSERT_TRUE(bucket.trigger(Fw::Time(2, 0)));
ASSERT_EQ(bucket.getTokens(), initialMaxTokens-2);
ASSERT_EQ(bucket.getTokens(), initialMaxTokens - 2);
// set new max tokens, replenish up to new max
U32 newMaxTokens = 10;
bucket.setMaxTokens(newMaxTokens);
ASSERT_EQ(bucket.getMaxTokens(), newMaxTokens);
ASSERT_TRUE(bucket.trigger(Fw::Time(20, 0)));
ASSERT_EQ(bucket.getTokens(), newMaxTokens-1);
ASSERT_EQ(bucket.getTokens(), newMaxTokens - 1);
// set new rate, replenish quickly
while (bucket.trigger(Fw::Time(0,0)));
while (bucket.trigger(Fw::Time(0, 0)))
;
bucket.setReplenishInterval(1000000);
U32 newRate = 2;
bucket.setReplenishRate(newRate);
ASSERT_EQ(bucket.getReplenishRate(), newRate);
ASSERT_TRUE(bucket.trigger(Fw::Time(21, 0)));
ASSERT_EQ(bucket.getTokens(), 1);
}
}
void TokenBucketTester ::
testInitialSettings()
{
void TokenBucketTester ::testInitialSettings() {
U32 interval = 1000000;
U32 maxTokens = 5;
U32 rate = 2;
U32 startTokens = 2;
Fw::Time startTime(5,0);
Fw::Time startTime(5, 0);
TokenBucket bucket(interval, maxTokens, rate, startTokens, startTime);
ASSERT_NE(bucket.getTokens(), maxTokens);
@ -125,20 +113,16 @@ namespace Utils {
ASSERT_EQ(bucket.getReplenishRate(), rate);
for (U32 i = 0; i < startTokens; i++) {
bool triggered = bucket.trigger(Fw::Time(0,0));
bool triggered = bucket.trigger(Fw::Time(0, 0));
ASSERT_TRUE(triggered);
}
ASSERT_FALSE(bucket.trigger(Fw::Time(0,0)));
}
ASSERT_FALSE(bucket.trigger(Fw::Time(0, 0)));
}
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
void TokenBucketTester ::
initComponents()
{
}
void TokenBucketTester ::initComponents() {}
} // end namespace Utils

View File

@ -14,21 +14,18 @@
#ifndef TOKENBUCKETTESTER_HPP
#define TOKENBUCKETTESTER_HPP
#include "Utils/TokenBucket.hpp"
#include <Fw/FPrimeBasicTypes.hpp>
#include "Utils/TokenBucket.hpp"
#include "gtest/gtest.h"
namespace Utils {
class TokenBucketTester
{
class TokenBucketTester {
// ----------------------------------------------------------------------
// Construction and destruction
// ----------------------------------------------------------------------
public:
//! Construct object TokenBucketTester
//!
TokenBucketTester();
@ -38,7 +35,6 @@ namespace Utils {
~TokenBucketTester();
public:
// ----------------------------------------------------------------------
// Tests
// ----------------------------------------------------------------------
@ -48,7 +44,6 @@ namespace Utils {
void testInitialSettings();
private:
// ----------------------------------------------------------------------
// Helper methods
// ----------------------------------------------------------------------
@ -58,12 +53,10 @@ namespace Utils {
void initComponents();
private:
// ----------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------
};
};
} // end namespace Utils

View File

@ -35,7 +35,7 @@ TEST(TokenBucketTest, TestInitialSettings) {
tester.testInitialSettings();
}
int main(int argc, char **argv) {
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,29 +1,27 @@
/*
* \author: Tim Canham
* \file:
* \brief
*
* This file has configuration settings for the ActiveRateGroup component.
*
*
* Copyright 2014-2015, by the California Institute of Technology.
* ALL RIGHTS RESERVED. United States Government Sponsorship
* acknowledged.
*
*/
* \author: Tim Canham
* \file:
* \brief
*
* This file has configuration settings for the ActiveRateGroup component.
*
*
* Copyright 2014-2015, by the California Institute of Technology.
* ALL RIGHTS RESERVED. United States Government Sponsorship
* acknowledged.
*
*/
#ifndef ACTIVERATEGROUP_ACTIVERATEGROUPCFG_HPP_
#define ACTIVERATEGROUP_ACTIVERATEGROUPCFG_HPP_
namespace Svc {
enum {
enum {
//! Number of overruns allowed before overrun event is throttled
ACTIVE_RATE_GROUP_OVERRUN_THROTTLE = 5,
};
};
}
#endif /* ACTIVERATEGROUP_ACTIVERATEGROUPCFG_HPP_ */

View File

@ -4,8 +4,7 @@
#include <Fw/FPrimeBasicTypes.hpp>
namespace Svc {
static const U16 BUFFERMGR_MAX_NUM_BINS = 10;
static const U16 BUFFERMGR_MAX_NUM_BINS = 10;
}
#endif // __BUFFERMANAGERCOMPONENTIMPLCFG_HPP__

View File

@ -8,7 +8,6 @@
#include <Fw/FPrimeBasicTypes.hpp>
// Default block size used when reading files for CRC calculation
constexpr FwSignedSizeType CONFIG_CRC_FILE_READ_BLOCK = 2048;

View File

@ -15,6 +15,4 @@ enum {
CMD_DISPATCHER_SEQUENCER_TABLE_SIZE = 25, // !< The size of the table holding commands in progress
};
#endif /* CMDDISPATCHER_COMMANDDISPATCHERIMPLCFG_HPP_ */

View File

@ -9,12 +9,12 @@
#include <Fw/FPrimeBasicTypes.hpp>
namespace Svc {
// Sets the maximum number of directories where
// data products can be stored. The array passed
// to the initializer for DpCatalog cannot exceed
// this size.
static const FwIndexType DP_MAX_DIRECTORIES = 2;
static const FwIndexType DP_MAX_FILES = 127;
}
// Sets the maximum number of directories where
// data products can be stored. The array passed
// to the initializer for DpCatalog cannot exceed
// this size.
static const FwIndexType DP_MAX_DIRECTORIES = 2;
static const FwIndexType DP_MAX_FILES = 127;
} // namespace Svc
#endif /* SVC_DPCATALOG_CONFIG_HPP_ */

View File

@ -18,6 +18,6 @@
// The format string for a file name
// The format arguments are base directory, container ID, time seconds, and time microseconds
#define DP_EXT ".fdp"
constexpr const char *DP_FILENAME_FORMAT = "%s/Dp_%08" PRI_FwDpIdType "_%08" PRIu32 "_%08" PRIu32 DP_EXT;
constexpr const char* DP_FILENAME_FORMAT = "%s/Dp_%08" PRI_FwDpIdType "_%08" PRIu32 "_%08" PRIu32 DP_EXT;
#endif

View File

@ -19,7 +19,6 @@ enum {
FILTER_DIAGNOSTIC_DEFAULT = false, //!< DIAGNOSTIC events are filtered at input
};
enum {
TELEM_ID_FILTER_SIZE = 25, //!< Size of telemetry ID filter
};

View File

@ -35,4 +35,3 @@ extern "C" {
}
#endif
#endif // FPRIME_INTEGER_CONFIG_H

View File

@ -9,18 +9,20 @@
#include <Fw/FPrimeBasicTypes.hpp>
namespace Svc {
// If this is set to true, the run handler will look to
// see if a packet is ready. If it is false, the next packet
// will be sent as soon as the previous is complete.
static const bool FILEDOWNLINK_PACKETS_BY_RUN = false;
// If this is set, errors that would cause FileDownlink to return an error response, such as a
// missing file or attempting to send a partial chunk past the end of the file will instead
// return success. This is recommended to avoid a non-serious FileDownlink error aborting a
// sequence early. These errors will still be logged as events.
static const bool FILEDOWNLINK_COMMAND_FAILURES_DISABLED = true;
// Size of the internal file downlink buffer. This must now be static as
// file down maintains its own internal buffer.
static const U32 FILEDOWNLINK_INTERNAL_BUFFER_SIZE = FW_FILE_BUFFER_MAX_SIZE;
}
// If this is set to true, the run handler will look to
// see if a packet is ready. If it is false, the next packet
// will be sent as soon as the previous is complete.
static const bool FILEDOWNLINK_PACKETS_BY_RUN = false;
// If this is set, errors that would cause FileDownlink to return an error response, such as a
// missing file or attempting to send a partial chunk past the end of the file will instead
// return success. This is recommended to avoid a non-serious FileDownlink error aborting a
// sequence early. These errors will still be logged as events.
static const bool FILEDOWNLINK_COMMAND_FAILURES_DISABLED = true;
// Size of the internal file downlink buffer. This must now be static as
// file down maintains its own internal buffer.
static const U32 FILEDOWNLINK_INTERNAL_BUFFER_SIZE = FW_FILE_BUFFER_MAX_SIZE;
} // namespace Svc
#endif /* SVC_FILEDOWNLINK_FILEDOWNLINKCFG_HPP_ */

View File

@ -4,13 +4,13 @@
#include <config/FpConfig.hpp>
namespace Svc {
namespace FileManagerConfig {
//! Number of directory entries to process per rate group tick
//! Higher values = faster directory listing but more events per tick
//! Lower values = slower directory listing but bounded event rate
//! Default: 1
static constexpr U32 FILES_PER_RATE_TICK = 1;
}
}
namespace FileManagerConfig {
//! Number of directory entries to process per rate group tick
//! Higher values = faster directory listing but more events per tick
//! Lower values = slower directory listing but bounded event rate
//! Default: 1
static constexpr U32 FILES_PER_RATE_TICK = 1;
} // namespace FileManagerConfig
} // namespace Svc
#endif

View File

@ -14,9 +14,8 @@
#ifdef __cplusplus
extern "C" {
#endif
#include <Platform/PlatformTypes.h>
#include <Fw/Types/BasicTypes.h>
#include <Platform/PlatformTypes.h>
// ----------------------------------------------------------------------
// Type aliases
@ -90,8 +89,8 @@ extern "C" {
// This generates code to connect to serialized ports
#ifndef FW_PORT_SERIALIZATION
#define FW_PORT_SERIALIZATION \
1 //!< Indicates whether there is code in ports to serialize the call (more code, but ability to serialize calls
//!< for multi-note systems)
1 //!< Indicates whether there is code in ports to serialize the call (more code, but ability to serialize
//!< calls for multi-note systems)
#endif
// Component Facilities

View File

@ -23,5 +23,4 @@ enum IpCfg {
};
static const Fw::TimeInterval SOCKET_RETRY_INTERVAL = Fw::TimeInterval(1, 0);
#endif //REF_IPCFG_HPP
#endif // REF_IPCFG_HPP

View File

@ -11,13 +11,12 @@
// Anonymous namespace for configuration parameters
namespace {
enum {
enum {
PRMDB_NUM_DB_ENTRIES = 25, // !< Number of entries in the parameter database
PRMDB_ENTRY_DELIMITER = 0xA5 // !< Byte value that should precede each parameter in file; sanity check against file integrity. Should match ground system.
};
PRMDB_ENTRY_DELIMITER = 0xA5 // !< Byte value that should precede each parameter in file; sanity check against
// file integrity. Should match ground system.
};
}
#endif /* PRMDB_PRMDBLIMPLCFG_HPP_ */

View File

@ -8,10 +8,6 @@
#ifndef PRMDB_TEST_UT_PRMDBIMPLTESTERCFG_HPP_
#define PRMDB_TEST_UT_PRMDBIMPLTESTERCFG_HPP_
enum {
PRMDB_IMPL_TESTER_MAX_READ_BUFFER = 256
};
enum { PRMDB_IMPL_TESTER_MAX_READ_BUFFER = 256 };
#endif /* PRMDB_TEST_UT_PRMDBIMPLTESTERCFG_HPP_ */

View File

@ -8,10 +8,7 @@
#define SVC_STATIC_MEMORY_CFG_HPP_
namespace Svc {
enum StaticMemoryConfig {
STATIC_MEMORY_ALLOCATION_SIZE = 2048
};
enum StaticMemoryConfig { STATIC_MEMORY_ALLOCATION_SIZE = 2048 };
}
#endif

View File

@ -15,7 +15,6 @@
// Anonymous namespace for configuration parameters
// The parameters below provide for tuning of the hash function used to
// write and read entries in the database. The has function is very simple;
// It first takes the telemetry ID and does a modulo computation with
@ -41,7 +40,7 @@
namespace {
enum {
enum {
TLMCHAN_NUM_TLM_HASH_SLOTS = 15, // !< Number of slots in the hash table.
// Works best when set to about twice the number of components producing telemetry
TLMCHAN_HASH_MOD_VALUE = 99, // !< The modulo value of the hashing function.
@ -49,8 +48,7 @@ namespace {
TLMCHAN_HASH_BUCKETS = 500 // !< Buckets assignable to a hash slot.
// Buckets must be >= number of telemetry channels in system
};
};
}

View File

@ -17,18 +17,17 @@
namespace Svc {
static const FwChanIdType MAX_PACKETIZER_PACKETS = 200;
static const FwChanIdType TLMPACKETIZER_NUM_TLM_HASH_SLOTS =
15; // !< Number of slots in the hash table.
// Works best when set to about twice the number of components producing telemetry
static const FwChanIdType TLMPACKETIZER_HASH_MOD_VALUE =
99; // !< The modulo value of the hashing function.
// Should be set to a little below the ID gaps to spread the entries around
static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS =
1000; // !< Buckets assignable to a hash slot.
// Buckets must be >= number of telemetry channels in system
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK =
25; // !< Maximum number of missing telemetry channel checks
// Works best when set to about twice the number of components producing telemetry
static const FwChanIdType TLMPACKETIZER_NUM_TLM_HASH_SLOTS = 15; // !< Number of slots in the hash table.
// Should be set to a little below the ID gaps to spread the entries around
static const FwChanIdType TLMPACKETIZER_HASH_MOD_VALUE = 99; // !< The modulo value of the hashing function.
// Buckets must be >= number of telemetry channels in system
static const FwChanIdType TLMPACKETIZER_HASH_BUCKETS = 1000; // !< Buckets assignable to a hash slot.
static const FwChanIdType TLMPACKETIZER_MAX_MISSING_TLM_CHECK = 25; // !< Max number of missing channel checks
// packet update mode
enum PacketUpdateMode {