Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
cbbeb55
Add unit tests for shrinking processed buffer
kubiak-jpl Mar 25, 2026
543990c
Update DpWriter to shrink processed buffers after processing
kubiak-jpl Mar 25, 2026
fc6fa39
Formatting
LeStarch Mar 30, 2026
5372062
Updated DpWriter to use the dataSize in the container header to shrin…
kubiak-jpl Mar 31, 2026
58c9381
Update DpWriter SDD with container shrinking steps
kubiak-jpl Mar 31, 2026
88c9bff
Re-run formatting
kubiak-jpl Mar 31, 2026
6784bc9
Initial build and unit test for DpCompressProc
kubiak-jpl Apr 2, 2026
f1cae22
Added unit tests for DpCompressProc
kubiak-jpl Apr 6, 2026
6ae17e8
ZLib compression engine implemented with unit tests
kubiak-jpl Apr 8, 2026
2c1a5fb
Updated the DpCompressProc record format to use array records
kubiak-jpl Apr 9, 2026
f384a28
Incorporated compressed data products into the Ref demo
kubiak-jpl Apr 9, 2026
1274db2
Removed ENABLE_CHUNKING parameter
kubiak-jpl Apr 14, 2026
d423f0c
Add documentation for DpCompressProc
kubiak-jpl Apr 14, 2026
1c65aee
Updated sdds for DpCompressProc and DpZLibCompressor
kubiak-jpl Apr 15, 2026
db50046
Updated diagrams in DpCompressProc sdd
kubiak-jpl Apr 16, 2026
c438e32
Fixed Requirements display in DpZLibCompressor sdd
kubiak-jpl Apr 16, 2026
a004d68
Merge remote-tracking branch 'origin/devel' into dev/dpcompressproc
kubiak-jpl Jun 3, 2026
4a57e95
Fix DpCompressProc compile errors from latest F Prime devel
kubiak-jpl Jun 3, 2026
37eacac
Cleaned up TODO comments
kubiak-jpl Jun 4, 2026
bac2c93
Update sdd.md with a description of the compression state machine
kubiak-jpl Jun 4, 2026
d695ad2
Add Compression State Machine diagram
kubiak-jpl Jun 4, 2026
0140228
Update DpCompressProc SDD with State Machine diagram
kubiak-jpl Jun 4, 2026
4a3fd69
Fixed compile warning in DpZLibCompressor
kubiak-jpl Jun 5, 2026
0b48918
Address spelling issues
kubiak-jpl Jun 5, 2026
df19f20
Fixing spelling in the proper location
kubiak-jpl Jun 5, 2026
4877373
Fix grammar issues
kubiak-jpl Jun 6, 2026
af60f16
Merge branch 'devel' into dev/dpcompressproc
kubiak-jpl Jun 8, 2026
3125644
Fixed formatting for DpCompressProc and DpZLibCompressor
kubiak-jpl Jun 9, 2026
a53a8c9
Merge branch 'devel' into dev/dpcompressproc
kubiak-jpl Jun 10, 2026
5d87700
Remove += operator due to RHEL compiler error about type promotion
kubiak-jpl Jun 10, 2026
db3044f
Add explicit to internal DpZLibCompressor constructor
kubiak-jpl Jun 10, 2026
54dfffb
Add zlib development files to rhel8 container workflow
kubiak-jpl Jun 10, 2026
7027d29
Add zlib-devel to other RHEL8 workflows
kubiak-jpl Jun 10, 2026
199f2b6
Add cast to FwSizeStoreType
kubiak-jpl Jun 11, 2026
f520ffb
Dummy cast to make RHEL8 happy
kubiak-jpl Jun 11, 2026
a761f3f
Revert changes to DataProduct subtopology and RefPackets
kubiak-jpl Jun 15, 2026
f297d7e
Check for zlib before adding the DpZLibCompressor component to the build
kubiak-jpl Jun 15, 2026
9accf9b
Remove printf from DpZLibCompressorTester
kubiak-jpl Jun 15, 2026
7f98154
Fixed formatting for DpCompressProcTester
kubiak-jpl Jun 15, 2026
eb9193d
Merge remote-tracking branch 'origin/devel' into dev/dpcompressproc
kubiak-jpl Jun 15, 2026
30c80fd
Adding DpCompression subtopology
kubiak-jpl Jun 16, 2026
7a12b72
Expose dpWriter.procBufferSendOut port in DataProducts subtopology
kubiak-jpl Jun 16, 2026
c71d2a0
Add commented out subtopology for DpCompression to Ref deployment
kubiak-jpl Jun 16, 2026
a8be073
Fixed code formatting
kubiak-jpl Jun 16, 2026
2419bf3
Merge remote-tracking branch 'origin/devel' into dev/dpcompressproc
kubiak-jpl Jun 16, 2026
d82d987
Update Svc/DpCompressProc/docs/sdd.md
kubiak-jpl Jun 22, 2026
af3a9bf
Updated docs/ directory with pointers to new Lossless compression work
kubiak-jpl Jun 22, 2026
6cb62f0
Minor fixes to compression components
kubiak-jpl Jun 22, 2026
3ba43d5
Removed TODO. Having the compressor write data at an offset simplifie…
kubiak-jpl Jun 25, 2026
4269ec0
Add events section to DpCompressProc and DpZLibCompressor
kubiak-jpl Jun 25, 2026
06dcae3
Add test for CompressionComplete EVR
kubiak-jpl Jun 25, 2026
c9169cd
Add param_ENABLE DISABLED test
kubiak-jpl Jun 25, 2026
421db16
Added ZLibInitError test
kubiak-jpl Jun 29, 2026
f6d9454
Added more event tests for DpZLibCompressor
kubiak-jpl Jun 29, 2026
5c8c58f
Run fprime-util format
kubiak-jpl Jun 29, 2026
51764d7
Merge remote-tracking branch 'origin/devel' into dev/dpcompressproc
kubiak-jpl Jun 29, 2026
9a4d173
Reject invalid PVN in SpacePacketDeframer (#5291)
peter941221 Jul 2, 2026
0c5015d
Merge remote-tracking branch 'origin/devel' into dev/dpcompressproc
kubiak-jpl Jul 6, 2026
c755df0
Updated TestUtils::Option to Fw::Optional
kubiak-jpl Jul 6, 2026
b995bff
Add ProcType argument to dpDemo integration test
kubiak-jpl Jul 6, 2026
d0d0a29
Fix dp_demo_intergration_test.py formatting
kubiak-jpl Jul 6, 2026
86208dc
CI: run fprime-examples integration tests in the examples workflow
thomas-bc Jul 6, 2026
64b3706
CI: upgrade build tooling before installing integration requirements
thomas-bc Jul 6, 2026
d549f1e
CI: upgrade fprime-gds to devel/pr before examples integration tests
thomas-bc Jul 6, 2026
203cc68
DEMO: point examples workflow at fork PR #1 branch (DataProduct InT)
thomas-bc Jul 6, 2026
897bdbc
Merge branch 'pr5235' into devin/demo-examples-int-green
thomas-bc Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build-test-rhel8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
steps:
- name: "Install dependencies"
run: |
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk zlib-devel
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: "Checkout F´ Repository"
uses: actions/checkout@v4
Expand All @@ -52,7 +52,7 @@ jobs:
steps:
- name: "Install dependencies"
run: |
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk zlib-devel
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: "Checkout F´ Repository"
uses: actions/checkout@v4
Expand All @@ -73,7 +73,7 @@ jobs:
steps:
- name: "Install dependencies"
run: |
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk
dnf install -y git python3.12 python3.12-pip llvm-toolset libasan libubsan java-1.8.0-openjdk zlib-devel
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: "Checkout F´ Repository"
uses: actions/checkout@v4
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/ext-build-examples-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,18 @@ jobs:
name: ""
uses: ./.github/workflows/reusable-project-builder.yml
with:
target_repository: nasa/fprime-examples
# FORK-DEMO OVERRIDE: point at JPL-Devin/fprime-examples PR #1 so the new
# DataProduct/test/int compression test is present. Revert to
# `nasa/fprime-examples` + `needs.get-branch.outputs.target-branch` before
# opening this upstream.
target_repository: JPL-Devin/fprime-examples
build_location: FlightExamples
run_unit_tests: true
target_ref: ${{ needs.get-branch.outputs.target-branch }}
run_integration_tests: true
integration_gds_working_directory: FlightExamples/ExamplesDeployment
integration_test_working_directory: FlightExamples
integration_binary: ../build-artifacts/*/ExamplesDeployment/bin/ExamplesDeployment
integration_gds_args: "--dictionary ../build-artifacts/*/ExamplesDeployment/dict/ExamplesDeploymentTopologyDictionary.json"
integration_pytest_args: "DataProduct/test/int ManagerWorker/Subtopology/test/int --dictionary build-artifacts/*/ExamplesDeployment/dict/ExamplesDeploymentTopologyDictionary.json --no-zmq"
target_ref: devin/1783371774-dp-compression-example
Comment on lines +38 to +51

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 CI workflow hardcoded to fork branch — must be reverted before upstream merge

The examples workflow at .github/workflows/ext-build-examples-repo.yml:38-51 is hardcoded to point at JPL-Devin/fprime-examples with branch devin/1783371774-dp-compression-example instead of the standard nasa/fprime-examples with the dynamic branch from get-branch. The comments at lines 38-41 explicitly acknowledge this is a temporary override for demo purposes. This must be reverted before merging upstream, as it would cause CI to permanently depend on a fork branch that may be deleted.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct and intentional — this is the throwaway demo branch, and the fork-branch override is deliberate (see the comment right above it) so the not-yet-upstream DataProduct/test/int test is present. The real CI PR (#197) keeps target_repository: nasa/fprime-examples + needs.get-branch.outputs.target-branch. This demo branch is marked do-not-merge.

fprime_location: ./FlightExamples/lib/fprime
109 changes: 109 additions & 0 deletions .github/workflows/reusable-project-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,41 @@ on:
required: false
type: boolean
default: true
run_integration_tests:
description: "Run an additional job to build the deployment and run integration tests against it."
required: false
type: boolean
default: false
integration_gds_working_directory:
description: "Directory to start fprime-gds from (relative to repo root). Required when run_integration_tests is true."
required: false
type: string
default: ""
integration_test_working_directory:
description: "Directory to run pytest from (relative to repo root). Required when run_integration_tests is true."
required: false
type: string
default: ""
integration_binary:
description: "Path to the FSW binary to run (relative to integration_gds_working_directory). Required when run_integration_tests is true."
required: false
type: string
default: ""
integration_binary_args:
description: "Arguments passed to the FSW binary."
required: false
type: string
default: "-a 127.0.0.1 -p 50000"
integration_gds_args:
description: "Extra arguments passed to fprime-gds (e.g. --dictionary path)."
required: false
type: string
default: ""
integration_pytest_args:
description: "Extra arguments passed to pytest (e.g. test paths, --dictionary path)."
required: false
type: string
default: ""
Comment on lines +22 to +56

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Integration test job definition appears missing from reusable workflow

The reusable workflow at .github/workflows/reusable-project-builder.yml adds input parameters for integration tests (run_integration_tests, integration_gds_working_directory, integration_binary, etc. at lines 22-56), and the examples workflow at .github/workflows/ext-build-examples-repo.yml:45 sets run_integration_tests: true. However, the diff for reusable-project-builder.yml only shows the build and runUT jobs — there is no runIntegrationTests job defined that would use these new inputs. If this job is truly missing, the integration test inputs would be accepted but silently ignored, and no integration tests would actually run.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive — the runIntegration job is defined in reusable-project-builder.yml (below the build/runUT jobs); the review diff hunk here only shows the new inputs block. Proof it runs: this PR's run / Integration Tests job executed and reported 5 passed in 41.20s. The job is gated on if: ${{ inputs.run_integration_tests }} (default false), so other callers are unaffected.

fprime_location:
description: "Relative path from the external project root to its F´ submodule"
required: false
Expand Down Expand Up @@ -139,3 +174,77 @@ jobs:
fprime-util check -j8 ${VERBOSE_FLAG} ${TARGET_PLATFORM} --pass-through --output-on-failure
shell: bash

runIntegration:
if: ${{ inputs.run_integration_tests }}
runs-on: ${{ inputs.runs_on }}
name: "Integration Tests"
env:
FPRIME_LOCATION: ${{ inputs.fprime_location }}
TARGET_PLATFORM: ${{ inputs.target_platform }}
steps:
- name: "Checkout target repository"
uses: actions/checkout@v4
with:
submodules: recursive
repository: ${{ inputs.target_repository }}
ref: ${{ inputs.target_ref }}
- name: "Overlay current F´ revision"
uses: actions/checkout@v4
with:
submodules: true
path: ${{ inputs.fprime_location }}
# Install the target project's requirements so its GDS plugins (e.g. custom framing)
# are available to fprime-gds; fall back to the F´ submodule requirements otherwise.
- name: "Install requirements.txt"
run: |
# Modern build tooling is required so local source packages (e.g. the
# project's GDS plugins) build with correct metadata; the runner's
# system pip/setuptools can otherwise produce a broken "UNKNOWN" wheel
# with no entry points, which silently drops custom framing plugins.
pip3 install --upgrade pip setuptools wheel
if [ -f "${{ inputs.build_location }}/requirements.txt" ]; then
(cd "${{ inputs.build_location }}" && pip3 install -r requirements.txt)
else
pip3 install -r ${FPRIME_LOCATION}/requirements.txt
fi
shell: bash
# Match the F´ Ref integration tests: run against the in-development GDS
# (this PR's branch or devel) so GDS regressions are caught here too.
- name: "Upgrade fprime-gds to devel or pr-xxxx"
uses: nasa/fprime-actions/upgrade-package@devel
with:
repository: nasa/fprime-gds
- name: "Generate build cache"
working-directory: ${{ inputs.build_location }}
run: |
if [ "${RUNNER_DEBUG:-0}" = "1" ]; then
VERBOSE_FLAG=--verbose
else
VERBOSE_FLAG=
fi
fprime-util generate ${VERBOSE_FLAG} ${TARGET_PLATFORM}
shell: bash
- name: "Build"
working-directory: ${{ inputs.build_location }}
run: |
if [ "${RUNNER_DEBUG:-0}" = "1" ]; then
VERBOSE_FLAG=--verbose
else
VERBOSE_FLAG=
fi
fprime-util build -j8 ${VERBOSE_FLAG} ${TARGET_PLATFORM}
shell: bash
- name: "Make FSW binary executable"
working-directory: ${{ inputs.integration_gds_working_directory }}
run: chmod +x ${{ inputs.integration_binary }}
shell: bash
- name: "Integration Tests"
uses: nasa/fprime-actions/run-integration-tests@devel
with:
gds-working-directory: ${{ inputs.integration_gds_working_directory }}
test-working-directory: ${{ inputs.integration_test_working_directory }}
binary: ${{ inputs.integration_binary }}
binary-args: ${{ inputs.integration_binary_args }}
gds-args: ${{ inputs.integration_gds_args }}
pytest-args: ${{ inputs.integration_pytest_args }}

2 changes: 1 addition & 1 deletion Fw/Types/Serializable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
}
FW_ASSERT(this->getBuffAddr());
// copy buffer to our buffer
(void)memcpy(&this->getBuffAddr()[this->m_serLoc], buff, static_cast<size_t>(length));
(void)memmove(&this->getBuffAddr()[this->m_serLoc], buff, static_cast<size_t>(length));

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buff has not been checked.
this->m_serLoc += static_cast<Serializable::SizeType>(length);
this->m_deserLoc = 0;

Expand Down
2 changes: 2 additions & 0 deletions Svc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,5 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Ccsds/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComAggregator/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/ComRetry/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/PassThroughRouter/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpCompressProc/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/DpZLibCompressor/")
21 changes: 20 additions & 1 deletion Svc/Ccsds/SpacePacketDeframer/SpacePacketDeframer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@

SpacePacketDeframer ::~SpacePacketDeframer() {}

namespace {

bool isValidPacketVersionNumber(const SpacePacketHeader& header) {
const U16 packetIdentification = header.get_packetIdentification();
const U16 pvn = (packetIdentification & SpacePacketSubfields::PvnMask) >> SpacePacketSubfields::PvnOffset;
return pvn == static_cast<U16>(ComCfg::Pvn::SPACE_PACKET_PROTOCOL);
}

} // namespace

// ----------------------------------------------------------------------
// Handler implementations for typed input ports
// ----------------------------------------------------------------------
Expand All @@ -35,7 +45,7 @@
// 1b - 0/1 - (PT) Packet Type
// 1b - 0/1 - (SHF) Secondary Header Flag
// 11b - n/a - (APID) Application Process ID
// 2b - 00 - Sequence Flag
// 2b - 00/01/10/11 - Sequence Flag
// 14b - n/a - Sequence Count
// 16b - n/a - Packet Data Length
// ################################
Expand All @@ -48,7 +58,7 @@
}
this->dataReturnOut_out(0, data, context); // Drop the packet
return;
}

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter context has not been checked.

SpacePacketHeader header;
Fw::SerializeStatus status = data.getDeserializer().deserializeTo(header);
Expand All @@ -62,6 +72,15 @@
return;
}

if (!isValidPacketVersionNumber(header)) {
this->log_WARNING_HI_InvalidPacket();
if (this->isConnected_errorNotify_OutputPort(0)) {
this->errorNotify_out(0, Svc::Ccsds::FrameError::SP_INVALID_PACKET);
}
this->dataReturnOut_out(0, data, context); // Drop the packet
return;
}

// Widen to U32 before adding 1 to prevent U16 truncation to 0 when packetDataLength == 0xFFFF (max U16 value).
// This is a undefined behavior condition in C++.
const U32 pkt_length = static_cast<U32>(header.get_packetDataLength()) + 1U;
Expand Down
2 changes: 2 additions & 0 deletions Svc/Ccsds/SpacePacketDeframer/docs/sdd.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ The `Svc::Ccsds::SpacePacketDeframer` extracts the following fields from the CCS
| Name | Severity | Description |
|---|---|---|
| InvalidLength | `warning high` | Deframing received an invalid packet length |
| InvalidPacket | `warning high` | Deframing received a malformed packet |

## Requirements

Expand All @@ -40,6 +41,7 @@ The `Svc::Ccsds::SpacePacketDeframer` extracts the following fields from the CCS
| SVC-CCSDS-SPD-001 | The SpacePacketDeframer shall deframe CCSDS Space Packets according to the CCSDS 133.0-B-2 standard. | Unit Test, Inspection |
| SVC-CCSDS-SPD-002 | The SpacePacketDeframer shall extract the user data field from valid Space Packets. | Unit Test |
| SVC-CCSDS-SPD-003 | The SpacePacketDeframer shall validate the packet length of a Space Packet Primary Header. | Unit Test |
| SVC-CCSDS-SPD-010 | The SpacePacketDeframer shall validate the Packet Version Number field and reject packets whose Packet Version Number does not match the CCSDS Space Packet Protocol, emitting `InvalidPacket` and returning the buffer. | Unit Test |
| SVC-CCSDS-SPD-009 | The SpacePacketDeframer shall emit an `InvalidLength` event if the packet length token in the header is cannot fit in the received data, and drop the received packet. | Unit Test |
| SVC-CCSDS-SPD-004 | The SpacePacketDeframer shall receive incoming data containing Space Packets via the `dataIn` port. | Unit Test |
| SVC-CCSDS-SPD-005 | The SpacePacketDeframer shall output the extracted Space Packet user data via the `dataOut` port. | Unit Test |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ TEST(SpacePacketDeframer, testBufferSingleByte) {
tester.testBufferSingleByte();
}

TEST(SpacePacketDeframer, testInvalidPacketIdentificationControlFields) {
Svc::Ccsds::SpacePacketDeframerTester tester;
tester.testInvalidPacketIdentificationControlFields();
}

TEST(SpacePacketDeframer, testCommandPacketTypeAccepted) {
Svc::Ccsds::SpacePacketDeframerTester tester;
tester.testCommandPacketTypeAccepted();
}

TEST(SpacePacketDeframer, testSecondaryHeaderFlagAccepted) {
Svc::Ccsds::SpacePacketDeframerTester tester;
tester.testSecondaryHeaderFlagAccepted();
}

TEST(SpacePacketDeframer, testSequenceFlagsAccepted) {
Svc::Ccsds::SpacePacketDeframerTester tester;
tester.testSequenceFlagsAccepted();
}

int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,97 @@ void SpacePacketDeframerTester ::testBufferSingleByte() {
ASSERT_EVENTS_InvalidPacket_SIZE(1);
}

void SpacePacketDeframerTester ::testInvalidPacketIdentificationControlFields() {
U8 payload[2] = {0xAA, 0xBB};
ComCfg::FrameContext nullContext;

Fw::Buffer buffer =
this->assemblePacketWithControlFields(0x1, // invalid PVN for Space Packet Protocol in this component
0x0, 0x0, static_cast<U16>(ComCfg::Apid::FW_PACKET_TELEM), 0x3, 0x0012,
static_cast<U16>(sizeof(payload) - 1), payload, sizeof(payload));

this->invoke_to_dataIn(0, buffer, nullContext);

ASSERT_from_dataOut_SIZE(0);
ASSERT_from_validateApidSeqCount_SIZE(0);
ASSERT_from_dataReturnOut_SIZE(1);
ASSERT_from_errorNotify(0, Svc::Ccsds::FrameError::SP_INVALID_PACKET);
ASSERT_FROM_PORT_HISTORY_SIZE(2);
ASSERT_EVENTS_SIZE(1);
ASSERT_EVENTS_InvalidPacket_SIZE(1);
}

void SpacePacketDeframerTester ::testCommandPacketTypeAccepted() {
this->testControlFieldAccepted(0x0, 0x1, 0x0, ComCfg::Apid::FW_PACKET_COMMAND, 0x3);
}

void SpacePacketDeframerTester ::testSecondaryHeaderFlagAccepted() {
this->testControlFieldAccepted(0x0, 0x0, 0x1, ComCfg::Apid::FW_PACKET_COMMAND, 0x3);
}

void SpacePacketDeframerTester ::testSequenceFlagsAccepted() {
this->testControlFieldAccepted(0x0, 0x0, 0x0, ComCfg::Apid::FW_PACKET_TELEM, 0x1);
}

// ----------------------------------------------------------------------
// Helper functions
// ----------------------------------------------------------------------

void SpacePacketDeframerTester ::testControlFieldAccepted(U16 pvn,
U16 packetType,
U16 secondaryHeaderFlag,
ComCfg::Apid::T expectedApid,
U16 sequenceFlags) {
U8 payload[2] = {0xAA, 0xBB};
const U16 seqCount = 0x0012;
ComCfg::FrameContext nullContext;

Fw::Buffer buffer = this->assemblePacketWithControlFields(
pvn, packetType, secondaryHeaderFlag, static_cast<U16>(expectedApid), sequenceFlags, seqCount,
static_cast<U16>(sizeof(payload) - 1), payload, sizeof(payload));

this->invoke_to_dataIn(0, buffer, nullContext);

ASSERT_from_dataOut_SIZE(1);
ASSERT_from_validateApidSeqCount_SIZE(1);
ASSERT_from_dataReturnOut_SIZE(0);
ASSERT_FROM_PORT_HISTORY_SIZE(2);
ASSERT_EQ(this->fromPortHistory_dataOut->at(0).context.get_apid(), expectedApid);
ASSERT_EQ(this->fromPortHistory_dataOut->at(0).context.get_sequenceCount(), seqCount);
ASSERT_EVENTS_SIZE(0);
}

Fw::Buffer SpacePacketDeframerTester ::assemblePacket(U16 apid,
U16 seqCount,
U16 lengthToken,
U8* packetData,
U16 packetDataLen,
bool hasSecHdr) {
return this->assemblePacketWithControlFields(0x0, 0x0, static_cast<U16>(hasSecHdr), apid, 0x3, seqCount,
lengthToken, packetData, packetDataLen);
}

Fw::Buffer SpacePacketDeframerTester ::assemblePacketWithControlFields(U16 pvn,
U16 packetType,
U16 secondaryHeaderFlag,
U16 apid,
U16 sequenceFlags,
U16 seqCount,
U16 lengthToken,
U8* packetData,
U16 packetDataLen) {
SpacePacketHeader header;
U16 packetId = apid & SpacePacketSubfields::ApidMask;
if (hasSecHdr) {
packetId |= SpacePacketSubfields::SecHdrMask;
}
header.set_packetIdentification(packetId);
header.set_packetSequenceControl(seqCount); // Sequence Flags = 0b11 (unsegmented) & unused Seq count
const U16 packetIdentification = static_cast<U16>(
((pvn << SpacePacketSubfields::PvnOffset) & SpacePacketSubfields::PvnMask) |
((packetType << SpacePacketSubfields::PktTypeOffset) & SpacePacketSubfields::PktTypeMask) |
((secondaryHeaderFlag << SpacePacketSubfields::SecHdrOffset) & SpacePacketSubfields::SecHdrMask) |
(apid & SpacePacketSubfields::ApidMask));
const U16 packetSequenceControl = static_cast<U16>(
((sequenceFlags << SpacePacketSubfields::SeqFlagsOffset) & SpacePacketSubfields::SeqFlagsMask) |
(seqCount & SpacePacketSubfields::SeqCountMask));

header.set_packetIdentification(packetIdentification);
header.set_packetSequenceControl(packetSequenceControl);
header.set_packetDataLength(lengthToken);

Fw::ExternalSerializeBuffer serializer(static_cast<U8*>(this->m_packetBuffer), sizeof(this->m_packetBuffer));
Expand Down
Loading
Loading