mirror of
https://github.com/nasa/fprime.git
synced 2025-12-10 00:44:37 -06:00
Finish code formatting (#4134)
This commit is contained in:
parent
c8e2d44877
commit
ba65039fff
5
.github/workflows/format-check.yml
vendored
5
.github/workflows/format-check.yml
vendored
@ -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
|
||||
|
||||
@ -19,73 +19,41 @@ 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
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -97,30 +65,17 @@ namespace CFDP {
|
||||
// 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) {
|
||||
@ -132,15 +87,10 @@ namespace CFDP {
|
||||
}
|
||||
}
|
||||
|
||||
void Checksum ::
|
||||
addByteAtOffset(
|
||||
const U8 byte,
|
||||
const U8 offset
|
||||
)
|
||||
{
|
||||
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
|
||||
|
||||
@ -51,15 +51,12 @@ namespace CFDP {
|
||||
//! ----------
|
||||
//! 0xA8ABBEEF <- Final value
|
||||
class Checksum {
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Types
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Construction and destruction
|
||||
// ----------------------------------------------------------------------
|
||||
@ -77,7 +74,6 @@ namespace CFDP {
|
||||
~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
|
||||
|
||||
@ -16,17 +16,12 @@ namespace CFDP {
|
||||
|
||||
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
|
||||
|
||||
@ -25,15 +25,14 @@ namespace CFDP {
|
||||
//!
|
||||
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
|
||||
|
||||
@ -10,9 +10,8 @@ using namespace CFDP;
|
||||
|
||||
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;
|
||||
@ -53,4 +52,3 @@ int main(int argc, char **argv) {
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
#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() {}
|
||||
|
||||
@ -19,13 +17,9 @@ namespace Ref {
|
||||
this->tlmWrite_BD_Cycles(this->m_cycles++);
|
||||
}
|
||||
|
||||
void BlockDriver::PingIn_handler(
|
||||
const FwIndexType portNum,
|
||||
U32 key
|
||||
)
|
||||
{
|
||||
void BlockDriver::PingIn_handler(const FwIndexType portNum, U32 key) {
|
||||
// call ping output port
|
||||
this->PingOut_out(0, key);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
@ -6,30 +6,25 @@
|
||||
namespace Ref {
|
||||
|
||||
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
|
||||
|
||||
@ -12,28 +12,19 @@ namespace Ref {
|
||||
// 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
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void BlockDriverTester ::
|
||||
testDataLoopBack()
|
||||
{
|
||||
void BlockDriverTester ::testDataLoopBack() {
|
||||
const U8 data[] = {1, 2, 3, 4, 5, 6, 7};
|
||||
Drv::DataBuffer dataBuffer(data, 7);
|
||||
|
||||
@ -49,9 +40,7 @@ namespace Ref {
|
||||
ASSERT_from_BufferOut(0, dataBuffer);
|
||||
}
|
||||
|
||||
void BlockDriverTester ::
|
||||
testPing()
|
||||
{
|
||||
void BlockDriverTester ::testPing() {
|
||||
const U32 key = 42;
|
||||
|
||||
this->clearHistory();
|
||||
@ -66,9 +55,7 @@ namespace Ref {
|
||||
ASSERT_from_PingOut(0, key);
|
||||
}
|
||||
|
||||
void BlockDriverTester ::
|
||||
testCycleIncrement()
|
||||
{
|
||||
void BlockDriverTester ::testCycleIncrement() {
|
||||
this->clearHistory();
|
||||
|
||||
// call ISR
|
||||
@ -90,4 +77,4 @@ namespace Ref {
|
||||
ASSERT_TLM_BD_Cycles(1, 1);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
@ -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
|
||||
|
||||
@ -42,113 +42,51 @@ namespace Ref {
|
||||
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();
|
||||
}
|
||||
@ -165,7 +103,6 @@ namespace Ref {
|
||||
}
|
||||
|
||||
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,22 +111,14 @@ 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);
|
||||
@ -207,11 +136,9 @@ 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);
|
||||
}
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
// Used to get the Os::Console
|
||||
#include <Os/Os.hpp>
|
||||
|
||||
|
||||
/**
|
||||
* \brief print commandline help message
|
||||
*
|
||||
|
||||
@ -10,9 +10,8 @@
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
|
||||
#include <Ref/PingReceiver/PingReceiverComponentImpl.hpp>
|
||||
#include <Fw/FPrimeBasicTypes.hpp>
|
||||
#include <Ref/PingReceiver/PingReceiverComponentImpl.hpp>
|
||||
|
||||
namespace Ref {
|
||||
|
||||
@ -20,30 +19,16 @@ namespace Ref {
|
||||
// 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
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void PingReceiverComponentImpl ::
|
||||
PingIn_handler(
|
||||
const FwIndexType portNum,
|
||||
U32 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) {
|
||||
@ -51,8 +36,7 @@ namespace Ref {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@ -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,27 +33,22 @@ 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
|
||||
|
||||
@ -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,8 +9,7 @@
|
||||
|
||||
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;
|
||||
@ -19,12 +18,9 @@ namespace Ref {
|
||||
this->m_stats.set_PacketStatus(PacketRecvStatus::PACKET_STATE_NO_PACKETS);
|
||||
}
|
||||
|
||||
RecvBuffImpl::~RecvBuffImpl() {
|
||||
|
||||
}
|
||||
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();
|
||||
@ -69,7 +65,6 @@ 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) {
|
||||
@ -92,4 +87,4 @@ namespace Ref {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
@ -7,14 +7,12 @@ namespace Ref {
|
||||
|
||||
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);
|
||||
Ref::PacketStat m_stats;
|
||||
@ -26,9 +24,8 @@ namespace Ref {
|
||||
|
||||
// parameter update notification
|
||||
void parameterUpdated(FwPrmIdType id);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
#endif
|
||||
|
||||
@ -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;
|
||||
@ -23,12 +22,9 @@ namespace Ref {
|
||||
this->m_state = SendBuff_ActiveState::SEND_IDLE;
|
||||
}
|
||||
|
||||
SendBuffImpl::~SendBuffImpl() {
|
||||
|
||||
}
|
||||
SendBuffImpl::~SendBuffImpl() {}
|
||||
|
||||
void SendBuffImpl::SchedIn_handler(FwIndexType portNum, U32 context) {
|
||||
|
||||
// first, dequeue any messages
|
||||
|
||||
MsgDispatchStatus stat = MSG_DISPATCH_OK;
|
||||
@ -79,7 +75,6 @@ namespace Ref {
|
||||
FW_ASSERT(serStat == Fw::FW_SERIALIZE_OK);
|
||||
// send data
|
||||
this->Data_out(0, this->m_testBuff);
|
||||
|
||||
}
|
||||
|
||||
this->m_invocations++;
|
||||
@ -98,8 +93,7 @@ namespace Ref {
|
||||
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*/
|
||||
@ -111,8 +105,7 @@ namespace Ref {
|
||||
|
||||
//! Handler for command SB_GEN_ASSERT
|
||||
/* Generate an ASSERT */
|
||||
void SendBuffImpl::SB_GEN_ASSERT_cmdHandler(
|
||||
FwOpcodeType opCode, /*!< The opcode*/
|
||||
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*/
|
||||
@ -144,4 +137,4 @@ namespace Ref {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
@ -9,18 +9,15 @@ namespace Ref {
|
||||
|
||||
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
|
||||
|
||||
@ -26,9 +26,8 @@ namespace Ref {
|
||||
// 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,9 +41,7 @@ namespace Ref {
|
||||
m_dpInProgress(false),
|
||||
m_numDps(0),
|
||||
m_currDp(0),
|
||||
m_dpPriority(0)
|
||||
{}
|
||||
|
||||
m_dpPriority(0) {}
|
||||
|
||||
SignalGen ::~SignalGen() {}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -91,11 +85,9 @@ namespace Ref {
|
||||
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
|
||||
@ -154,15 +146,12 @@ 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;
|
||||
@ -252,7 +233,6 @@ namespace Ref {
|
||||
// should never get here
|
||||
FW_ASSERT(0, reqType.e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SignalGen::cleanupAndSendDp() {
|
||||
@ -263,19 +243,11 @@ namespace Ref {
|
||||
this->m_currDp = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 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;
|
||||
@ -293,4 +265,4 @@ namespace Ref {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Ref
|
||||
|
||||
@ -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
|
||||
|
||||
@ -18,29 +18,19 @@ namespace Ref {
|
||||
// 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));
|
||||
}
|
||||
|
||||
SignalGenTester ::
|
||||
~SignalGenTester()
|
||||
{
|
||||
|
||||
}
|
||||
SignalGenTester ::~SignalGenTester() {}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Tests
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void SignalGenTester ::
|
||||
test_start()
|
||||
{
|
||||
void SignalGenTester ::test_start() {
|
||||
ASSERT_TLM_Output_SIZE(0);
|
||||
sendCmd_Toggle(0, 0);
|
||||
component.doDispatch();
|
||||
@ -54,12 +44,10 @@ namespace Ref {
|
||||
// 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
|
||||
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
|
||||
@ -67,21 +55,13 @@ namespace Ref {
|
||||
TextLogEntry e = {id, timeTag, severity, text};
|
||||
|
||||
printTextLogHistoryEntry(e, stdout);
|
||||
|
||||
}
|
||||
|
||||
Fw::Success::T SignalGenTester ::
|
||||
productGet_handler(
|
||||
FwDpIdType id,
|
||||
FwSizeType dataSize,
|
||||
Fw::Buffer& buffer
|
||||
)
|
||||
{
|
||||
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
|
||||
|
||||
@ -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,7 +88,6 @@ namespace Ref {
|
||||
|
||||
U8 m_dpBuff[1024];
|
||||
Fw::Buffer m_reqDpBuff;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace Ref
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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.
|
||||
*
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -141,8 +130,7 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
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;
|
||||
@ -223,4 +204,4 @@ static_assert(FW_USE_PRINTF_FAMILY_FUNCTIONS_IN_STRING_FORMATTING,
|
||||
return PASSED_FILE_CRC_CHECK;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Utils
|
||||
|
||||
@ -19,9 +19,7 @@ namespace Utils {
|
||||
|
||||
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,
|
||||
@ -38,6 +36,6 @@ namespace Utils {
|
||||
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
|
||||
|
||||
@ -13,8 +13,8 @@
|
||||
#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 {
|
||||
|
||||
@ -22,14 +22,11 @@ namespace Utils {
|
||||
//! \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,22 +61,17 @@ 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
|
||||
void final(HashBuffer& buffer //! The result
|
||||
);
|
||||
|
||||
//! Finalize an incremental computation and return the result
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -14,23 +14,15 @@
|
||||
|
||||
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);
|
||||
@ -46,15 +38,11 @@ namespace Utils {
|
||||
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++) {
|
||||
@ -63,9 +51,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
@ -73,21 +59,17 @@ namespace Utils {
|
||||
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);
|
||||
// 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
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
#include "lib_crc.h"
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/*******************************************************************\
|
||||
* *
|
||||
* Library : lib_crc *
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -14,20 +14,13 @@
|
||||
|
||||
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);
|
||||
@ -35,23 +28,17 @@ namespace Utils {
|
||||
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);
|
||||
@ -59,4 +46,4 @@ namespace Utils {
|
||||
buffer = bufferOut;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Utils
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
// clang-format off
|
||||
/* crypto/sha/sha.h */
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
|
||||
@ -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
|
||||
@ -124,16 +87,12 @@ 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
|
||||
@ -142,9 +101,7 @@ namespace Utils {
|
||||
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
|
||||
@ -155,9 +112,7 @@ namespace Utils {
|
||||
return shouldTrigger;
|
||||
}
|
||||
|
||||
void RateLimiter ::
|
||||
updateCounter(bool triggered)
|
||||
{
|
||||
void RateLimiter ::updateCounter(bool triggered) {
|
||||
FW_ASSERT(this->m_counterCycle > 0);
|
||||
|
||||
if (triggered) {
|
||||
@ -172,9 +127,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void RateLimiter ::
|
||||
updateTime(bool triggered, Fw::Time time)
|
||||
{
|
||||
void RateLimiter ::updateTime(bool triggered, Fw::Time time) {
|
||||
FW_ASSERT(this->m_timeCycle > 0);
|
||||
|
||||
if (triggered) {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
//
|
||||
// See below for detailed descriptions
|
||||
|
||||
|
||||
// SEND_CMD
|
||||
//
|
||||
// Send a command and expect a response status. This command essentially calls
|
||||
@ -50,8 +49,7 @@
|
||||
// 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__); \
|
||||
@ -67,8 +65,7 @@
|
||||
// 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__); \
|
||||
@ -86,8 +83,7 @@
|
||||
// // ...
|
||||
// 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); \
|
||||
@ -133,5 +129,4 @@
|
||||
ASSERT_GT(this->fromPortHistory_##port->size(), 0); \
|
||||
ASSERT_from_##port(__VA_ARGS__);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -18,23 +18,11 @@
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
namespace Types {
|
||||
|
||||
class CircularBuffer {
|
||||
|
||||
friend class CircularBufferTester;
|
||||
|
||||
public:
|
||||
@ -157,4 +156,3 @@ class CircularBuffer {
|
||||
};
|
||||
} // End Namespace Types
|
||||
#endif
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -6,7 +6,4 @@
|
||||
|
||||
#include "CircularBufferTester.hpp"
|
||||
|
||||
|
||||
namespace Types {
|
||||
|
||||
}
|
||||
namespace Types {}
|
||||
|
||||
@ -12,9 +12,7 @@
|
||||
namespace Types {
|
||||
|
||||
class CircularBufferTester {
|
||||
|
||||
public:
|
||||
|
||||
static void tester_m_allocated_size_decrement(Types::CircularBuffer& circular_buffer) {
|
||||
circular_buffer.m_allocated_size--;
|
||||
}
|
||||
@ -22,9 +20,8 @@ namespace Types {
|
||||
static FwSizeType tester_get_m_head_idx(Types::CircularBuffer& circular_buffer) {
|
||||
return circular_buffer.m_head_idx;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Types
|
||||
|
||||
#endif
|
||||
|
||||
@ -9,36 +9,27 @@
|
||||
*/
|
||||
#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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
return state.getRemainingSize() >= state.getRandomSize();
|
||||
}
|
||||
|
||||
|
||||
void SerializeOkRule::action(MockTypes::CircularState& state) {
|
||||
state.checkSizes();
|
||||
Fw::SerializeStatus status = state.getTestBuffer().serialize(state.getBuffer(), state.getRandomSize());
|
||||
@ -48,39 +39,28 @@ namespace Types {
|
||||
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) {
|
||||
return state.getRemainingSize() < state.getRandomSize();
|
||||
}
|
||||
|
||||
|
||||
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) {
|
||||
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
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;
|
||||
@ -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,37 +93,29 @@ 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) {
|
||||
FwSizeType peek_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
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;
|
||||
@ -159,26 +129,19 @@ 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) {
|
||||
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
@ -193,10 +156,7 @@ namespace Types {
|
||||
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) {
|
||||
FwSizeType rotate_available = (MAX_BUFFER_SIZE - state.getRemainingSize());
|
||||
@ -206,4 +166,4 @@ namespace Types {
|
||||
void RotateBadRule::action(MockTypes::CircularState& state) {
|
||||
ASSERT_EQ(state.getTestBuffer().rotate(state.getRandomSize()), Fw::FW_DESERIALIZE_BUFFER_EMPTY);
|
||||
}
|
||||
}
|
||||
} // namespace Types
|
||||
|
||||
@ -21,10 +21,9 @@
|
||||
|
||||
#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 {
|
||||
|
||||
@ -139,5 +138,5 @@ namespace Types {
|
||||
// Action that tests the buffer's ability to rotate
|
||||
void action(MockTypes::CircularState& state);
|
||||
};
|
||||
}
|
||||
} // namespace Types
|
||||
#endif // FPRIME_GROUNDINTERFACERULES_HPP
|
||||
|
||||
@ -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,8 +25,7 @@ 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);
|
||||
}
|
||||
|
||||
@ -120,4 +119,4 @@ namespace MockTypes {
|
||||
ASSERT_EQ(m_test_buffer.get_free_size(), m_remaining_size);
|
||||
ASSERT_EQ(m_test_buffer.get_allocated_size(), allocated_size);
|
||||
}
|
||||
}
|
||||
} // namespace MockTypes
|
||||
|
||||
@ -108,5 +108,5 @@ namespace MockTypes {
|
||||
Types::CircularBuffer m_test_buffer;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace MockTypes
|
||||
#endif // FPRIME_CIRCULARSTATE_HPP
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -13,31 +13,21 @@
|
||||
|
||||
#include "RateLimiterTester.hpp"
|
||||
|
||||
|
||||
namespace Utils {
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Construction and destruction
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
RateLimiterTester ::
|
||||
RateLimiterTester()
|
||||
{
|
||||
}
|
||||
RateLimiterTester ::RateLimiterTester() {}
|
||||
|
||||
RateLimiterTester ::
|
||||
~RateLimiterTester()
|
||||
{
|
||||
|
||||
}
|
||||
RateLimiterTester ::~RateLimiterTester() {}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 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];
|
||||
@ -70,9 +60,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
@ -98,7 +86,8 @@ 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);
|
||||
}
|
||||
@ -106,9 +95,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
@ -130,7 +117,8 @@ namespace Utils {
|
||||
curTime.add(0, STest::Pick::lowerUpper(1, 5) * 100000);
|
||||
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;
|
||||
@ -139,14 +127,10 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void RateLimiterTester ::
|
||||
initComponents()
|
||||
{
|
||||
}
|
||||
void RateLimiterTester ::initComponents() {}
|
||||
|
||||
} // end namespace Utils
|
||||
|
||||
@ -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,13 +54,9 @@ namespace Utils {
|
||||
void initComponents();
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // end namespace Utils
|
||||
|
||||
@ -20,24 +20,15 @@ namespace Utils {
|
||||
// Construction and destruction
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
TokenBucketTester ::
|
||||
TokenBucketTester()
|
||||
{
|
||||
}
|
||||
TokenBucketTester ::TokenBucketTester() {}
|
||||
|
||||
TokenBucketTester ::
|
||||
~TokenBucketTester()
|
||||
{
|
||||
|
||||
}
|
||||
TokenBucketTester ::~TokenBucketTester() {}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// 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++) {
|
||||
@ -67,9 +58,7 @@ namespace Utils {
|
||||
}
|
||||
}
|
||||
|
||||
void TokenBucketTester ::
|
||||
testReconfiguring()
|
||||
{
|
||||
void TokenBucketTester ::testReconfiguring() {
|
||||
U32 initialInterval = 1000000;
|
||||
U32 initialMaxTokens = 5;
|
||||
|
||||
@ -101,7 +90,8 @@ namespace Utils {
|
||||
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);
|
||||
@ -110,9 +100,7 @@ namespace Utils {
|
||||
ASSERT_EQ(bucket.getTokens(), 1);
|
||||
}
|
||||
|
||||
void TokenBucketTester ::
|
||||
testInitialSettings()
|
||||
{
|
||||
void TokenBucketTester ::testInitialSettings() {
|
||||
U32 interval = 1000000;
|
||||
U32 maxTokens = 5;
|
||||
U32 rate = 2;
|
||||
@ -131,14 +119,10 @@ namespace Utils {
|
||||
ASSERT_FALSE(bucket.trigger(Fw::Time(0, 0)));
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Helper methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
void TokenBucketTester ::
|
||||
initComponents()
|
||||
{
|
||||
}
|
||||
void TokenBucketTester ::initComponents() {}
|
||||
|
||||
} // end namespace Utils
|
||||
|
||||
@ -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,11 +53,9 @@ namespace Utils {
|
||||
void initComponents();
|
||||
|
||||
private:
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Variables
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
};
|
||||
|
||||
} // end namespace Utils
|
||||
|
||||
@ -24,6 +24,4 @@ namespace Svc {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif /* ACTIVERATEGROUP_ACTIVERATEGROUPCFG_HPP_ */
|
||||
|
||||
@ -7,5 +7,4 @@ namespace Svc {
|
||||
static const U16 BUFFERMGR_MAX_NUM_BINS = 10;
|
||||
}
|
||||
|
||||
|
||||
#endif // __BUFFERMANAGERCOMPONENTIMPLCFG_HPP__
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -15,6 +15,4 @@ enum {
|
||||
CMD_DISPATCHER_SEQUENCER_TABLE_SIZE = 25, // !< The size of the table holding commands in progress
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* CMDDISPATCHER_COMMANDDISPATCHERIMPLCFG_HPP_ */
|
||||
|
||||
@ -15,6 +15,6 @@ namespace Svc {
|
||||
// this size.
|
||||
static const FwIndexType DP_MAX_DIRECTORIES = 2;
|
||||
static const FwIndexType DP_MAX_FILES = 127;
|
||||
}
|
||||
} // namespace Svc
|
||||
|
||||
#endif /* SVC_DPCATALOG_CONFIG_HPP_ */
|
||||
|
||||
@ -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
|
||||
};
|
||||
|
||||
@ -35,4 +35,3 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
#endif // FPRIME_INTEGER_CONFIG_H
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
#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.
|
||||
@ -21,6 +22,7 @@ namespace Svc {
|
||||
// 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_ */
|
||||
|
||||
@ -10,7 +10,7 @@ namespace Svc {
|
||||
//! Lower values = slower directory listing but bounded event rate
|
||||
//! Default: 1
|
||||
static constexpr U32 FILES_PER_RATE_TICK = 1;
|
||||
}
|
||||
}
|
||||
} // namespace FileManagerConfig
|
||||
} // namespace Svc
|
||||
|
||||
#endif
|
||||
|
||||
@ -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
|
||||
|
||||
@ -23,5 +23,4 @@ enum IpCfg {
|
||||
};
|
||||
static const Fw::TimeInterval SOCKET_RETRY_INTERVAL = Fw::TimeInterval(1, 0);
|
||||
|
||||
|
||||
#endif // REF_IPCFG_HPP
|
||||
|
||||
@ -13,11 +13,10 @@ namespace {
|
||||
|
||||
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_ */
|
||||
|
||||
@ -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_ */
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
@ -51,7 +50,6 @@ namespace {
|
||||
// Buckets must be >= number of telemetry channels in system
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif /* TLMCHANIMPLCFG_HPP_ */
|
||||
|
||||
@ -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.
|
||||
// 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_MAX_MISSING_TLM_CHECK =
|
||||
25; // !< Maximum number of missing telemetry channel checks
|
||||
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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user