Skip to content

Commit

Permalink
Fix string records for data products (#2697)
Browse files Browse the repository at this point in the history
* Revise Linux platform types

* Fix regression in test autocoder

TimeBaseStoreType is not the same as TimeBase

* Revise test autocoder

Cast to the TimeBaseStore type with a known size

* Revise test autocoder

Remove unnecessary const casting

* Fix integer type mismatch in ComQueue

* Update fpp version

* Update fpp version

* Revise DpWriter unit tests

Remove manually written functions
Use new autocode in tester base

* Update fpp version

* Update fpp version

* Revise DpTest

Add check for priority set by dpGet

* Reivse StringType; add ExternalString

* Revise dp test

* Revise dp test; update fpp version

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise dp test

* Revise fpp version

* Update fpp version

* Revise ExternalString

* Reformat Fw/Serializable.{hpp,cpp}

* Reformat StringType.{hpp,cpp}

* Revise StringBase

* Update fpp version

* Remove trailing space

* Reformat code

* Revise dp test

* Reformat cpp and hpp files in Fw/Types

* Revise string types

* Revise string types

* Revise string types

* Remove EightyCharString

* Revise CmdString

* Revise LogString

* Revise PrmString

* Revise TextLogString

* Revise Test/String

* Revise TlmString

* Revise InternalInterfaceString

* Revise Os/QueueString

* Revise Os/TaskString

* Add missing type qualifier

* Fix warning in String.hpp

* Revise string types

* Remove stray character

* Revise StringBase

* Revise string types

* Revise String type

* Revise FileNameString

* Revise string types

* Add missing file

* Revise InternalInterfaceString

* Revise comment

* Revise TlmString

* Revise string types

* Revise log strings

* Revise PrmString

* Revise Os string classes

* Revise string types

* Revise string types

* Revise os strings

* Add test for ExternalString to TypesTest

* Revise ExternalString

* Revise ExternalString

* Update fpp version

* Format Fw/Types

* Update fpp version

* Revise code formatting

* Remove helper scripts

* Update fpp version

* Fix spelling

* Update requirements

* Update actions@version

* Fix pip-check CI by restricting versions

* Remove debugging instructions

---------

Co-authored-by: thomas-bc <[email protected]>
Co-authored-by: M Starch <[email protected]>
  • Loading branch information
3 people authored Apr 25, 2024
1 parent 4557066 commit f265eb2
Show file tree
Hide file tree
Showing 10 changed files with 340 additions and 79 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/pip-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ jobs:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
runner: [macos-latest, ubuntu-latest]
runner: [macos-13, macos-latest, ubuntu-latest]
# macos-14 (ARM) currently breaks actions/setup-python with 3.8 and 3.9
# so we exclude them from the matrix and also test with macos-13 (x86)
# More info at https://github.com/actions/setup-python/issues/850
exclude:
- runner: macos-latest
python-version: '3.8'
- runner: macos-latest
python-version: '3.9'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
53 changes: 46 additions & 7 deletions FppTest/dp/DpTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ namespace FppTest {
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

DpTest ::DpTest(const char* const compName,
U32 u32RecordData,
U16 dataRecordData,
const U8ArrayRecordData& u8ArrayRecordData,
const U32ArrayRecordData& u32ArrayRecordData,
const DataArrayRecordData& dataArrayRecordData)
DpTest::DpTest(const char* const compName,
U32 u32RecordData,
U16 dataRecordData,
const U8ArrayRecordData& u8ArrayRecordData,
const U32ArrayRecordData& u32ArrayRecordData,
const DataArrayRecordData& dataArrayRecordData,
const Fw::StringBase& a_stringRecordData)
: DpTestComponentBase(compName),
u32RecordData(u32RecordData),
dataRecordData(dataRecordData),
u8ArrayRecordData(u8ArrayRecordData),
u32ArrayRecordData(u32ArrayRecordData),
dataArrayRecordData(dataArrayRecordData),
sendTime(Fw::ZERO_TIME) {}
stringRecordData(a_stringRecordData),
sendTime(Fw::ZERO_TIME) {
for (auto& elt : this->stringArrayRecordData) {
elt = &a_stringRecordData;
}
}

void DpTest ::init(const NATIVE_INT_TYPE queueDepth, const NATIVE_INT_TYPE instance) {
DpTestComponentBase::init(queueDepth, instance);
Expand All @@ -50,6 +56,8 @@ void DpTest::schedIn_handler(const NATIVE_INT_TYPE portNum, U32 context) {
this->dpRequest_Container4(CONTAINER_4_DATA_SIZE);
// Request a buffer for Container 5
this->dpRequest_Container5(CONTAINER_5_DATA_SIZE);
// Request a buffer for Container 6
this->dpRequest_Container6(CONTAINER_6_DATA_SIZE);
// Get a buffer for Container 1
{
DpContainer container;
Expand Down Expand Up @@ -178,6 +186,37 @@ void DpTest ::dpRecv_Container5_handler(DpContainer& container, Fw::Success::T s
}
}

void DpTest ::dpRecv_Container6_handler(DpContainer& container, Fw::Success::T status) {
if (status == Fw::Success::SUCCESS) {
auto serializeStatus = Fw::FW_SERIALIZE_OK;
for (FwSizeType i = 0; i < CONTAINER_6_DATA_SIZE; ++i) {
serializeStatus = container.serializeRecord_StringRecord(this->stringRecordData);
if (serializeStatus == Fw::FW_SERIALIZE_NO_ROOM_LEFT) {
break;
}
FW_ASSERT(serializeStatus == Fw::FW_SERIALIZE_OK, status);
}
// Use the time stamp from the time get port
this->dpSend(container);
}
}

void DpTest ::dpRecv_Container7_handler(DpContainer& container, Fw::Success::T status) {
if (status == Fw::Success::SUCCESS) {
auto serializeStatus = Fw::FW_SERIALIZE_OK;
for (FwSizeType i = 0; i < CONTAINER_7_DATA_SIZE; ++i) {
serializeStatus = container.serializeRecord_StringArrayRecord(
this->stringArrayRecordData, FW_NUM_ARRAY_ELEMENTS(this->stringArrayRecordData));
if (serializeStatus == Fw::FW_SERIALIZE_NO_ROOM_LEFT) {
break;
}
FW_ASSERT(serializeStatus == Fw::FW_SERIALIZE_OK, status);
}
// Use the time stamp from the time get port
this->dpSend(container);
}
}

// ----------------------------------------------------------------------
// Private helper functions
// ----------------------------------------------------------------------
Expand Down
18 changes: 18 additions & 0 deletions FppTest/dp/DpTest.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module FppTest {
@ A component for testing data product code gen
active component DpTest {

# ----------------------------------------------------------------------
# Constants
# ----------------------------------------------------------------------

constant stringSize = 80

# ----------------------------------------------------------------------
# Types
# ----------------------------------------------------------------------
Expand Down Expand Up @@ -58,6 +64,12 @@ module FppTest {
@ Record 5
product record DataArrayRecord: Data array id 500

@ Record 6
product record StringRecord: string size stringSize id 600

@ Record 7
product record StringArrayRecord: string size stringSize array id 700

# ----------------------------------------------------------------------
# Containers
# ----------------------------------------------------------------------
Expand All @@ -77,6 +89,12 @@ module FppTest {
@ Container 5
product container Container5 id 500 default priority 50

@ Container 6
product container Container6 id 600 default priority 60

@ Container 7
product container Container7 id 700 default priority 70

}

}
126 changes: 77 additions & 49 deletions FppTest/dp/DpTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
#include <array>

#include "FppTest/dp/DpTestComponentAc.hpp"
#include "Fw/Types/String.hpp"

namespace FppTest {

class DpTest : public DpTestComponentBase {

// Friend class for testing
friend class Tester;

public:
// ----------------------------------------------------------------------
// Constants
Expand All @@ -29,6 +34,12 @@ class DpTest : public DpTestComponentBase {
static constexpr FwSizeType CONTAINER_4_PACKET_SIZE = DpContainer::getPacketSizeForDataSize(CONTAINER_4_DATA_SIZE);
static constexpr FwSizeType CONTAINER_5_DATA_SIZE = 1000;
static constexpr FwSizeType CONTAINER_5_PACKET_SIZE = DpContainer::getPacketSizeForDataSize(CONTAINER_5_DATA_SIZE);
static constexpr FwSizeType CONTAINER_6_DATA_SIZE = 1000;
static constexpr FwSizeType CONTAINER_6_PACKET_SIZE = DpContainer::getPacketSizeForDataSize(CONTAINER_6_DATA_SIZE);
static constexpr FwSizeType CONTAINER_7_DATA_SIZE = 1000;
static constexpr FwSizeType CONTAINER_7_PACKET_SIZE = DpContainer::getPacketSizeForDataSize(CONTAINER_7_DATA_SIZE);

static constexpr FwSizeType STRING_ARRAY_RECORD_ARRAY_SIZE = 100;

public:
// ----------------------------------------------------------------------
Expand All @@ -38,19 +49,21 @@ class DpTest : public DpTestComponentBase {
using U8ArrayRecordData = std::array<U8, 256>;
using U32ArrayRecordData = std::array<U32, 100>;
using DataArrayRecordData = std::array<DpTest_Data, 300>;
using PtrToConstStringBase = const Fw::StringBase*;

public:
// ----------------------------------------------------------------------
// Construction, initialization, and destruction
// ----------------------------------------------------------------------

//! Construct object DpTest
DpTest(const char* const compName, //!< The component name
U32 u32RecordData, //!< The U32Record data
U16 dataRecordData, //!< The DataRecord data
const U8ArrayRecordData& u8ArrayRecordData, //!< The U8ArrayRecord data
const U32ArrayRecordData& u32ArrayRecordData, //!< The U32ArrayRecord data
const DataArrayRecordData& dataArrayRecordData //!< The DataArrayRecord data
DpTest(const char* const compName, //!< The component name
U32 u32RecordData, //!< The U32Record data
U16 dataRecordData, //!< The DataRecord data
const U8ArrayRecordData& u8ArrayRecordData, //!< The U8ArrayRecord data
const U32ArrayRecordData& u32ArrayRecordData, //!< The U32ArrayRecord data
const DataArrayRecordData& dataArrayRecordData, //!< The DataArrayRecord data
const Fw::StringBase& stringRecordData //!< The StringRecord data
);

//! Initialize object DpTest
Expand All @@ -69,73 +82,82 @@ class DpTest : public DpTestComponentBase {
//! Set the send time
void setSendTime(Fw::Time time) { this->sendTime = time; }

PRIVATE :
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for schedIn
void
schedIn_handler(const NATIVE_INT_TYPE portNum, //!< The port number
U32 context //!< The call order
) override;

PRIVATE :
// ----------------------------------------------------------------------
// Data product handler implementations
// ----------------------------------------------------------------------

//! Receive a data product container of type Container1
//! \return Serialize status
void
dpRecv_Container1_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) override;
private:
// ----------------------------------------------------------------------
// Handler implementations for user-defined typed input ports
// ----------------------------------------------------------------------

//! Handler implementation for schedIn
void schedIn_handler(const NATIVE_INT_TYPE portNum, //!< The port number
U32 context //!< The call order
) final;

private:
// ----------------------------------------------------------------------
// Data product handler implementations
// ----------------------------------------------------------------------

//! Receive a data product container of type Container1
//! \return Serialize status
void dpRecv_Container1_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) final;

//! Receive a data product container of type Container2
//! \return Serialize status
void dpRecv_Container2_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) override;
) final;

//! Receive a data product container of type Container3
//! \return Serialize status
void dpRecv_Container3_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) override;
) final;

//! Receive a data product container of type Container4
//! \return Serialize status
void dpRecv_Container4_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) override;
) final;

//! Receive a data product container of type Container5
//! \return Serialize status
void dpRecv_Container5_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) override;
) final;

PRIVATE :
// ----------------------------------------------------------------------
// Private helper functions
// ----------------------------------------------------------------------
//! Receive a data product container of type Container6
//! \return Serialize status
void dpRecv_Container6_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) final;

//! Receive a data product container of type Container7
//! \return Serialize status
void dpRecv_Container7_handler(DpContainer& container, //!< The container
Fw::Success::T //!< The container status
) final;

private:
// ----------------------------------------------------------------------
// Private helper functions
// ----------------------------------------------------------------------

//! Check a container for validity
void
checkContainer(const DpContainer& container, //!< The container
FwDpIdType localId, //!< The expected local id
FwSizeType size, //!< The expected size
FwDpPriorityType priority //!< The expected priority
) const;
//! Check a container for validity
void checkContainer(const DpContainer& container, //!< The container
FwDpIdType localId, //!< The expected local id
FwSizeType size, //!< The expected size
FwDpPriorityType priority //!< The expected priority
) const;

PRIVATE :
// ----------------------------------------------------------------------
// Private member variables
// ----------------------------------------------------------------------
private:
// ----------------------------------------------------------------------
// Private member variables
// ----------------------------------------------------------------------

//! U32Record data
const U32 u32RecordData;
//! U32Record data
const U32 u32RecordData;

//! DataRecord data
const U16 dataRecordData;
Expand All @@ -149,6 +171,12 @@ class DpTest : public DpTestComponentBase {
//! DataArrayRecord data
const DataArrayRecordData& dataArrayRecordData;

//! StringRecord data
const Fw::StringBase& stringRecordData;

//! StringArrayRecord data
PtrToConstStringBase stringArrayRecordData[STRING_ARRAY_RECORD_ARRAY_SIZE];

//! Send time for testing
Fw::Time sendTime;
};
Expand Down
24 changes: 24 additions & 0 deletions FppTest/dp/test/ut/TestMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ TEST(productRecvIn, Container5_FAILURE) {
tester.productRecvIn_Container5_FAILURE();
}

TEST(productRecvIn, Container6_SUCCESS) {
COMMENT("Receive Container6 SUCCESS");
Tester tester;
tester.productRecvIn_Container6_SUCCESS();
}

TEST(productRecvIn, Container6_FAILURE) {
COMMENT("Receive Container6 FAILURE");
Tester tester;
tester.productRecvIn_Container6_FAILURE();
}

TEST(productRecvIn, Container7_SUCCESS) {
COMMENT("Receive Container7 SUCCESS");
Tester tester;
tester.productRecvIn_Container7_SUCCESS();
}

TEST(productRecvIn, Container7_FAILURE) {
COMMENT("Receive Container7 FAILURE");
Tester tester;
tester.productRecvIn_Container7_FAILURE();
}

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
STest::Random::seed();
Expand Down
Loading

0 comments on commit f265eb2

Please sign in to comment.