Skip to content

Commit

Permalink
Fix data product array record size (#2568)
Browse files Browse the repository at this point in the history
* Fix dp array record size

Use FwStoreType to store the size

* Remove todo comment

* Revise requirements.txt
  • Loading branch information
bocchino authored Mar 6, 2024
1 parent c52f443 commit 8fe3022
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 22 deletions.
12 changes: 6 additions & 6 deletions FppTest/dp/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void Tester::productRecvIn_Container2_FAILURE() {
void Tester::productRecvIn_Container3_SUCCESS() {
Fw::Buffer buffer;
FwSizeType expectedNumElts;
const FwSizeType dataEltSize = sizeof(FwSizeType) + this->u8ArrayRecordData.size();
const FwSizeType dataEltSize = sizeof(FwSizeStoreType) + this->u8ArrayRecordData.size();
// Invoke the port and check the header
this->productRecvIn_InvokeAndCheckHeader(DpTest::ContainerId::Container3, dataEltSize,
DpTest::ContainerPriority::Container3, this->container3Buffer, buffer,
Expand All @@ -145,7 +145,7 @@ void Tester::productRecvIn_Container3_SUCCESS() {
const FwDpIdType expectedId = this->component.getIdBase() + DpTest::RecordId::U8ArrayRecord;
ASSERT_EQ(id, expectedId);
FwSizeType size;
status = serialRepr.deserialize(size);
status = serialRepr.deserializeSize(size);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(size, this->u8ArrayRecordData.size());
const U8* const buffAddr = serialRepr.getBuffAddr();
Expand All @@ -165,7 +165,7 @@ void Tester::productRecvIn_Container3_FAILURE() {
void Tester::productRecvIn_Container4_SUCCESS() {
Fw::Buffer buffer;
FwSizeType expectedNumElts;
const FwSizeType dataEltSize = sizeof(FwSizeType) + this->u32ArrayRecordData.size() * sizeof(U32);
const FwSizeType dataEltSize = sizeof(FwSizeStoreType) + this->u32ArrayRecordData.size() * sizeof(U32);
// Invoke the port and check the header
this->productRecvIn_InvokeAndCheckHeader(DpTest::ContainerId::Container4, dataEltSize,
DpTest::ContainerPriority::Container4, this->container4Buffer, buffer,
Expand All @@ -181,7 +181,7 @@ void Tester::productRecvIn_Container4_SUCCESS() {
const FwDpIdType expectedId = this->component.getIdBase() + DpTest::RecordId::U32ArrayRecord;
ASSERT_EQ(id, expectedId);
FwSizeType size;
status = serialRepr.deserialize(size);
status = serialRepr.deserializeSize(size);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(size, this->u32ArrayRecordData.size());
const U8* const buffAddr = serialRepr.getBuffAddr();
Expand All @@ -201,7 +201,7 @@ void Tester::productRecvIn_Container4_FAILURE() {
void Tester::productRecvIn_Container5_SUCCESS() {
Fw::Buffer buffer;
FwSizeType expectedNumElts;
const FwSizeType dataEltSize = sizeof(FwSizeType) + this->dataArrayRecordData.size() * DpTest_Data::SERIALIZED_SIZE;
const FwSizeType dataEltSize = sizeof(FwSizeStoreType) + this->dataArrayRecordData.size() * DpTest_Data::SERIALIZED_SIZE;
// Invoke the port and check the header
this->productRecvIn_InvokeAndCheckHeader(DpTest::ContainerId::Container5, dataEltSize,
DpTest::ContainerPriority::Container5, this->container5Buffer, buffer,
Expand All @@ -217,7 +217,7 @@ void Tester::productRecvIn_Container5_SUCCESS() {
const FwDpIdType expectedId = this->component.getIdBase() + DpTest::RecordId::DataArrayRecord;
ASSERT_EQ(id, expectedId);
FwSizeType size;
status = serialRepr.deserialize(size);
status = serialRepr.deserializeSize(size);
ASSERT_EQ(status, Fw::FW_SERIALIZE_OK);
ASSERT_EQ(size, this->dataArrayRecordData.size());
const U8* const buffAddr = serialRepr.getBuffAddr();
Expand Down
6 changes: 1 addition & 5 deletions Fw/Dp/docs/sdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,9 @@ Array records with _type = T_ have the following format:
|Field Name|Data Type|Serialized Size|Description|
|----------|---------|---------------|-----------|
|`Id`|`FwDpIdType`|`sizeof(FwDpIdType)`|The record ID|
|`Size`|`FwSizeType`|`sizeof(FwSizeType)`|The number _n_ of elements in the record|
|`Size`|`FwSizeType`|`sizeof(FwSizeStoreType)`|The number _n_ of elements in the record|
|`Data`|Array of _n_ _T_|_n_ * [`sizeof(`_T_`)` if _T_ is a primitive type; otherwise _T_`::SERIALIZED_SIZE`]|_n_ elements, each of type _T_|

_TODO: The array size should be serialized as `FwSizeStoreType`.
This requires a change to the FPP code generation.
See https://github.com/fprime-community/fpp/issues/393._

#### 5.1.4. Data Hash

The data hash has the following format.
Expand Down
22 changes: 11 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ fprime-fpl-convert-xml==1.0.3
fprime-fpl-extract-xml==1.0.3
fprime-fpl-layout==1.0.3
fprime-fpl-write-pic==1.0.3
fprime-fpp-check==2.1.0a4
fprime-fpp-depend==2.1.0a4
fprime-fpp-filenames==2.1.0a4
fprime-fpp-format==2.1.0a4
fprime-fpp-from-xml==2.1.0a4
fprime-fpp-locate-defs==2.1.0a4
fprime-fpp-locate-uses==2.1.0a4
fprime-fpp-syntax==2.1.0a4
fprime-fpp-to-cpp==2.1.0a4
fprime-fpp-to-json==2.1.0a4
fprime-fpp-to-xml==2.1.0a4
fprime-fpp-check==2.1.0a5
fprime-fpp-depend==2.1.0a5
fprime-fpp-filenames==2.1.0a5
fprime-fpp-format==2.1.0a5
fprime-fpp-from-xml==2.1.0a5
fprime-fpp-locate-defs==2.1.0a5
fprime-fpp-locate-uses==2.1.0a5
fprime-fpp-syntax==2.1.0a5
fprime-fpp-to-cpp==2.1.0a5
fprime-fpp-to-json==2.1.0a5
fprime-fpp-to-xml==2.1.0a5
fprime-gds==3.4.3
fprime-tools==3.4.4
fprime-visual==1.0.2
Expand Down

0 comments on commit 8fe3022

Please sign in to comment.