From 10d07574931051cce8f3209787c4dabd136289aa Mon Sep 17 00:00:00 2001 From: Walker Date: Wed, 13 May 2026 13:32:37 -0500 Subject: [PATCH 01/18] Part cFS/workflows#129, Use Updated Static Analysis Workflow --- .github/workflows/static-analysis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 52e299eb..85dccf26 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,6 +1,5 @@ name: Static Analysis -# Run on all push and pull requests on: push: branches: @@ -16,4 +15,6 @@ on: jobs: static-analysis: name: Static Analysis - uses: nasa/cFS/.github/workflows/app-static-analysis-reusable.yml@dev + uses: nasa/cFS/.github/workflows/static-analysis-reusable.yml@dev + with: + source-dir: 'source/fsw' \ No newline at end of file From ed344483c8b7423eec48c38147ef027c534b22e9 Mon Sep 17 00:00:00 2001 From: Michael Yang Date: Thu, 28 May 2026 15:44:09 -0400 Subject: [PATCH 02/18] Fix nasa#497, Suppress ignored return value warning in codeSonar --- fsw/src/cf_cfdp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index cbe00593..5433fe7d 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -2326,7 +2326,9 @@ void CF_CFDP_DisableEngine(void) /* finally all queue counters must be reset */ memset(&CF_AppData.hk.Payload.channel_hk[i].q_size, 0, sizeof(CF_AppData.hk.Payload.channel_hk[i].q_size)); - CFE_SB_DeletePipe(chan->pipe); + /* SAD: Suppress Ignored Return Value warning from CodeSonar. CFE_SB_DeletePipe() will send event message if + * there is any error */ + (void)CFE_SB_DeletePipe(chan->pipe); } } From e95cbf88d8363306ba232df9cd0c4618e3cf7b12 Mon Sep 17 00:00:00 2001 From: Walker Date: Tue, 16 Jun 2026 11:21:57 -0500 Subject: [PATCH 03/18] Fix #502, Initialize Variable msg_size in cf_cfdp_sbintf.c --- fsw/src/cf_cfdp_sbintf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index 1658d485..c60353fa 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -187,13 +187,16 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) const int chan_num = (chan - CF_AppData.engine.channels); CFE_SB_Buffer_t *bufptr; CFE_MSG_Size_t msg_size; - CFE_MSG_Type_t msg_type = CFE_MSG_Type_Invalid; + CFE_MSG_Type_t msg_type; CF_Logical_PduBuffer_t *ph; for (; count < CF_AppData.config_table->chan[chan_num].rx_max_messages_per_wakeup; ++count) { - status = CFE_SB_ReceiveBuffer(&bufptr, chan->pipe, CFE_SB_POLL); + bufptr = NULL; + msg_size = 0; + msg_type = CFE_MSG_Type_Invalid; + status = CFE_SB_ReceiveBuffer(&bufptr, chan->pipe, CFE_SB_POLL); if (status != CFE_SUCCESS) { break; /* no more messages */ From de6ee9c05654f9a1030acb8a275b444a49e1f57b Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 21 Jul 2026 20:46:53 +0000 Subject: [PATCH 04/18] Part nasa/cFS#1079, Adding specialty PR templates and links to the specialty PR templates in the default PR template. --- .../comment_documentation_change.md | 50 +++++++++++ .../PULL_REQUEST_TEMPLATE/fsw_code_change.md | 88 +++++++++++++++++++ .../PULL_REQUEST_TEMPLATE/workflows_change.md | 50 +++++++++++ .github/pull_request_template.md | 6 ++ 4 files changed, 194 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md create mode 100644 .github/PULL_REQUEST_TEMPLATE/fsw_code_change.md create mode 100644 .github/PULL_REQUEST_TEMPLATE/workflows_change.md diff --git a/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md b/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md new file mode 100644 index 00000000..4c5537cc --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md @@ -0,0 +1,50 @@ +--- +name: Comment / Documentation Change +about: Changes limited to comments, README, docstrings, or other documentation +labels: documentation +--- + +## Description of Change + + + +## Linked Issue + + +Closes # + +## Areas of Expertise Touched + + +- [ ] ASTRO +- [ ] CI/CD +- [ ] COSMOS +- [ ] Cybersecurity +- [ ] Docker +- [ ] EDS +- [ ] Git +- [ ] PSPs +- [ ] SBN +- [ ] SMP +- [ ] Tables +- [ ] TSN +- [ ] Unit Tests +- [ ] Other + +--- + +## Author Checklist + +- [ ] Linked GitHub issue is referenced above/linked to this PR +- [ ] Documentation generation workflow ran successfully on this branch +- [ ] Changes are limited to documentation/comments (no code behavior changes) + +--- + +## Reviewer Checklist + +- [ ] Documentation is clear, accurate, and complete +- [ ] Spelling and grammar reviewed +- [ ] Any links in the documentation have been verified to work +- [ ] Documentation generation workflow output looks correct +- [ ] Appropriate Expert areas have been reviewed \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md b/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md new file mode 100644 index 00000000..4701113d --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md @@ -0,0 +1,88 @@ +--- +name: FSW Code Change +about: Flight Software code changes +labels: fsw +--- + +## Description of Change + + + +## Linked Issue + +Closes # + +## Requirements Impact + + +- Requirement ID(s): +- [ ] Requirements updated as necessary +- [ ] Existing requirements are still satisfied by this change + +## Testing Evidence + + + +### Unit Tests (UT Assert) + + +### COSMOS Test Suite + + +## Areas of Expertise Touched + +- [ ] ASTRO +- [ ] CI/CD +- [ ] COSMOS +- [ ] Cybersecurity +- [ ] Docker +- [ ] EDS +- [ ] Git +- [ ] PSPs +- [ ] SBN +- [ ] SMP +- [ ] Tables +- [ ] TSN +- [ ] Unit Tests +- [ ] Other + +--- + +## Author Checklist + +- [ ] Linked GitHub issue is referenced above +- [ ] Code has been formatted with `.clang-format` +- [ ] Static analysis workflows ran and passed +- [ ] Unit tests (UT Assert) updated/added to cover code changes +- [ ] Unit test workflows ran and passed +- [ ] COSMOS test suite was run; tests updated/added if relevant changes were made +- [ ] Requirements have been reviewed; updated or confirmed still satisfied (see above) +- [ ] Testing evidence is included above +- [ ] Self-review of the diff completed + +--- + +## Reviewer Checklist + +- [ ] Code logic is correct and matches the stated intent +- [ ] Code is readable, maintainable, and follows project conventions +- [ ] `.clang-format` has been applied +- [ ] Static analysis results reviewed and acceptable +- [ ] Unit tests are meaningful and adequately cover the changes +- [ ] **The change has been exercised by the unit tests** (not just that tests pass — the new/changed code paths are actually covered) +- [ ] **COSMOS test suite was executed against this change** and results reviewed (or confirmed N/A with justification) +- [ ] **Reviewer has independently verified the change behaves as described** (e.g., by running the tests locally, reviewing CI output in detail, or performing additional ad-hoc testing as warranted) +- [ ] **Memory safety** reviewed (allocation, bounds, lifetime, stack usage) +- [ ] Requirements impact reviewed and appropriate +- [ ] Error handling is appropriate +- [ ] Appropriate Expert areas have been reviewed + +### Reviewer Testing Notes + + \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE/workflows_change.md b/.github/PULL_REQUEST_TEMPLATE/workflows_change.md new file mode 100644 index 00000000..8fe91cb4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/workflows_change.md @@ -0,0 +1,50 @@ +--- +name: Workflows Change +about: Changes to files under .github/workflows/ +labels: ci/workflows +--- + +## Description of Change + + + +## Linked Issue + +Closes # + +## Areas of Expertise Touched + +- [ ] ASTRO +- [ ] CI/CD +- [ ] COSMOS +- [ ] Cybersecurity +- [ ] Docker +- [ ] EDS +- [ ] Git +- [ ] PSPs +- [ ] SBN +- [ ] SMP +- [ ] Tables +- [ ] TSN +- [ ] Unit Tests +- [ ] Other + +--- + +## Author Checklist + +- [ ] Linked GitHub issue is referenced above +- [ ] Workflow changes were tested on a branch/fork before submitting this PR +- [ ] All workflows ran successfully on this branch + +--- + +## Reviewer Checklist + +- [ ] Workflow logic is correct and achieves the stated goal +- [ ] Third-party actions are from trusted sources and pinned to a specific SHA/tag +- [ ] Secrets are handled appropriately (no secrets exposed in logs, least-privilege usage) +- [ ] Workflow permissions follow the principle of least privilege +- [ ] Changes do not break or bypass existing branch protection rules +- [ ] All workflow runs on this PR completed successfully +- [ ] Appropriate Expert areas have been reviewed \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 0789aebb..fd963177 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -32,3 +32,9 @@ If included, identify any third party code and provide text file of license **Contributor Info - All information REQUIRED for consideration of pull request** Full name and company/organization/center of all contributors ("Personal" if individual work) - Note CLA's apply to software contributions. + +**For members of the cFS Team** +Click the `Preview` tab and select the pull request template corresponding to the type of change you are submitting: +- [Comment/Documentation Change](?expand=1&template=comment_documentation_change.md) +- [Flight Software Code Change](?expand=1&template=fsw_code_change.md) +- [Workflows Change](?expand=1&template=workflows_change.md) From 03990bc9d9cc3ab9ab339b330bee59ff189f0ba4 Mon Sep 17 00:00:00 2001 From: Walker Date: Wed, 29 Jul 2026 10:56:15 -0500 Subject: [PATCH 05/18] Fix #506, Remove Dead Functions --- unit-test/CMakeLists.txt | 1 - unit-test/cf_cmd_tests.c | 62 ------ unit-test/cf_utils_tests.c | 43 ----- unit-test/stubs/cf_cfdp_handlers.c | 17 -- unit-test/stubs/cf_clist_handlers.c | 17 -- unit-test/stubs/cf_cmd_handlers.c | 51 ----- unit-test/stubs/cf_utils_handlers.c | 16 -- unit-test/stubs/cf_utils_stubs.c | 1 - unit-test/utilities/cf_test_alt_handler.c | 20 -- unit-test/utilities/cf_test_alt_handler.h | 4 - unit-test/utilities/cf_test_utils.c | 221 ---------------------- unit-test/utilities/cf_test_utils.h | 22 --- 12 files changed, 475 deletions(-) delete mode 100644 unit-test/stubs/cf_cmd_handlers.c diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index a2b75c3e..41548a20 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -51,7 +51,6 @@ add_cfe_coverage_stubs(cf_internal stubs/cf_chunk_stubs.c stubs/cf_clist_handlers.c stubs/cf_clist_stubs.c - stubs/cf_cmd_handlers.c stubs/cf_cmd_stubs.c stubs/cf_codec_handlers.c stubs/cf_codec_stubs.c diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index c9c7fcc2..fc06f8e2 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -45,11 +45,6 @@ void cf_cmd_tests_Teardown(void) ** *******************************************************************************/ -CF_CFDP_Class_t Any_cfdp_class_t(void) -{ - return (CF_CFDP_Class_t)AnyCoinFlip(); -} - CF_EntityId_t Any_CF_EntityId_t(void) { return (CF_EntityId_t)Any_uint8(); @@ -2697,63 +2692,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } -void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnSecondCallAnd_wq_IsDownAnd_queue_IsActive_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( - void) -{ - /* Arrange */ - CF_WriteQueueCmd_t utbuf; - CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile[2]; - int32 forced_return_CF_WriteTxnQueueDataToFile_1st_call = 0; - int32 forced_return_CF_WriteTxnQueueDataToFile_2nd_call = Any_int32_Except(0); - int32 context_CF_WrappedClose_fd; - uint16 initial_hk_err_counter = Any_uint16(); - - memset(&utbuf, 0, sizeof(utbuf)); - - /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); - - /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_Queue_active; - - /* valid result from CF_WrappedCreat */ - strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - - /* invalid result from CF_WriteTxnQueueDataToFile */ - UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), - &context_CF_WriteTxnQueueDataToFile, - sizeof(context_CF_WriteTxnQueueDataToFile), - false); - UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile_1st_call); - UT_SetDeferredRetcode(UT_KEY(CF_WriteTxnQueueDataToFile), 2, forced_return_CF_WriteTxnQueueDataToFile_2nd_call); - - UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; - - /* Act */ - CF_WriteQueueCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CF_WriteTxnQueueDataToFile, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_WQ_WRITEQ_TX_ERR_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 1); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); -} - void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDownAnd_queue_IsPend_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( void) { diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index e178fa93..97efd604 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -59,17 +59,6 @@ CF_QueueIdx_t Any_cf_queue_index_t(void) return (CF_QueueIdx_t)Any_uint16_LessThan(CF_QueueIdx_NUM); } -CF_Direction_t Any_direction_t(void) -{ - return (CF_Direction_t)Any_uint8_LessThan(CF_Direction_NUM); -} - -CF_CFDP_ConditionCode_t Any_condition_code_t(void) -{ - uint8 codes[13] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15 }; - return (CF_CFDP_ConditionCode_t)Any_uint8_FromThese(codes, sizeof(codes) / sizeof(codes[0])); -} - void local_handler_OS_close(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) { int32 status; @@ -591,38 +580,6 @@ void Test_CF_Traverse_WriteTxnQueueEntryToFile(void) UtAssert_BOOL_TRUE(args.error); } -/******************************************************************************* -** -** CF_WriteHistoryEntryToFile tests -** -*******************************************************************************/ - -void Test_CF_WriteHistoryEntryToFile(void) -{ - /* Test case for: - * int CF_WriteHistoryEntryToFile(osal_id_t fd, const CF_History_t *history) - */ - osal_id_t arg_fd = OS_ObjectIdFromInteger(1); - CF_History_t history; - - memset(&history, 0, sizeof(history)); - strcpy(history.fnames.src_filename, "sf"); - strcpy(history.fnames.dst_filename, "df"); - - /* Successful write - need to set up for 3 successful calls to OS_write() */ - UT_SetDeferredRetcode(UT_KEY(OS_write), 1, 44); - UT_SetDeferredRetcode(UT_KEY(OS_write), 1, strlen(history.fnames.src_filename) + 6); - UT_SetDeferredRetcode(UT_KEY(OS_write), 1, strlen(history.fnames.dst_filename) + 6); - UtAssert_INT32_EQ(CF_WriteHistoryEntryToFile(arg_fd, &history), 0); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - - /* Unsuccessful write */ - UT_CF_ResetEventCapture(); - UT_SetDeferredRetcode(UT_KEY(OS_write), 1, -1); - UtAssert_INT32_EQ(CF_WriteHistoryEntryToFile(arg_fd, &history), -1); - UT_CF_AssertEventID(CF_CMD_WHIST_WRITE_ERR_EID); -} - /******************************************************************************* ** ** CF_WriteQueueDataToFile tests diff --git a/unit-test/stubs/cf_cfdp_handlers.c b/unit-test/stubs/cf_cfdp_handlers.c index 519225ab..f41613a0 100644 --- a/unit-test/stubs/cf_cfdp_handlers.c +++ b/unit-test/stubs/cf_cfdp_handlers.c @@ -111,23 +111,6 @@ void UT_DefaultHandler_CF_CFDP_PlaybackDir(void *UserObj, UT_EntryKey_t FuncKey, } } -/*---------------------------------------------------------------- - * - * For compatibility with other tests, this has a mechanism to save its - * arguments to a test-provided context capture buffer. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_CFDP_ResetTransaction(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - CF_CFDP_ResetTransaction_context_t *ctxt = UT_CF_GetContextBuffer(FuncKey, CF_CFDP_ResetTransaction_context_t); - - if (ctxt) - { - ctxt->txn = UT_Hook_GetArgValueByName(Context, "txn", CF_Transaction_t *); - ctxt->keep_history = UT_Hook_GetArgValueByName(Context, "keep_history", bool); - } -} - /*---------------------------------------------------------------- * * For compatibility with other tests, this has a mechanism to save its diff --git a/unit-test/stubs/cf_clist_handlers.c b/unit-test/stubs/cf_clist_handlers.c index 9a55ab49..8ed1928b 100644 --- a/unit-test/stubs/cf_clist_handlers.c +++ b/unit-test/stubs/cf_clist_handlers.c @@ -72,23 +72,6 @@ void UT_DefaultHandler_CF_CList_InsertBack(void *UserObj, UT_EntryKey_t FuncKey, } } -/*---------------------------------------------------------------- - * - * For compatibility with other tests, this has a mechanism to save its - * arguments to a test-provided context capture buffer. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_CList_CF_CList_Pop(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - CF_CList_Pop_context_t *ctxt = UT_CF_GetContextBuffer(FuncKey, CF_CList_Pop_context_t); - - if (ctxt) - { - ctxt->head = UT_Hook_GetArgValueByName(Context, "head", CF_CListNode_t **); - UT_Stub_SetReturnValue(FuncKey, ctxt->forced_return); - } -} - /*---------------------------------------------------------------- * * For compatibility with other tests, this has a mechanism to save its diff --git a/unit-test/stubs/cf_cmd_handlers.c b/unit-test/stubs/cf_cmd_handlers.c deleted file mode 100644 index 819315b1..00000000 --- a/unit-test/stubs/cf_cmd_handlers.c +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************ - * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) - * Application version 3.0.0” - * - * Copyright (c) 2019 United States Government as represented by the - * Administrator of the National Aeronautics and Space Administration. - * All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ************************************************************************/ - -/** - * @file - * @brief The CF Application command handling stubs file - * - * All ground commands are processed in this file. All supporting functions - * necessary to process the commands are also here. - */ - -#include "cf_test_utils.h" -#include "cf_app.h" - -#include - -/* UT includes */ -#include "uttest.h" -#include "utstubs.h" - -/*---------------------------------------------------------------- - * - * For compatibility with other tests, this has a mechanism to save its - * arguments to a test-provided context capture buffer. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_ProcessGroundCommand(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - CFE_SB_Buffer_t **ctxt = UT_CF_GetContextBuffer(FuncKey, CFE_SB_Buffer_t *); - - if (ctxt) - { - *ctxt = UT_Hook_GetArgValueByName(Context, "BufPtr", CFE_SB_Buffer_t *); - } -} diff --git a/unit-test/stubs/cf_utils_handlers.c b/unit-test/stubs/cf_utils_handlers.c index 2d391a3f..eb65f59c 100644 --- a/unit-test/stubs/cf_utils_handlers.c +++ b/unit-test/stubs/cf_utils_handlers.c @@ -201,19 +201,3 @@ void UT_DefaultHandler_CF_WrappedOpenCreate(void *UserObj, UT_EntryKey_t FuncKey UT_Stub_SetReturnValue(FuncKey, ctxt->forced_return); } } - -/*---------------------------------------------------------------- - * - * Function: UT_DefaultHandler_CF_TxnStatus_IsError - * - * Translate the return value to a "bool" - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_TxnStatus_IsError(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - bool result; - - result = (bool)Context->Int32StatusCode; - - UT_Stub_SetReturnValue(FuncKey, result); -} diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index 4a767b73..c4828745 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -31,7 +31,6 @@ void UT_DefaultHandler_CF_FindUnusedTransaction(void *, UT_EntryKey_t, const UT_ void UT_DefaultHandler_CF_ResetHistory(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_TraverseAllTransactions(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels(void *, UT_EntryKey_t, const UT_StubContext_t *); -void UT_DefaultHandler_CF_TxnStatus_IsError(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WrappedOpenCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WriteHistoryQueueDataToFile(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WriteTxnQueueDataToFile(void *, UT_EntryKey_t, const UT_StubContext_t *); diff --git a/unit-test/utilities/cf_test_alt_handler.c b/unit-test/utilities/cf_test_alt_handler.c index 76385ab5..8d703e33 100644 --- a/unit-test/utilities/cf_test_alt_handler.c +++ b/unit-test/utilities/cf_test_alt_handler.c @@ -130,26 +130,6 @@ void UT_AltHandler_CF_CList_Traverse_R_PRIO(void *UserObj, UT_EntryKey_t FuncKey } } -/*---------------------------------------------------------------- - * - * A handler for CF_TraverseAllTransactions which _sets_ the opaque context - * pointer as an int* object. The value is taken from the UserObj opaque pointer. - * - *-----------------------------------------------------------------*/ -void UT_AltHandler_CF_TraverseAllTransactions_All_Channels_Set_Context(void *UserObj, - UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context) -{ - int *call_context = UT_Hook_GetArgValueByName(Context, "context", int *); - int *req_context = UserObj; - int forced_return; - - *call_context = *req_context; - forced_return = -1; - - UT_Stub_SetReturnValue(FuncKey, forced_return); -} - /*---------------------------------------------------------------- * * A simple handler that can be used for any stub that returns a pointer. diff --git a/unit-test/utilities/cf_test_alt_handler.h b/unit-test/utilities/cf_test_alt_handler.h index d6f4ff9d..d474e563 100644 --- a/unit-test/utilities/cf_test_alt_handler.h +++ b/unit-test/utilities/cf_test_alt_handler.h @@ -35,10 +35,6 @@ void UT_AltHandler_CF_CList_Traverse_POINTER(void *UserObj, UT_EntryKey_t FuncKe void UT_AltHandler_CF_CList_Traverse_R_PRIO(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); -void UT_AltHandler_CF_TraverseAllTransactions_All_Channels_Set_Context(void *UserObj, - UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context); - void UT_AltHandler_GenericPointerReturn(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); void UT_AltHandler_CaptureTransactionStatus(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); diff --git a/unit-test/utilities/cf_test_utils.c b/unit-test/utilities/cf_test_utils.c index 1ffe4d66..5a13dddb 100644 --- a/unit-test/utilities/cf_test_utils.c +++ b/unit-test/utilities/cf_test_utils.c @@ -138,28 +138,11 @@ void TestUtil_InitializeRandomSeed(void) * The 'Any' randomized values section ******************************************************************************/ -bool Any_bool(void) -{ - bool random_bool = false; - - if (AnyCoinFlip()) - { - random_bool = true; - } - - return random_bool; -} - unsigned int AnyCoinFlip(void) { return rand() % 2; } -char Any_char(void) -{ - return (char)Any_uint8(); -} - unsigned int Any_unsigned_int(void) { int random_val = rand(); @@ -167,87 +150,11 @@ unsigned int Any_unsigned_int(void) return random_val; } -/* - * AnyBufferOf_uint8_WithSize works, but name/design could use overhaul - * should it return a pointer? or should it be named different because it alters - * the buffer given? - */ -void AnyBufferOf_uint8_WithSize(uint8 *buffer, size_t size) -{ - int i; - - for (i = 0; i < size; ++i) - { - *(buffer + (sizeof(uint8) * i)) = Any_uint8(); - } -} - -uint8 Any_0_or_1(void) -{ - return Any_uint8_LessThan(2); -} - uint8 Any_uint8(void) { return (uint8)Any_unsigned_int(); } -uint8 Any_uint8_ExceptSetBits(uint8 bits) -{ - uint8 random_value = bits; - uint8 max_tries = 10; - uint8 num_tries = 0; - - while ((random_value & bits) == bits) - { - if (num_tries == max_tries) - { - UtPrintf("Any_uint8_ExceptSetBits unable to get valid number in %u checks\n", num_tries); - UtAssert_Abort("Any_uint8_ExceptSetBits failed to get valid number"); - } - else - { - ++num_tries; - } - - random_value = Any_uint8(); - } - - return random_value; -} - -uint8 Any_uint8_ExceptUnsetBits(uint8 bits) -{ - uint8 random_value = bits; - uint8 max_tries = 10; - uint8 num_tries = 0; - - while ((random_value | bits) == bits) - { - if (num_tries == max_tries) - { - UtPrintf("Any_uint8_ExceptUnsetBits unable to get valid number in %u checks\n", num_tries); - UtAssert_Abort("Any_uint8_ExceptUnsetBits failed to get valid number"); - } - else - { - ++num_tries; - } - - random_value = Any_uint8(); - } - - return random_value; -} - -uint8 Any_uint8_FromThese(uint8 values[], uint8 num_values) -{ - uint8 random_index = rand() % num_values; - uint8 random_value = values[random_index]; - - return random_value; -} - uint8 Any_uint8_BetweenExcludeMax(uint8 floor, uint8 ceiling) { uint8 random_val; @@ -312,13 +219,6 @@ uint16 Any_uint16(void) return (uint16)Any_unsigned_int(); } -uint16 Any_uint16_BetweenExcludeMax(uint16 floor, uint16 ceiling) -{ - uint16 difference = ceiling - floor; - - return (uint16)((rand() % difference) + floor); -} - uint16 Any_uint16_Except(uint16 exception) { uint32 random_val = exception; @@ -331,15 +231,6 @@ uint16 Any_uint16_Except(uint16 exception) return random_val; } -uint16 Any_uint16_GreaterThan(uint16 floor) -{ - uint16 random_val; - - random_val = 65535 - (rand() % (65536 - floor - 1)); /* -1 for non-inclusive */ - - return random_val; -} - uint16 Any_uint16_LessThan(uint16 ceiling) { return rand() % ceiling; @@ -350,26 +241,6 @@ uint32 Any_uint32(void) return Any_unsigned_int(); } -uint32 Any_uint32_BetweenInclusive(uint32 min, uint32 max) -{ - uint32 difference = max - min + 1; /* +1 for max inclusive */ - - return (uint32)((rand() % difference) + min); -} - -uint32 Any_uint32_BetweenExcludeMax(uint32 min, uint32 max) -{ - uint32 difference = max - min; - - /* check that rand % 0 does not happen */ - if (difference == 0) - { - UtAssert_Abort(__func__); - } - - return (uint32)((rand() % difference) + min); -} - uint32 Any_uint32_Except(uint32 exception) { uint32 random_val = exception; @@ -382,24 +253,6 @@ uint32 Any_uint32_Except(uint32 exception) return random_val; } -int32 Any_int32_LessThan(int32 ceiling) -{ - int32 random_val; - int32 new_ceiling; - - if (ceiling > 0) - { - random_val = (rand() % ceiling) - rand(); - } - else - { - new_ceiling = abs(INT32_MIN - ceiling); - random_val = ceiling - (rand() % new_ceiling); - } - - return random_val; -} - uint32 Any_uint32_GreaterThan(uint32 floor) { uint32 random_val; @@ -458,23 +311,6 @@ int Any_int_Positive(void) return (rand() % (UINT16_MAX)) + 1; /* 0 to RAND_MAX - 1, then +1 for 1 to RAND_MAX */ } -int Any_int_PositiveExcept(int exception) -{ - int rand_val = exception; - - while (rand_val == exception) - { - rand_val = rand(); - } - - return rand_val; -} - -int Any_int_ZeroOrPositiveLessThan(int ceiling) -{ - return rand() % ceiling; -} - int32 Any_int32(void) { return (int32)Any_int(); @@ -485,18 +321,6 @@ int32 Any_int32_Except(int32 exception) return (int32)Any_int_Except(exception); } -int32 Any_int32_Negative(void) -{ - return Any_int_Negative(); -} - -int32 Any_int32_ZeroOrPositive() -{ - int32 random_val = rand() % INT32_MAX; - - return random_val; -} - uint64 Any_uint64() { uint64 rand_val; @@ -524,26 +348,6 @@ uint64 Any_uint64_Except(uint64 exception) char random_length_string[500]; -char *AnyFilenameOfLength(size_t length) -{ - return AnyRandomStringOfLettersOfLength(length); -} - -char *AnyRandomStringOfTextOfLength(size_t length) -{ - size_t i; - int value; - - for (i = 0; i < length; ++i) - { - value = 32 + (rand() % 95); /* ASCII 32 to 126 */ - random_length_string[i] = (char)value; - } - random_length_string[i] = '\0'; - - return random_length_string; -} - char *AnyRandomStringOfLettersOfLength(size_t length) { size_t i; @@ -584,31 +388,6 @@ void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length) random_string[i] = '\0'; } -/* cfe specific */ -void Any_CFE_TIME_SysTime_Set(CFE_TIME_SysTime_t *fake_time) -{ - fake_time->Seconds = Any_uint32(); - fake_time->Subseconds = Any_uint32(); -} - -CFE_Status_t Any_CFE_Status_t_Negative() -{ - return Any_int32_Negative(); -} - -CFE_Status_t Any_CFE_Status_t_Except(CFE_Status_t exception) -{ - CFE_Status_t rand_val = exception; - - /* technically could continue forever, but it won't */ - while (rand_val == exception) - { - rand_val = Any_int32(); - } - - return rand_val; -} - /* cf specific */ uint8 Any_cf_chan_num(void) { diff --git a/unit-test/utilities/cf_test_utils.h b/unit-test/utilities/cf_test_utils.h index 5268f430..63f80f11 100644 --- a/unit-test/utilities/cf_test_utils.h +++ b/unit-test/utilities/cf_test_utils.h @@ -225,37 +225,23 @@ void TestUtil_InitializeRandomSeed(void); unsigned int AnyCoinFlip(void); -bool Any_bool(void); -void AnyBufferOf_uint8_WithSize(uint8 *buffer, size_t size); -char Any_char(void); -uint8 Any_0_or_1(void); uint8 Any_uint8(void); uint8 Any_uint8_BetweenExcludeMax(uint8 floor, uint8 ceiling); uint8 Any_uint8_BetweenInclusive(uint8 floor, uint8 ceiling); -uint8 Any_uint8_ExceptSetBits(uint8 mask); -uint8 Any_uint8_ExceptUnsetBits(uint8 mask); -uint8 Any_uint8_FromThese(uint8 values[], uint8 num_values); uint8 Any_uint8_LessThan(uint8 ceiling); uint8 Any_uint8_GreaterThan(uint8 floor); uint8 Any_uint8_GreaterThan_or_EqualTo(uint8 floor); uint8 Any_uint8_Except(uint8 exception); uint16 Any_uint16(void); -uint16 Any_uint16_BetweenExcludeMax(uint16 floor, uint16 ceiling); uint16 Any_uint16_Except(uint16 exception); -uint16 Any_uint16_GreaterThan(uint16 floor); uint16 Any_uint16_LessThan(uint16 ceiling); uint32 Any_uint32(void); -uint32 Any_uint32_BetweenInclusive(uint32 min, uint32 max); -uint32 Any_uint32_BetweenExcludeMax(uint32 min, uint32 max); uint32 Any_uint32_Except(uint32 exception); uint32 Any_uint32_GreaterThan(uint32 floor); uint32 Any_uint32_LessThan(uint32 ceiling); uint32 Any_uint32_LessThan_or_EqualTo(uint32 max); int32 Any_int32(void); int32 Any_int32_Except(int32 exception); -int32 Any_int32_LessThan(int32 ceiling); -int32 Any_int32_Negative(void); -int32 Any_int32_ZeroOrPositive(void); uint64 Any_uint64(void); uint64 Any_uint64_Except(uint64 exception); unsigned int Any_unsigned_int(void); @@ -263,17 +249,9 @@ int Any_int(void); int Any_int_Except(int exception); int Any_int_Negative(void); int Any_int_Positive(void); -int Any_int_PositiveExcept(int exception); -int Any_int_ZeroOrPositiveLessThan(int ceiling); -char *AnyFilenameOfLength(size_t length); -char *AnyRandomStringOfTextOfLength(size_t stringLength); char *AnyRandomStringOfLettersOfLength(size_t length); void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length); uint8 Any_cf_chan_num(void); -void Any_CFE_TIME_SysTime_Set(CFE_TIME_SysTime_t *fake_time); -CFE_Status_t Any_CFE_Status_t_Negative(void); -CFE_Status_t Any_CFE_Status_t_Except(CFE_Status_t exception); - #endif From d82f5433ad4e26cdb0f667984a8fb595d67eb72f Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 6 Aug 2026 07:57:47 -0400 Subject: [PATCH 06/18] Fix #90, standardize patterns across all internal functions Updates all code to follow the same pattern: - channel numbers are used only in CMD/TLM/Tables (external) - channel number is converted to a pointer, with error checking - only channel pointer is used therein This change removes all ambiguity about whether the passed-in value is range checked or not. Repeated conversions between channel number and channel pointer are removed, and code is much simpler as a result. Also fixes #288 --- config/default_cf_extern_typedefs.h | 16 +- config/default_cf_msgdefs.h | 221 +++- config/default_cf_msgstruct.h | 32 +- config/default_cf_tbldefs.h | 14 +- config/eds_cf_extern_typedefs.h | 15 +- config/eds_cf_msgdefs.h | 2 +- docs/dox_src/cfs_cf.dox | 104 +- eds/cf.xml | 131 ++- fsw/inc/cf_eventids.h | 22 - fsw/inc/cf_fcncodes.h | 25 +- fsw/src/cf_app.c | 221 ++-- fsw/src/cf_app.h | 183 ++- fsw/src/cf_cfdp.c | 608 +++++----- fsw/src/cf_cfdp.h | 27 +- fsw/src/cf_cfdp_dispatch.c | 8 +- fsw/src/cf_cfdp_r.c | 62 +- fsw/src/cf_cfdp_s.c | 62 +- fsw/src/cf_cfdp_sbintf.c | 68 +- fsw/src/cf_cfdp_sbintf.h | 4 +- fsw/src/cf_cfdp_types.h | 120 +- fsw/src/cf_cmd.c | 528 +++++---- fsw/src/cf_cmd.h | 26 +- fsw/src/cf_dispatch.c | 6 +- fsw/src/cf_eds_dispatch.c | 2 +- fsw/src/cf_timer.c | 3 +- fsw/src/cf_utils.c | 94 +- fsw/src/cf_utils.h | 84 +- fsw/tables/cf_def_config.c | 2 +- unit-test/cf_app_tests.c | 79 +- unit-test/cf_cfdp_dispatch_tests.c | 50 +- unit-test/cf_cfdp_r_tests.c | 89 +- unit-test/cf_cfdp_s_tests.c | 115 +- unit-test/cf_cfdp_sbintf_tests.c | 80 +- unit-test/cf_cfdp_tests.c | 314 +++--- unit-test/cf_cmd_tests.c | 1436 +++++++++++------------- unit-test/cf_dispatch_tests.c | 16 +- unit-test/cf_timer_tests.c | 18 +- unit-test/cf_utils_tests.c | 232 ++-- unit-test/stubs/cf_cfdp_handlers.c | 4 +- unit-test/stubs/cf_cfdp_s_stubs.c | 78 +- unit-test/stubs/cf_cfdp_sbintf_stubs.c | 4 +- unit-test/stubs/cf_cfdp_stubs.c | 28 +- unit-test/stubs/cf_cmd_stubs.c | 32 +- unit-test/stubs/cf_utils_handlers.c | 27 + unit-test/stubs/cf_utils_stubs.c | 28 +- unit-test/utilities/cf_test_utils.c | 4 +- unit-test/utilities/cf_test_utils.h | 10 +- 47 files changed, 3044 insertions(+), 2290 deletions(-) diff --git a/config/default_cf_extern_typedefs.h b/config/default_cf_extern_typedefs.h index ed441941..66100420 100644 --- a/config/default_cf_extern_typedefs.h +++ b/config/default_cf_extern_typedefs.h @@ -38,11 +38,19 @@ * * Defined per section 7.1 of CCSDS 727.0-B-5 */ -typedef enum +enum CF_CFDP_Class { - CF_CFDP_CLASS_1 = 0, /**< \brief CFDP class 1 - Unreliable transfer */ - CF_CFDP_CLASS_2 = 1, /**< \brief CFDP class 2 - Reliable transfer */ -} CF_CFDP_Class_t; + CF_CFDP_Class_1 = 0, /**< \brief CFDP class 1 - Unreliable transfer */ + CF_CFDP_Class_2 = 1, /**< \brief CFDP class 2 - Reliable transfer */ +}; + +/** + * @brief External type to use for CFDP class + * + * This uses the labels defined in enum CF_CFDP_Class + * but maps to a fixed-width type for use in CMD/TLM/Tables + */ +typedef uint8 CF_CFDP_Class_Enum_t; /** * @brief CF queue identifiers diff --git a/config/default_cf_msgdefs.h b/config/default_cf_msgdefs.h index 285aedf2..fcd5be2c 100644 --- a/config/default_cf_msgdefs.h +++ b/config/default_cf_msgdefs.h @@ -28,6 +28,66 @@ #include "common_types.h" #include "cf_extern_typedefs.h" +/** + * \defgroup cfscfmsgtypes Typedefs used in CFS CFDP Commands and Telemetry + * \{ + */ + +/** + * \brief Type IDs for use for Write Queue cmd + */ +typedef enum CF_Type +{ + CF_Type_all = 0, /**< \brief Type all */ + CF_Type_up = 1, /**< \brief Type up */ + CF_Type_down = 2 /**< \brief Type down */ +} CF_Type_t; + +/** + * @brief External type to use for CFDP queue type + * + * This uses the labels defined in enum CF_Type + * but maps to a fixed-width type for use in CMD/TLM/Tables + */ +typedef uint8 CF_Type_Enum_t; + +/** + * @brief Standardized type used for channel selection in commands + * + * 255 = all channels (if applicable; not all commands allow all channels) + * 0-X = single channel number + */ +typedef uint8 CF_ChannelSelect_t; + +/** + * Standardized type used for polling directory selection in commands + * + * 255 = all polling directory indices (if applicable) + * 0-X = single polling directory index number + */ +typedef uint8 CF_PollIdxSelect_t; + +/** + * \brief Enum labels for use for queue selection + */ +enum CF_QueueSelect +{ + CF_QueueSelect_Pending = 0, /**< \brief Pending Queue */ + CF_QueueSelect_Active = 1, /**< \brief Active Queue */ + CF_QueueSelect_History = 2, /**< \brief History Queue */ + CF_QueueSelect_All = 3, /**< \brief All queues */ +}; + +/** + * @brief External type to use for CFDP queue select + * + * This uses the labels defined in enum CF_QueueSelect + * but maps to a fixed-width type for use in CMD/TLM/Tables + */ +typedef uint8 CF_QueueSelect_Enum_t; + +/** \} */ + /** * \defgroup cfscftlm CFS CFDP Telemetry * \{ @@ -146,47 +206,86 @@ typedef struct CF_EotPacket_Payload */ /** - * \brief Command payload argument union to support 4 uint8's, 2 uint16's or 1 uint32 + * \brief Enum labels for use for Reset cmd */ -typedef union CF_UnionArgs_Payload -{ - uint32 dword; /**< \brief Generic uint32 argument */ - uint16 hword[2]; /**< \brief Generic uint16 array of arguments */ - uint8 byte[4]; /**< \brief Generic uint8 array of arguments */ -} CF_UnionArgs_Payload_t; - -/** - * \brief IDs for use for Reset cmd - */ -typedef enum +enum CF_Reset { CF_Reset_all = 0, /**< \brief Reset all */ CF_Reset_command = 1, /**< \brief Reset command */ CF_Reset_fault = 2, /**< \brief Reset fault */ CF_Reset_up = 3, /**< \brief Reset up */ CF_Reset_down = 4 /**< \brief Reset down */ -} CF_Reset_t; +}; /** - * \brief Type IDs for use for Write Queue cmd + * @brief External type to use for Reset command + * + * This uses the labels defined in enum CF_Reset + * but maps to a fixed-width type for use in CMD/TLM/Tables + */ +typedef uint8 CF_Reset_Enum_t; + +/** + * \brief Reset command payload + * + * For command details see #CF_RESET_CC */ -typedef enum +typedef struct CF_ResetCountersCmd_Payload { - CF_Type_all = 0, /**< \brief Type all */ - CF_Type_up = 1, /**< \brief Type up */ - CF_Type_down = 2 /**< \brief Type down */ -} CF_Type_t; + CF_Reset_Enum_t ResetType; +} CF_ResetCountersCmd_Payload_t; + +/** + * \brief Single byte channel selector payload + * + * Used in all commands needing only a channel selection + * - 255 = all channels + * - else = single channel + */ +typedef struct CF_ChannelSelect_Payload +{ + CF_ChannelSelect_t ChannelSelect; +} CF_ChannelSelect_Payload_t; + +/** + * \brief Polling directory selector payload + * + * Used in all commands needing a polldir selection + * + * Single byte channel selector + * - 255 = all channels + * - else = single channel + * + * Single byte polling directory index + * - 255 = all polling directories + * - else = single polling directory index + */ +typedef struct CF_PollDirSelect_Payload +{ + CF_ChannelSelect_t ChannelSelect; + CF_PollIdxSelect_t PollDirIndx; +} CF_PollDirSelect_Payload_t; /** - * \brief Queue IDs for use for Write Queue cmd + * \brief Queue selector payload + * + * Used in all commands needing a queue selection + * + * Single byte channel selector + * - 255 = all channels + * - else = single channel + * + * Single byte queue selection enum + * Values indicated by #CF_QueueSelect enum + * - 0 = Pending queue + * - 1 = History queue + * - 2 = Both pending and history queue */ -typedef enum +typedef struct CF_QueueSelect_Payload { - CF_Queue_pend = 0, /**< \brief Queue pending */ - CF_Queue_active = 1, /**< \brief Queue active */ - CF_Queue_history = 2, /**< \brief Queue history */ - CF_Queue_all = 3 /**< \brief Queue all */ -} CF_Queue_t; + CF_ChannelSelect_t ChannelSelect; + CF_QueueSelect_Enum_t QueueSelect; +} CF_QueueSelect_Payload_t; /** * \brief Parameter IDs for use with Get/Set parameter messages @@ -194,7 +293,7 @@ typedef enum * Specifically these are used for the "key" field within CF_GetParamCmd_t and * CF_SetParamCmd_t message structures. */ -typedef enum +enum CF_GetSet_ValueID { CF_GetSet_ValueID_ticks_per_second, /**< \brief Ticks per second key */ CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup, /**< \brief Receive CRC calculated bytes per wake-up key */ @@ -207,7 +306,15 @@ typedef enum CF_GetSet_ValueID_local_eid, /**< \brief Local entity id key */ CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup, /**< \brief Max outgoing messages per wake-up key */ CF_GetSet_ValueID_MAX /**< \brief Key limit used for validity check */ -} CF_GetSet_ValueID_t; +}; + +/** + * @brief External type to use for CF_GetSet_ValueID + * + * This uses the labels defined in enum CF_GetSet_ValueID + * but maps to a fixed-width type for use in CMD/TLM/Tables + */ +typedef uint8 CF_GetSet_ValueID_Enum_t; /** * \brief Get parameter command structure @@ -216,8 +323,8 @@ typedef enum */ typedef struct CF_GetParam_Payload { - uint8 key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ - uint8 chan_num; /**< \brief Channel number */ + CF_GetSet_ValueID_Enum_t key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number */ } CF_GetParam_Payload_t; /** @@ -227,10 +334,10 @@ typedef struct CF_GetParam_Payload */ typedef struct CF_SetParam_Payload { - uint32 value; /**< \brief Parameter value to set */ - uint8 key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ - uint8 chan_num; /**< \brief Channel number */ - uint8 spare[2]; /**< \brief Alignment spare, uint32 multiple */ + uint32 value; /**< \brief Parameter value to set */ + CF_GetSet_ValueID_Enum_t key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number */ + uint8 spare[2]; /**< \brief Alignment spare, uint32 multiple */ } CF_SetParam_Payload_t; /** @@ -240,13 +347,13 @@ typedef struct CF_SetParam_Payload */ typedef struct CF_TxFile_Payload { - uint8 cfdp_class; /**< \brief CFDP class: 0=class 1, 1=class 2 */ - uint8 keep; /**< \brief Keep file flag: 1=keep, else delete */ - uint8 chan_num; /**< \brief Channel number */ - uint8 priority; /**< \brief Priority: 0=highest priority */ - CF_EntityId_t dest_id; /**< \brief Destination entity id */ - char src_filename[CF_FILENAME_MAX_LEN]; /**< \brief Source file/directory name */ - char dst_filename[CF_FILENAME_MAX_LEN]; /**< \brief Destination file/directory name */ + CF_CFDP_Class_Enum_t cfdp_class; /**< \brief CFDP class: 0=class 1, 1=class 2 */ + uint8 keep; /**< \brief Keep file flag: 1=keep, else delete */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number */ + uint8 priority; /**< \brief Priority: 0=highest priority */ + CF_EntityId_t dest_id; /**< \brief Destination entity id */ + char src_filename[CF_FILENAME_MAX_LEN]; /**< \brief Source file/directory name */ + char dst_filename[CF_FILENAME_MAX_LEN]; /**< \brief Destination file/directory name */ } CF_TxFile_Payload_t; /** @@ -256,10 +363,10 @@ typedef struct CF_TxFile_Payload */ typedef struct CF_WriteQueue_Payload { - uint8 type; /**< \brief Transaction direction: all=0, up=1, down=2 */ - uint8 chan; /**< \brief Channel number */ - uint8 queue; /**< \brief Queue type: 0=pending, 1=active, 2=history, 3=all */ - uint8 spare; /**< \brief Alignment spare, puts filename on 32-bit boundary */ + CF_Type_Enum_t type; /**< \brief Transaction direction: all=0, up=1, down=2 */ + CF_ChannelSelect_t chan; /**< \brief Channel number */ + CF_QueueSelect_Enum_t queue; /**< \brief Queue type: 0=pending, 1=active, 2=history, 3=all */ + uint8 spare; /**< \brief Alignment spare, puts filename on 32-bit boundary */ char filename[CF_FILENAME_MAX_LEN]; /**< \brief Filename written to */ } CF_WriteQueue_Payload_t; @@ -273,10 +380,32 @@ typedef struct CF_Transaction_Payload { CF_TransactionSeq_t ts; /**< \brief Transaction sequence number */ CF_EntityId_t eid; /**< \brief Entity id */ - uint8 chan; /**< \brief Channel number: 254=use ts, 255=all channels, else channel */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number: 254=use ts, 255=all channels, else channel */ uint8 spare[3]; /**< \brief Alignment spare for 32-bit multiple */ } CF_Transaction_Payload_t; /**\}*/ +/** + * @brief Internal type (enum) for the CFDP class. + * + * This typedef should only be used internally but the same labels/values + * apply externally as well. Notably this is a native-width type, and for + * external cmd/tlm use it needs to be a fixed-width type. + * + * @sa #CF_CFDP_Class_Enum_t + */ +typedef enum CF_CFDP_Class CF_CFDP_Class_t; + +/** + * @brief Internal type (enum) for the CFDP value identifier. + * + * This typedef should only be used internally but the same labels/values + * apply externally as well. Notably this is a native-width type, and for + * external cmd/tlm use it needs to be a fixed-width type. + * + * @sa #CF_GetSet_ValueID_Enum_t + */ +typedef enum CF_GetSet_ValueID CF_GetSet_ValueID_t; + #endif diff --git a/config/default_cf_msgstruct.h b/config/default_cf_msgstruct.h index 29eec046..dd60de22 100644 --- a/config/default_cf_msgstruct.h +++ b/config/default_cf_msgstruct.h @@ -103,8 +103,8 @@ typedef struct CF_DisableEngineCmd */ typedef struct CF_ResetCountersCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_ResetCountersCmd_Payload_t Payload; /**< \brief Command arguments */ } CF_ResetCountersCmd_t; /** @@ -114,8 +114,8 @@ typedef struct CF_ResetCountersCmd */ typedef struct CF_FreezeCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_FreezeCmd_t; /** @@ -125,8 +125,8 @@ typedef struct CF_FreezeCmd */ typedef struct CF_ThawCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_ThawCmd_t; /** @@ -136,8 +136,8 @@ typedef struct CF_ThawCmd */ typedef struct CF_EnableDequeueCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_EnableDequeueCmd_t; /** @@ -147,8 +147,8 @@ typedef struct CF_EnableDequeueCmd */ typedef struct CF_DisableDequeueCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_DisableDequeueCmd_t; /** @@ -158,8 +158,8 @@ typedef struct CF_DisableDequeueCmd */ typedef struct CF_EnableDirPollingCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_PollDirSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_EnableDirPollingCmd_t; /** @@ -169,8 +169,8 @@ typedef struct CF_EnableDirPollingCmd */ typedef struct CF_DisableDirPollingCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_PollDirSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_DisableDirPollingCmd_t; /** @@ -180,8 +180,8 @@ typedef struct CF_DisableDirPollingCmd */ typedef struct CF_PurgeQueueCmd { - CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ - CF_UnionArgs_Payload_t Payload; /**< \brief Generic command arguments */ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_QueueSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_PurgeQueueCmd_t; /** diff --git a/config/default_cf_tbldefs.h b/config/default_cf_tbldefs.h index 03da6e33..73f0801d 100644 --- a/config/default_cf_tbldefs.h +++ b/config/default_cf_tbldefs.h @@ -41,9 +41,9 @@ typedef struct CF_PollDir { uint32 interval_sec; /**< \brief number of seconds to wait before trying a new directory */ - uint8 priority; /**< \brief priority to use when placing transactions on the pending queue */ - CF_CFDP_Class_t cfdp_class; /**< \brief the CFDP class to send */ - CF_EntityId_t dest_eid; /**< \brief destination entity id */ + uint8 priority; /**< \brief priority to use when placing transactions on the pending queue */ + CF_CFDP_Class_Enum_t cfdp_class; /**< \brief the CFDP class to send */ + CF_EntityId_t dest_eid; /**< \brief destination entity id */ char src_dir[CF_FILENAME_MAX_PATH]; /**< \brief path to source dir */ char dst_dir[CF_FILENAME_MAX_PATH]; /**< \brief path to destination dir */ @@ -83,7 +83,15 @@ typedef struct CF_ChannelConfig * For backward compatibility with existing CF table definitions, include the other part here. */ #ifndef CF_OMIT_DEPRECATED + #include "cf_tblstruct.h" + +/* + * Preserve compatibility with table definitions that specify the class using these terms + */ +#define CF_CFDP_CLASS_1 CF_CFDP_Class_1 +#define CF_CFDP_CLASS_2 CF_CFDP_Class_2 + #endif #endif diff --git a/config/eds_cf_extern_typedefs.h b/config/eds_cf_extern_typedefs.h index f1d514d2..374bb160 100644 --- a/config/eds_cf_extern_typedefs.h +++ b/config/eds_cf_extern_typedefs.h @@ -33,18 +33,21 @@ #include "cf_eds_typedefs.h" /* Define type mappings for CF-specific types */ -typedef CF_QueueIdx_Enum_t CF_QueueIdx_t; #define CF_QueueIdx_NUM (1 + EdsDataType_EdsEnum_CF_QueueIdx_t_MAX) #define CF_GetSet_ValueID_MAX (1 + EdsDataType_EdsEnum_CF_GetSet_ValueID_t_MAX) -typedef CF_EntityId_Atom_t CF_EntityId_t; -typedef CF_TransactionSeq_Atom_t CF_TransactionSeq_t; +typedef EdsDataType_CF_EntityId_t CF_EntityId_t; +typedef EdsDataType_CF_TransactionSeq_t CF_TransactionSeq_t; -typedef CF_CFDP_Enum_t CF_CFDP_Class_t; -typedef CF_GetSet_ValueID_Enum_t CF_GetSet_ValueID_t; +typedef enum EdsEnum_CF_QueueIdx CF_QueueIdx_t; +typedef enum EdsEnum_CF_CFDP_Class CF_CFDP_Class_t; +typedef enum EdsEnum_CF_GetSet_ValueID CF_GetSet_ValueID_t; + +typedef EdsDataType_CF_PollIdxSelect_t CF_PollIdxSelect_t; +typedef EdsDataType_CF_ChannelSelect_t CF_ChannelSelect_t; typedef EdsDataType_BASE_TYPES_PathName_t CF_PathName_t; typedef EdsDataType_BASE_TYPES_FileName_t CF_FileName_t; -#endif \ No newline at end of file +#endif diff --git a/config/eds_cf_msgdefs.h b/config/eds_cf_msgdefs.h index 53a76786..76744c3d 100644 --- a/config/eds_cf_msgdefs.h +++ b/config/eds_cf_msgdefs.h @@ -28,4 +28,4 @@ #include "cf_eds_typedefs.h" #include "cf_fcncodes.h" -#endif \ No newline at end of file +#endif diff --git a/docs/dox_src/cfs_cf.dox b/docs/dox_src/cfs_cf.dox index 3778eb44..fb378ee1 100644 --- a/docs/dox_src/cfs_cf.dox +++ b/docs/dox_src/cfs_cf.dox @@ -398,23 +398,23 @@ When files are found in a polling directory that is enabled, the files are automatically queued by CF for output. The polling rate is configurable and each channel has a configurable number of polling directories. Each polling - directory has an enable, a class setting, a priority setting, a destination - directory. When enabled, CF will periodically check the polling directories - for files. When a file is found, CF will place the file information on the - pending queue if it is closed and not already on the queue and not currently - active. All polling directories are checked at the same frequency which is - defined by the table parameter NumWakeupsPerPollDirChk. Setting this parameter - to one will cause CF to check the polling directories at the fastest possible - rate, every time it receives a 'wake-up' command. Checking polling directories - is a processor-intensive effort, it is best to keep the polling rate as low as + directory has an enable, a class setting, a priority setting, a destination + directory. When enabled, CF will periodically check the polling directories + for files. When a file is found, CF will place the file information on the + pending queue if it is closed and not already on the queue and not currently + active. All polling directories are checked at the same frequency which is + defined by the table parameter NumWakeupsPerPollDirChk. Setting this parameter + to one will cause CF to check the polling directories at the fastest possible + rate, every time it receives a 'wake-up' command. Checking polling directories + is a processor-intensive effort, it is best to keep the polling rate as low as possible.

Failed Transmit and directory use

- - Currently, the fail directory is used only to store class 2 TX files that failed - during transmission from a polling directory. When a file fails during transmission - from a polling directory, it is deleted from the polling directory to prevent an - infinite loop and moved to the fail directory. However, if a file fails during a + + Currently, the fail directory is used only to store class 2 TX files that failed + during transmission from a polling directory. When a file fails during transmission + from a polling directory, it is deleted from the polling directory to prevent an + infinite loop and moved to the fail directory. However, if a file fails during a class 2 TX outside of a polling directory, the file will not be deleted.

Efficiency

@@ -612,19 +612,11 @@ \verbatim * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the counters type, byte[1-3] don't care: * - 0 = all counters * - 1 = command counters * - 2 = fault counters * - 3 = up counters * - 4 = down counters - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } -CF_UnionArgs_Payload_t; \endverbatim The command parameter byte[0] identifies which category of counters to @@ -653,8 +645,8 @@ CF_UnionArgs_Payload_t; and an event will be generated. If the command is not successful, the command error counter will increment and - an error event will be generated indicating the reason for failure. File will - not be deleted if the 'transmit' failed (unless in an polling directories). + an error event will be generated indicating the reason for failure. File will + not be deleted if the 'transmit' failed (unless in an polling directories). \verbatim typedef struct CF_TxFileCmd @@ -671,7 +663,7 @@ CF_UnionArgs_Payload_t; \endverbatim The first parameter, \c cfdp_class, identifies whether the file will be transferred - using #CF_CFDP_CLASS_1 or #CF_CFDP_CLASS_2. For Class 1 transfers, CF will send the data + using #CF_CFDP_Class_1 or #CF_CFDP_Class_2. For Class 1 transfers, CF will send the data once and expect no feedback from the peer. Class 2 transfers are more reliable and attempt to fill in data that may have been dropped on the first attempt. @@ -741,7 +733,7 @@ CF_UnionArgs_Payload_t; \endverbatim The first parameter, \c cfdp_class, identifies whether the files will be - transferred using #CF_CFDP_CLASS_1 or #CF_CFDP_CLASS_2. For Class 1 transfers, CF will + transferred using #CF_CFDP_Class_1 or #CF_CFDP_Class_2. For Class 1 transfers, CF will send the data once and expect no feedback from the peer. Class 2 transfers are more reliable and attempt to fill in data that may have been dropped on the first attempt. @@ -1109,15 +1101,9 @@ CF_UnionArgs_Payload_t; \verbatim * Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels - * - 255 = all channels + * Single byte channel selector + * - 255 (0xFF) = all channels * - else = single channel - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } CF_UnionArgs_Payload_t; \endverbatim The first and only parameter, \c byte[0], specifies which pending queue to enable. @@ -1147,16 +1133,9 @@ CF_UnionArgs_Payload_t; \verbatim * Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel - - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } CF_UnionArgs_Payload_t; \endverbatim The first and only parameter, \c byte[0], specifies which pending queue to enable. @@ -1185,23 +1164,14 @@ CF_UnionArgs_Payload_t; \verbatim * Command Structure - * #CF_UnionArgs_Payload_t - * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the polling directory index + * Single byte polling directory index * - 255 = all polling directories * - else = single polling directory index * - - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } CF_UnionArgs_Payload_t; \endverbatim The first parameter, \c byte[0], specifies which channel contains the polling @@ -1237,23 +1207,13 @@ CF_UnionArgs_Payload_t; \verbatim * Command Structure - * #CF_UnionArgs_Payload_t - * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the polling directory index + * Single byte polling directory index * - 255 = all polling directories * - else = single polling directory index - * - - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } CF_UnionArgs_Payload_t; \endverbatim The first parameter, \c byte[0], specifies which channel contains the polling @@ -1285,24 +1245,14 @@ CF_UnionArgs_Payload_t; \verbatim * Command Structure - * #CF_UnionArgs_Payload_t - * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the queue + * Single byte queue index * - 0 = Pending queue * - 1 = History queue * - 2 = Both pending and history queue - * - - typedef union CF_UnionArgs_Payload - { - uint32 dword; - uint16 hword[2]; - uint8 byte[4]; - } CF_UnionArgs_Payload_t; \endverbatim The first parameter, \c byte[0], specifies a single channel id or a value diff --git a/eds/cf.xml b/eds/cf.xml index 21edcbc8..20199da3 100644 --- a/eds/cf.xml +++ b/eds/cf.xml @@ -72,15 +72,35 @@ - + + + + + + + + + + + + + + - + - - + + + + + + + + + + + + @@ -121,7 +141,7 @@ - + @@ -184,7 +204,7 @@ - + @@ -236,7 +256,7 @@ - + @@ -275,7 +295,7 @@ - + @@ -315,30 +335,65 @@ - + + + + + - - - - - + + + Single byte channel selector payload + - 255 = all channels + - else = single channel + + + + + - - - - - + + + Polling directory selector payload - + Single byte channel selector + - 255 = all channels + - else = single channel + + Single byte polling directory index + - 255 = all polling directories + - else = single polling directory index + + + + + + + + + + Queue selector payload + + Single byte channel selector + - 255 = all channels + - else = single channel + + Single byte queue selection enum + Values indicated by #CF_QueueSelect enum + - 0 = Pending queue + - 1 = History queue + - 2 = Both pending and history queue + - + + - + @@ -346,16 +401,16 @@ - + - + - + @@ -386,7 +441,7 @@ - + @@ -397,7 +452,7 @@ - + @@ -474,7 +529,7 @@ - + @@ -593,7 +648,7 @@ - + @@ -634,7 +689,7 @@ - + @@ -962,7 +1017,7 @@ - + @@ -1002,7 +1057,7 @@ - + @@ -1049,7 +1104,7 @@ - + @@ -1096,7 +1151,7 @@ - + @@ -1144,7 +1199,7 @@ - + diff --git a/fsw/inc/cf_eventids.h b/fsw/inc/cf_eventids.h index 894e6e15..c37fbe9f 100644 --- a/fsw/inc/cf_eventids.h +++ b/fsw/inc/cf_eventids.h @@ -57,28 +57,6 @@ */ #define CF_INIT_TBL_CHECK_REL_ERR_EID 21 -/** - * \brief CF Check Table Manage Failed Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * Failure from manage table call during periodic table check - */ -#define CF_INIT_TBL_CHECK_MAN_ERR_EID 22 - -/** - * \brief CF Check Table Get Address Failed Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * Failure from get table call during periodic table check - */ -#define CF_INIT_TBL_CHECK_GA_ERR_EID 23 - /** * \brief CF Table Registration At Initialization Failed Event ID * diff --git a/fsw/inc/cf_fcncodes.h b/fsw/inc/cf_fcncodes.h index 7fa1b1aa..3aa298b5 100644 --- a/fsw/inc/cf_fcncodes.h +++ b/fsw/inc/cf_fcncodes.h @@ -74,7 +74,7 @@ * Resets the requested housekeeping counters * * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the counters type, byte[1-3] don't care: + * Single byte enumeration * - 0 = all counters * - 1 = command counters * - 2 = fault counters @@ -172,7 +172,7 @@ * this could cause failures for class 2 transactions in progress. * * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * @@ -206,7 +206,7 @@ * for the specified channel, note received messages are consumed either way. * * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * @@ -478,7 +478,7 @@ * Enables the sending of file data PDUs. * * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * @@ -511,7 +511,7 @@ * Disables the sending of file data PDUs. * * \par Command Structure - * #CF_UnionArgs_Payload_t where byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * @@ -544,13 +544,12 @@ * Enables the processing of polling directories * * \par Command Structure - * #CF_UnionArgs_Payload_t * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the polling directory index + * Single byte polling directory index * - 255 = all polling directories * - else = single polling directory index * @@ -584,13 +583,12 @@ * Disable the processing of polling directories * * \par Command Structure - * #CF_UnionArgs_Payload_t * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the polling directory index + * Single byte polling directory index * - 255 = all polling directories * - else = single polling directory index * @@ -624,13 +622,12 @@ * Purge the requested queue * * \par Command Structure - * #CF_UnionArgs_Payload_t * - * byte[0] specifies the channel number or all channels + * Single byte channel selector * - 255 = all channels * - else = single channel * - * byte[1] specifies the queue + * Single byte queue selection enum * - 0 = Pending queue * - 1 = History queue * - 2 = Both pending and history queue diff --git a/fsw/src/cf_app.c b/fsw/src/cf_app.c index 96db059a..d7468faf 100644 --- a/fsw/src/cf_app.c +++ b/fsw/src/cf_app.c @@ -33,6 +33,7 @@ #include "cf_cfdp.h" #include "cf_version.h" #include "cf_dispatch.h" +#include "cf_utils.h" #include "cf_tbl.h" #include @@ -41,60 +42,167 @@ CF_AppData_t CF_AppData; /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_app.h for argument/return detail + * Local helper function + * Imports configuration from table for a single channel + * Compatible with CF_ForEachChannel() * *-----------------------------------------------------------------*/ -void CF_CheckTables(void) +static int32 CF_DoChannelConfig(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { - CFE_Status_t status; + const CF_ConfigTable_t *config = arg; + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); + const CF_ChannelConfig_t *chan_config = &config->chan[chan_num]; + const CF_PollDir_t *tbl_pd_config; + CF_LocalPdConfig_t *pd_config; + int pd; + + chan->config.max_outgoing_messages_per_wakeup = chan_config->max_outgoing_messages_per_wakeup; + chan->config.rx_max_messages_per_wakeup = chan_config->rx_max_messages_per_wakeup; + chan->config.ack_timer_s = chan_config->ack_timer_s; + chan->config.nak_timer_s = chan_config->nak_timer_s; + chan->config.inactivity_timer_s = chan_config->inactivity_timer_s; + chan->config.ack_limit = chan_config->ack_limit; + chan->config.nak_limit = chan_config->nak_limit; + chan->config.mid_input = chan_config->mid_input; + chan->config.mid_output = chan_config->mid_output; + chan->config.pipe_depth_input = chan_config->pipe_depth_input; + chan->config.dequeue_enabled = chan_config->dequeue_enabled; + + CFE_SB_MessageStringGet(chan->config.sem_name, + chan_config->sem_name, + "", + sizeof(chan->config.sem_name), + sizeof(chan_config->sem_name)); + CFE_SB_MessageStringGet(chan->config.move_dir, + chan_config->move_dir, + "", + sizeof(chan->config.move_dir), + sizeof(chan_config->move_dir)); + + for (pd = 0; pd < CF_MAX_POLLING_DIR_PER_CHAN; ++pd) + { + tbl_pd_config = &chan_config->polldir[pd]; + pd_config = &chan->config.polldir[pd]; + + pd_config->enabled = tbl_pd_config->enabled; + pd_config->priority = tbl_pd_config->priority; + pd_config->interval_sec = tbl_pd_config->interval_sec; + pd_config->cfdp_class = tbl_pd_config->cfdp_class; + pd_config->dest_eid = tbl_pd_config->dest_eid; + + CFE_SB_MessageStringGet(pd_config->src_dir, + tbl_pd_config->src_dir, + "", + sizeof(pd_config->src_dir), + sizeof(tbl_pd_config->src_dir)); + CFE_SB_MessageStringGet(pd_config->dst_dir, + tbl_pd_config->dst_dir, + "", + sizeof(pd_config->dst_dir), + sizeof(tbl_pd_config->dst_dir)); + } - /* check the table for an update only if engine is disabled */ - if (!CF_AppData.engine.enabled) + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Checks for table updates + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ManageTables(CF_Engine_t *engine_ptr, bool always_import) +{ + CFE_Status_t status; + void *table_addr; + const CF_ConfigTable_t *config; + + /* + * NOTE: As of CFE 7.0 (Caelum), some the CFE TBL APIs return success codes + * other than CFE_SUCCESS, so it is not sufficient to check for only this + * result here. For example they may return something like CFE_TBL_INFO_UPDATED. + * But from the standpoint of this routine, they are all success, because the + * function still did its expected job. + * + * For now, the safest way to check is to check for negative values, + * as the alt-success codes are in the positive range by design, and + * error codes are all in the negative range of CFE_Status_t. + * + * This should continue to work even if CFE TBL APIs change to + * remove the problematic alt-success codes at some point. + */ + status = CFE_TBL_Manage(CF_AppData.config_handle); + if (status < CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_INIT_TBL_MANAGE_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: error in CFE_TBL_Manage, returned 0x%08lx", + (unsigned long)status); + } + else if (always_import || status == CFE_TBL_INFO_UPDATED) { - /* - * NOTE: As of CFE 7.0 (Caelum), some the CFE TBL APIs return success codes - * other than CFE_SUCCESS, so it is not sufficient to check for only this - * result here. For example they may return something like CFE_TBL_INFO_UPDATED. - * But from the standpoint of this routine, they are all success, because the - * function still did its expected job. - * - * For now, the safest way to check is to check for negative values, - * as the alt-success codes are in the positive range by design, and - * error codes are all in the negative range of CFE_Status_t. - * - * This should continue to work even if CFE TBL APIs change to - * remove the problematic alt-success codes at some point. - */ - status = CFE_TBL_ReleaseAddress(CF_AppData.config_handle); + status = CFE_TBL_GetAddress(&table_addr, CF_AppData.config_handle); if (status < CFE_SUCCESS) { - CFE_EVS_SendEvent(CF_INIT_TBL_CHECK_REL_ERR_EID, + CFE_EVS_SendEvent(CF_INIT_TBL_GETADDR_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: error in CFE_TBL_ReleaseAddress (check), returned 0x%08lx", + "CF: failed to get table address, returned 0x%08lx", (unsigned long)status); - CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; } - - status = CFE_TBL_Manage(CF_AppData.config_handle); - if (status < CFE_SUCCESS) + else { - CFE_EVS_SendEvent(CF_INIT_TBL_CHECK_MAN_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: error in CFE_TBL_Manage (check), returned 0x%08lx", - (unsigned long)status); - CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; + config = table_addr; + + engine_ptr->config.ticks_per_second = config->ticks_per_second; + engine_ptr->config.rx_crc_calc_bytes_per_wakeup = config->rx_crc_calc_bytes_per_wakeup; + engine_ptr->config.local_eid = config->local_eid; + engine_ptr->config.outgoing_file_chunk_size = config->outgoing_file_chunk_size; + + CFE_SB_MessageStringGet(engine_ptr->config.tmp_dir, + config->tmp_dir, + "", + sizeof(engine_ptr->config.tmp_dir), + sizeof(config->tmp_dir)); + CFE_SB_MessageStringGet(engine_ptr->config.fail_dir, + config->fail_dir, + "", + sizeof(engine_ptr->config.fail_dir), + sizeof(config->fail_dir)); + + CF_ForEachChannel(engine_ptr, CF_DoChannelConfig, table_addr); + + /* Release the address, the config is now in the CF global data */ + status = CFE_TBL_ReleaseAddress(CF_AppData.config_handle); + if (status < CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_INIT_TBL_CHECK_REL_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: error in CFE_TBL_ReleaseAddress, returned 0x%08lx", + (unsigned long)status); + } } + } - status = CFE_TBL_GetAddress((void *)&CF_AppData.config_table, CF_AppData.config_handle); - if (status < CFE_SUCCESS) - { - CFE_EVS_SendEvent(CF_INIT_TBL_CHECK_GA_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: failed to get table address (check), returned 0x%08lx", - (unsigned long)status); - CF_AppData.RunStatus = CFE_ES_RunStatus_APP_ERROR; - } + return status; +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_app.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_CheckTables(void) +{ + CF_Engine_t *engine_ptr = CF_GetEngine(); + + /* check the table for an update only if engine is disabled */ + if (!engine_ptr->enabled) + { + /* NOTE: We do not need to abort the app if this fails, it can + * keep running with the existing config in RAM. A failure here only + * means that the config is not applied */ + CF_ManageTables(engine_ptr, false); } } @@ -165,34 +273,9 @@ CFE_Status_t CF_TableInit(void) "CF: error loading table, returned 0x%08lx", (unsigned long)status); } - } - - if (status == CFE_SUCCESS) - { - status = CFE_TBL_Manage(CF_AppData.config_handle); - if (status != CFE_SUCCESS) - { - CFE_EVS_SendEvent(CF_INIT_TBL_MANAGE_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: error in CFE_TBL_Manage, returned 0x%08lx", - (unsigned long)status); - } - } - - if (status == CFE_SUCCESS) - { - status = CFE_TBL_GetAddress((void **)&CF_AppData.config_table, CF_AppData.config_handle); - /* status will be CFE_TBL_INFO_UPDATED because it was just loaded, but we can use CFE_SUCCESS too */ - if ((status != CFE_TBL_INFO_UPDATED) && (status != CFE_SUCCESS)) - { - CFE_EVS_SendEvent(CF_INIT_TBL_GETADDR_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: error getting table address, returned 0x%08lx", - (unsigned long)status); - } else { - status = CFE_SUCCESS; + status = CF_ManageTables(CF_GetEngine(), true); } } @@ -216,8 +299,6 @@ CFE_Status_t CF_AppInit(void) CF_AppData.RunStatus = CFE_ES_RunStatus_APP_RUN; - CFE_MSG_Init(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(CF_AppData.hk)); - status = CFE_EVS_Register(NULL, 0, CFE_EVS_EventFilter_BINARY); if (status != CFE_SUCCESS) { @@ -258,7 +339,7 @@ CFE_Status_t CF_AppInit(void) if (status == CFE_SUCCESS) { - status = CF_CFDP_InitEngine(); /* function sends event internally */ + status = CF_CFDP_InitEngine(CF_GetEngine()); /* function sends event internally */ } if (status == CFE_SUCCESS) diff --git a/fsw/src/cf_app.h b/fsw/src/cf_app.h index 344a79db..d8b97357 100644 --- a/fsw/src/cf_app.h +++ b/fsw/src/cf_app.h @@ -84,14 +84,11 @@ */ typedef struct { - CF_HkPacket_t hk; - uint32 RunStatus; - CFE_SB_PipeId_t CmdPipe; - - CFE_TBL_Handle_t config_handle; - CF_ConfigTable_t *config_table; + CF_HkCmdCounters_t counters; + CFE_SB_PipeId_t CmdPipe; + CFE_TBL_Handle_t config_handle; CF_Engine_t engine; } CF_AppData_t; @@ -113,6 +110,180 @@ extern CF_AppData_t CF_AppData; ** **************************************************************************/ +/************************************************************************/ +/** + * @brief Gets the CFDP engine struct + * + * @par Description + * Obtains a pointer to the CFDP engine. + * + * @par Assumptions, External Events, and Notes: + * This is currently a singleon in the CF app, but the architecture + * does permit there to be more than one. + * + * This never returns NULL, in the current implementation there is + * one (and only one) engine. + * + * @returns engine pointer + */ +static inline CF_Engine_t *CF_GetEngine(void) +{ + return &CF_AppData.engine; +} + +/************************************************************************/ +/** + * @brief Checks if a class identifier is valid + * + * @par Description + * checks if the given class number matches one of the defined enum values + * + * @par Assumptions, External Events, and Notes: + * None + * + * @retval true if value is valid/acceptable + * @retval false if value is invalid + */ +static inline bool CF_IsValidClass(CF_CFDP_Class_Enum_t cv) +{ + return (cv == CF_CFDP_Class_1 || cv == CF_CFDP_Class_2); +} + +/************************************************************************/ +/** + * @brief Checks if a channel identifier is valid + * + * @par Description + * checks if the given channel number matches one of the defined values + * + * @par Assumptions, External Events, and Notes: + * This only checks if it matches a single channel. It does not test + * for the special values that some commands might accept. + * + * @retval true if value is valid/acceptable + * @retval false if value is invalid + */ +static inline bool CF_IsValidChannel(CF_ChannelSelect_t cs) +{ + return (cs < CF_NUM_CHANNELS); +} + +/************************************************************************/ +/** + * @brief Checks if a channel identifier represents "all channels" + * + * @par Description + * checks if the given channel number matches the special all channels value + * + * @par Assumptions, External Events, and Notes: + * This only checks if it matches all channels. + * + * @retval true if value is valid/acceptable + * @retval false if value is invalid + */ +static inline bool CF_IsAllChannels(CF_ChannelSelect_t cs) +{ + return (cs == CF_ALL_CHANNELS); +} + +/************************************************************************/ +/** + * @brief Checks if a channel identifier represents "all channels" + * + * @par Description + * checks if the given channel number matches the special all channels value + * + * @par Assumptions, External Events, and Notes: + * This only checks if it matches all channels. + * + * @retval true if value is valid/acceptable + * @retval false if value is invalid + */ +static inline bool CF_IsCompoundKey(CF_ChannelSelect_t cs) +{ + return (cs == CF_COMPOUND_KEY); +} + +/************************************************************************/ +/** + * @brief Gets the channel number as an integer + * + * @par Description + * For consistent representation of channel numbers in logs messages + * and other strings. + * + * @par Assumptions, External Events, and Notes: + * Format log messages with printf "%d" conversion + * + * @returns channel number represented as "int" type + */ +static inline int CF_ChannelSelect_AsInt(CF_ChannelSelect_t cs) +{ + return (cs); +} + +/************************************************************************/ +/** + * @brief Gets the channel number from integer + * + * @par Description + * For intentional conversion from an integer value to a channel number + * + * @par Assumptions, External Events, and Notes: + * this exists for special/corner cases only, should really not be + * needed in general. Prefer to use the APIs that invoke a subroutine + * using the standard selector logic. + * + * @returns channel number value + */ +static inline CF_ChannelSelect_t CF_ChannelSelect_FromInt(int c) +{ + return (c); +} + +/************************************************************************/ +/** + * @brief Gets the channel pointer from a channel number + * + * @par Description + * Obtains the channel pointer associated with the channel number + * + * @par Assumptions, External Events, and Notes: + * This implements range-checking and may return NULL + * + * @returns channel pointer + * @retval NULL if channel number is invalid + */ +static inline CF_Channel_t *CF_GetChannelPtr(CF_ChannelSelect_t cs) +{ + if (CF_IsValidChannel(cs)) + { + return &CF_GetEngine()->channels[cs]; + } + else + { + return NULL; + } +} + +/************************************************************************/ +/** + * @brief Gets the channel number from a channel pointer + * + * @par Description + * Obtains the channel number associated with the channel pointer + * + * @par Assumptions, External Events, and Notes: + * This is primarily for log messages. + * + * @returns channel number + */ +static inline CF_ChannelSelect_t CF_GetChannelFromPtr(const CF_Channel_t *ChanPtr) +{ + CF_Engine_t *engine_ptr = CF_GetEngine(); + return (CF_ChannelSelect_t) { (ChanPtr - engine_ptr->channels) }; +} + /************************************************************************/ /** @brief Checks to see if a table update is pending, and perform it. * diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 5433fe7d..ab693389 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -46,6 +46,19 @@ #include #include "cf_assert.h" +/** + * State data for engine init + * + * Tracks the next engine pointers to use + */ +typedef struct CF_EngineInitState +{ + CF_History_t *history; + CF_Transaction_t *txn; + CF_ChunkWrapper_t *cw; + size_t chunk_mem_offset; +} CF_EngineInitState_t; + /*---------------------------------------------------------------- * * Application-scope internal function @@ -128,7 +141,8 @@ void CF_CFDP_DecodeStart(CF_DecoderState_t *pdec, *-----------------------------------------------------------------*/ void CF_CFDP_ArmAckTimer(CF_Transaction_t *txn) { - CF_Timer_InitRelSec(&txn->ack_timer, CF_AppData.config_table->chan[txn->chan_num].ack_timer_s); + const CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + CF_Timer_InitRelSec(&txn->ack_timer, chan->config.ack_timer_s); txn->flags.com.ack_timer_armed = true; } @@ -162,13 +176,14 @@ static inline bool CF_CFDP_IsSender(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_ArmInactTimer(CF_Transaction_t *txn) { - CF_Timer_Seconds_t Sec; + const CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + CF_Timer_Seconds_t Sec; /* select timeout based on the state */ if (CF_CFDP_GetAckTxnStatus(txn) == CF_CFDP_AckTxnStatus_ACTIVE) { /* in an active transaction, we expect traffic so use the normal inactivity timer */ - Sec = CF_AppData.config_table->chan[txn->chan_num].inactivity_timer_s; + Sec = chan->config.inactivity_timer_s; } else { @@ -179,7 +194,7 @@ void CF_CFDP_ArmInactTimer(CF_Transaction_t *txn) * timeout would hold resources longer than needed). Using double the ack timer should * ensure that if the remote retransmitted anything, we will see it, and avoids adding * another config option just for this. */ - Sec = CF_AppData.config_table->chan[txn->chan_num].ack_timer_s * 2; + Sec = chan->config.ack_timer_s * 2; } CF_Timer_InitRelSec(&txn->inactivity_timer, Sec); @@ -193,12 +208,13 @@ void CF_CFDP_ArmInactTimer(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ bool CF_CFDP_CheckAckNakCount(CF_Transaction_t *txn, uint8 *counter) { - bool is_ok; - uint16 Event; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + bool is_ok; + uint16 Event; /* Check limit and handle if needed */ Event = 0; - is_ok = (*counter < CF_AppData.config_table->chan[txn->chan_num].ack_limit); + is_ok = (*counter < chan->config.ack_limit); if (is_ok) { @@ -208,7 +224,7 @@ bool CF_CFDP_CheckAckNakCount(CF_Transaction_t *txn, uint8 *counter) else { /* Reached limit */ - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.ack_limit; + ++chan->stat.counters.fault.ack_limit; if (txn->history->dir == CF_Direction_TX) { @@ -326,7 +342,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *txn, hdr->version = 1; hdr->pdu_type = (directive_code == 0); /* set to '1' for file data PDU, '0' for a directive PDU */ hdr->direction = (towards_sender != false); /* set to '1' for toward sender, '0' for toward receiver */ - hdr->txm_mode = (CF_CFDP_GetClass(txn) == CF_CFDP_CLASS_1); /* set to '1' for class 1 data, '0' for class 2 */ + hdr->txm_mode = (CF_CFDP_GetClass(txn) == CF_CFDP_Class_1); /* set to '1' for class 1 data, '0' for class 2 */ /* choose the larger of the two EIDs to determine size */ if (src_eid > dst_eid) @@ -380,9 +396,10 @@ CF_Logical_PduBuffer_t *CF_CFDP_ConstructPduHeader(const CF_Transaction_t *txn, *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_SendMd(CF_Transaction_t *txn) { - CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_METADATA, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, txn->history->peer_eid, 0, txn->history->seq_num, @@ -414,7 +431,7 @@ CFE_Status_t CF_CFDP_SendMd(CF_Transaction_t *txn) CF_CFDP_EncodeMd(ph->penc, md); CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); CF_TRACE("%s(): Sent MD, size=%lu, cr=%d, ct=%d\n", __func__, @@ -441,7 +458,7 @@ CFE_Status_t CF_CFDP_SendFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) /* update PDU length */ CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); return ret; } @@ -455,6 +472,7 @@ CFE_Status_t CF_CFDP_SendFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) void CF_CFDP_AppendTlv(CF_Logical_TlvList_t *ptlv_list, CF_CFDP_TlvType_t tlv_type) { CF_Logical_Tlv_t *ptlv; + CF_Engine_t *engine_ptr = CF_GetEngine(); if (ptlv_list->num_tlv < CF_PDU_MAX_TLV) { @@ -472,7 +490,7 @@ void CF_CFDP_AppendTlv(CF_Logical_TlvList_t *ptlv_list, CF_CFDP_TlvType_t tlv_ty if (tlv_type == CF_CFDP_TLV_TYPE_ENTITY_ID) { - ptlv->data.eid = CF_AppData.config_table->local_eid; + ptlv->data.eid = engine_ptr->config.local_eid; ptlv->length = CF_CFDP_GetValueEncodedSize(ptlv->data.eid); } else @@ -491,9 +509,10 @@ void CF_CFDP_AppendTlv(CF_Logical_TlvList_t *ptlv_list, CF_CFDP_TlvType_t tlv_ty *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_SendEof(CF_Transaction_t *txn) { - CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_EOF, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, txn->history->peer_eid, 0, txn->history->seq_num, @@ -520,7 +539,7 @@ CFE_Status_t CF_CFDP_SendEof(CF_Transaction_t *txn) CF_CFDP_EncodeEof(ph->penc, eof); CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); CF_TRACE("%s(): Sent EOF, cc=%d, crc=%08lx, size=%lu\n", __func__, @@ -542,7 +561,8 @@ CFE_Status_t CF_CFDP_SendAck(CF_Transaction_t *txn, CF_CFDP_FileDirective_t dir_ { CF_Logical_PduBuffer_t *ph; CF_Logical_PduAck_t *ack; - CFE_Status_t ret = CFE_SUCCESS; + CFE_Status_t ret = CFE_SUCCESS; + CF_Engine_t *engine_ptr = CF_GetEngine(); CF_Assert((dir_code == CF_CFDP_FileDirective_EOF) || (dir_code == CF_CFDP_FileDirective_FIN)); @@ -550,7 +570,7 @@ CFE_Status_t CF_CFDP_SendAck(CF_Transaction_t *txn, CF_CFDP_FileDirective_t dir_ { ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_ACK, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, txn->history->peer_eid, false, txn->history->seq_num, @@ -561,7 +581,7 @@ CFE_Status_t CF_CFDP_SendAck(CF_Transaction_t *txn, CF_CFDP_FileDirective_t dir_ ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_ACK, txn->history->peer_eid, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, true, txn->history->seq_num, 0); @@ -589,7 +609,7 @@ CFE_Status_t CF_CFDP_SendAck(CF_Transaction_t *txn, CF_CFDP_FileDirective_t dir_ CF_CFDP_EncodeAck(ph->penc, ack); CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); CF_TRACE("%s(): Sent ACK, dir_code=%d, cc=%d, st=%d\n", __func__, @@ -612,11 +632,12 @@ CFE_Status_t CF_CFDP_SendFin(CF_Transaction_t *txn) CF_Logical_PduBuffer_t *ph; CF_Logical_PduFin_t *fin; CFE_Status_t ret; + CF_Engine_t *engine_ptr = CF_GetEngine(); ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_FIN, txn->history->peer_eid, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, 1, txn->history->seq_num, 0); @@ -641,7 +662,7 @@ CFE_Status_t CF_CFDP_SendFin(CF_Transaction_t *txn) CF_CFDP_EncodeFin(ph->penc, fin); CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); CF_TRACE("%s(): Sent FIN, cc=%d, dc=%d, st=%d\n", __func__, @@ -663,7 +684,7 @@ void CF_CFDP_SendNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { CF_Logical_PduNak_t *nak; - CF_Assert(CF_CFDP_GetClass(txn) == CF_CFDP_CLASS_2); + CF_Assert(CF_CFDP_GetClass(txn) == CF_CFDP_Class_2); nak = &ph->int_header.nak; @@ -674,7 +695,7 @@ void CF_CFDP_SendNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) CF_CFDP_EncodeNak(ph->penc, nak); CF_CFDP_SetPduLength(ph); - CF_CFDP_Send(txn->chan_num, ph); + CF_CFDP_Send(CF_GetChannelFromTxn(txn), ph); /* The timer needs to be armed after this, lack of response will need a re-nak */ CF_CFDP_ArmAckTimer(txn); @@ -688,11 +709,10 @@ void CF_CFDP_SendNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) * See description in cf_cfdp.h for argument/return detail * *-----------------------------------------------------------------*/ -CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) +CFE_Status_t CF_CFDP_RecvPh(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph) { CFE_Status_t ret = CFE_SUCCESS; - CF_Assert(chan_num < CF_NUM_CHANNELS); /* * If the source eid, destination eid, or sequence number fields * are larger than the sizes configured in the cf platform config @@ -703,7 +723,7 @@ CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) CFE_EVS_SendEvent(CF_PDU_TRUNCATION_ERR_EID, CFE_EVS_EventType_ERROR, "CF: PDU rejected due to EID/seq number field truncation"); - ++CF_AppData.hk.Payload.channel_hk[chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_ERROR; } /* @@ -717,7 +737,7 @@ CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) CFE_EVS_SendEvent(CF_PDU_LARGE_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: PDU with large file bit received (unsupported)"); - ++CF_AppData.hk.Payload.channel_hk[chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_ERROR; } else @@ -733,13 +753,13 @@ CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) CFE_EVS_EventType_ERROR, "CF: PDU too short (%lu received)", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec)); - ++CF_AppData.hk.Payload.channel_hk[chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_SHORT_PDU_ERROR; } else { /* PDU is ok, so continue processing */ - ++CF_AppData.hk.Payload.channel_hk[chan_num].counters.recv.pdu; + ++chan->stat.counters.recv.pdu; } } @@ -754,7 +774,8 @@ CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { - const CF_Logical_PduMd_t *md = &ph->int_header.md; + const CF_Logical_PduMd_t *md = &ph->int_header.md; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); int lv_ret; CFE_Status_t ret = CFE_SUCCESS; @@ -765,7 +786,7 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) CFE_EVS_EventType_ERROR, "CF: metadata packet too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec)); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_PDU_METADATA_ERROR; } else @@ -795,7 +816,7 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, md->source_filename.length); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_PDU_METADATA_ERROR; } else @@ -812,7 +833,7 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, md->dest_filename.length); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_PDU_METADATA_ERROR; } else @@ -840,7 +861,8 @@ CFE_Status_t CF_CFDP_RecvMd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_RecvFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { - CFE_Status_t ret = CFE_SUCCESS; + CFE_Status_t ret = CFE_SUCCESS; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); CF_CFDP_DecodeFileDataHeader(ph->pdec, ph->pdu_header.segment_meta_flag, &ph->int_header.fd); @@ -863,7 +885,7 @@ CFE_Status_t CF_CFDP_RecvFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) CFE_EVS_EventType_ERROR, "CF: filedata PDU too short: %lu bytes received", (unsigned long)CF_CODEC_GET_SIZE(ph->pdec)); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_SHORT_PDU_ERROR; } else if (ph->pdu_header.segment_meta_flag) @@ -872,7 +894,7 @@ CFE_Status_t CF_CFDP_RecvFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) CFE_EVS_SendEvent(CF_PDU_FD_UNSUPPORTED_ERR_EID, CFE_EVS_EventType_ERROR, "CF: filedata PDU with segment metadata received"); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; ret = CF_ERROR; } @@ -986,7 +1008,8 @@ CFE_Status_t CF_CFDP_RecvNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ void CF_CFDP_RecvDrop(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.dropped; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + ++chan->stat.counters.recv.dropped; } /*---------------------------------------------------------------- @@ -997,8 +1020,10 @@ void CF_CFDP_RecvDrop(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ void CF_CFDP_RecvHold(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + /* anything received in this state is considered spurious */ - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.spurious; + ++chan->stat.counters.recv.spurious; /* * Normally we do not expect PDUs for a transaction in holdover, because @@ -1155,11 +1180,11 @@ void CF_CFDP_SetupRxTransaction(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *p void CF_CFDP_ReceivePdu(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph) { CF_Transaction_t *txn; - uint8 chan_num = (chan - CF_AppData.engine.channels); + CF_Engine_t *engine_ptr = CF_GetEngine(); /* This decodes the header in the PDU. If it fails it sends the relevent event * and increments any necessary counters. */ - if (CF_CFDP_RecvPh(chan_num, ph) != CFE_SUCCESS) + if (CF_CFDP_RecvPh(chan, ph) != CFE_SUCCESS) { /* drop it, nothing more to do */ return; @@ -1171,10 +1196,10 @@ void CF_CFDP_ReceivePdu(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph) { /* if no match found, then check if we are the destination entity id. * If so then this would be the first PDU of an RX transaction */ - if (ph->pdu_header.destination_eid == CF_AppData.config_table->local_eid) + if (ph->pdu_header.destination_eid == engine_ptr->config.local_eid) { /* we didn't find a match, so assign it to a transaction */ - txn = CF_CFDP_StartRxTransaction(chan_num); + txn = CF_CFDP_StartRxTransaction(chan); if (txn == NULL) { CFE_EVS_SendEvent( @@ -1210,176 +1235,204 @@ void CF_CFDP_ReceivePdu(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph) /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cfdp.h for argument/return detail + * Internal helper routine only, not part of API. + * Initializes a single channel within the engine. + * Compatible with CF_ForEachChannel() * *-----------------------------------------------------------------*/ -CFE_Status_t CF_CFDP_InitEngine(void) +static int32 CF_CFDP_DoEngineChannelInit(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { - /* initialize all transaction nodes */ - CF_History_t *history; - CF_Transaction_t *txn = CF_AppData.engine.transactions; - CF_ChunkWrapper_t *cw = CF_AppData.engine.chunks; - CF_CListNode_t **list_head; - CFE_Status_t ret = CFE_SUCCESS; - int chunk_mem_offset = 0; - int i; - int j; - int k; - char nbuf[64]; - static const int CF_DIR_MAX_CHUNKS[CF_Direction_NUM][CF_NUM_CHANNELS] = { CF_CHANNEL_NUM_RX_CHUNKS_PER_TRANSACTION, CF_CHANNEL_NUM_TX_CHUNKS_PER_TRANSACTION }; - memset(&CF_AppData.engine, 0, sizeof(CF_AppData.engine)); + CF_EngineInitState_t *state = arg; + CF_CListNode_t **list_head; + int j; + int k; + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); + char nbuf[64]; + CFE_Status_t ret = CFE_SUCCESS; - /* Ensure that the temp directory exists (ignore error if it already exists) */ - OS_mkdir(CF_AppData.config_table->tmp_dir, 0); + snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, chan_num); + ret = CFE_SB_CreatePipe(&chan->pipe, chan->config.pipe_depth_input, nbuf); + if (ret != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_CR_CHANNEL_PIPE_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: failed to create pipe %s, returned 0x%08lx", + nbuf, + (unsigned long)ret); + return ret; + } - for (i = 0; i < CF_NUM_CHANNELS; ++i) + ret = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(chan->config.mid_input), chan->pipe, chan->config.pipe_depth_input); + if (ret != CFE_SUCCESS) { - snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, i); - ret = CFE_SB_CreatePipe(&CF_AppData.engine.channels[i].pipe, - CF_AppData.config_table->chan[i].pipe_depth_input, - nbuf); - if (ret != CFE_SUCCESS) + CFE_EVS_SendEvent(CF_INIT_SUB_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: failed to subscribe to MID 0x%lx, returned 0x%08lx", + (unsigned long)chan->config.mid_input, + (unsigned long)ret); + return ret; + } + + if (chan->config.sem_name[0]) + { + /* + * There is a start up race condition because CFE starts all apps at the same time, + * and if this sem is instantiated by another app, it may not be created yet. + * + * Therefore if OSAL returns OS_ERR_NAME_NOT_FOUND, assume this is what is going + * on, delay a bit and try again. + */ + ret = OS_ERR_NAME_NOT_FOUND; + for (j = 0; j < CF_STARTUP_SEM_MAX_RETRIES; ++j) { - CFE_EVS_SendEvent(CF_CR_CHANNEL_PIPE_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: failed to create pipe %s, returned 0x%08lx", - nbuf, - (unsigned long)ret); - break; + ret = OS_CountSemGetIdByName(&chan->sem_id, chan->config.sem_name); + + if (ret != OS_ERR_NAME_NOT_FOUND) + { + break; + } + + OS_TaskDelay(CF_STARTUP_SEM_TASK_DELAY); } - ret = CFE_SB_SubscribeLocal(CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[i].mid_input), - CF_AppData.engine.channels[i].pipe, - CF_AppData.config_table->chan[i].pipe_depth_input); - if (ret != CFE_SUCCESS) + if (ret != OS_SUCCESS) { - CFE_EVS_SendEvent(CF_INIT_SUB_ERR_EID, + CFE_EVS_SendEvent(CF_INIT_SEM_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: failed to subscribe to MID 0x%lx, returned 0x%08lx", - (unsigned long)CF_AppData.config_table->chan[i].mid_input, - (unsigned long)ret); - break; + "CF: failed to get sem id for name %s, error=%ld", + chan->config.sem_name, + (long)ret); + return ret; } + } - if (CF_AppData.config_table->chan[i].sem_name[0]) - { - /* - * There is a start up race condition because CFE starts all apps at the same time, - * and if this sem is instantiated by another app, it may not be created yet. - * - * Therefore if OSAL returns OS_ERR_NAME_NOT_FOUND, assume this is what is going - * on, delay a bit and try again. - */ - ret = OS_ERR_NAME_NOT_FOUND; - for (j = 0; j < CF_STARTUP_SEM_MAX_RETRIES; ++j) - { - ret = OS_CountSemGetIdByName(&CF_AppData.engine.channels[i].sem_id, - CF_AppData.config_table->chan[i].sem_name); + for (j = 0; j < CF_NUM_TRANSACTIONS_PER_CHANNEL; ++j) + { + /* Initially put this on the free list for this channel */ + state->txn->chan_ptr = chan; + CF_CList_InitNode(&state->txn->cl_node); + CF_CList_InsertBack_Ex(chan, CF_QueueIdx_FREE, &state->txn->cl_node); + ++state->txn; - if (ret != OS_ERR_NAME_NOT_FOUND) - { - break; - } + for (k = 0; k < CF_Direction_NUM; ++k) + { + list_head = CF_GetChunkListHead(chan, k); - OS_TaskDelay(CF_STARTUP_SEM_TASK_DELAY); - } + CF_ChunkListInit(&state->cw->chunks, + CF_DIR_MAX_CHUNKS[k][chan_num], + &engine_ptr->chunk_mem[state->chunk_mem_offset]); + state->chunk_mem_offset += CF_DIR_MAX_CHUNKS[k][chan_num]; + CF_CList_InitNode(&state->cw->cl_node); + CF_CList_InsertBack(list_head, &state->cw->cl_node); - if (ret != OS_SUCCESS) - { - CFE_EVS_SendEvent(CF_INIT_SEM_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: failed to get sem id for name %s, error=%ld", - CF_AppData.config_table->chan[i].sem_name, - (long)ret); - break; - } + ++state->cw; } + } - for (j = 0; j < CF_NUM_TRANSACTIONS_PER_CHANNEL; ++j, ++txn) - { - /* Initially put this on the free list for this channel */ - CF_FreeTransaction(txn, i); + for (j = 0; j < CF_NUM_HISTORIES_PER_CHANNEL; ++j) + { + CF_CList_InitNode(&state->history->cl_node); + CF_CList_InsertBack_Ex(chan, CF_QueueIdx_HIST_FREE, &state->history->cl_node); - for (k = 0; k < CF_Direction_NUM; ++k, ++cw) - { - list_head = CF_GetChunkListHead(&CF_AppData.engine.channels[i], k); + ++state->history; + } - CF_Assert((chunk_mem_offset + CF_DIR_MAX_CHUNKS[k][i]) <= CF_NUM_CHUNKS_ALL_CHANNELS); - CF_ChunkListInit(&cw->chunks, CF_DIR_MAX_CHUNKS[k][i], &CF_AppData.engine.chunk_mem[chunk_mem_offset]); - chunk_mem_offset += CF_DIR_MAX_CHUNKS[k][i]; - CF_CList_InitNode(&cw->cl_node); - CF_CList_InsertBack(list_head, &cw->cl_node); - } - } + return CFE_SUCCESS; +} - for (j = 0; j < CF_NUM_HISTORIES_PER_CHANNEL; ++j) - { - history = &CF_AppData.engine.histories[(i * CF_NUM_HISTORIES_PER_CHANNEL) + j]; - CF_CList_InitNode(&history->cl_node); - CF_CList_InsertBack_Ex(&CF_AppData.engine.channels[i], CF_QueueIdx_HIST_FREE, &history->cl_node); - } - } +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cfdp.h for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_CFDP_InitEngine(CF_Engine_t *engine_ptr) +{ + CFE_Status_t ret; + CF_EngineInitState_t state; + + /* NOTE: Not clearing the engine global struct here. + * It was already cleared at the beginning of CF_AppInit(), and + * since then the configuration was imported from the table. Clearing + * the global would wipe that configuration data. */ + + /* Ensure that the temp directory exists (ignore error if it already exists) */ + OS_mkdir(engine_ptr->config.tmp_dir, 0); + + memset(&state, 0, sizeof(state)); + state.history = engine_ptr->histories; + state.txn = engine_ptr->transactions; + state.cw = engine_ptr->chunks; + + ret = CF_ForEachChannel(engine_ptr, CF_CFDP_DoEngineChannelInit, &state); if (ret == CFE_SUCCESS) { - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; } + CF_Assert(state.chunk_mem_offset <= CF_NUM_CHUNKS_ALL_CHANNELS); + return ret; } /*---------------------------------------------------------------- * - * Application-scope internal function + * Local helper function function * See description in cf_cfdp.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_CFDP_S_Tick_NewData(CF_Transaction_t *txn) +static void CF_CFDP_S_Tick_SendFileData(CF_Transaction_t *txn) { + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); /* for perf log */ uint32 last_outgoing_counter; - CF_Channel_t *chan; - if (!txn->flags.com.suspended && txn->state_data.sub_state == CF_TxSubState_DATA_NORMAL) - { - /* this is a candidate for sending data */ - chan = CF_GetChannelFromTxn(txn); - } - else - { - chan = NULL; - } + CF_Assert(chan); - if (chan != NULL) + /* + * Run the TXN - Every call to DispatchTx should produce an outgoing PDU. + * If it does not, then it means this is blocked for some reason. Do not keep + * looping the same TXN if it is not making progress. Exit this loop and + * come back next tick. + * + * On the next tick, the state will be checked by the tick processor and + * may change out of DATA_NORMAL if necessary. Otherwise if it stays in + * DATA_NORMAL we will simply resume. + * + * Note the loop here is to adhere to the priority ordering. Items in the TX + * queue are ordered by priority so we should focus only on the first entry + * when sending new file data, then return CF_CLIST_EXIT to stop. If we exited + * with CF_CLIST_CONT it would effectively round robin between all entries. + */ + do { - /* - * Run the TXN - Every call to DispatchTx should produce an outgoing PDU. - * If it does not, then it means this is blocked for some reason. Do not keep - * looping the same TXN if it is not making progress. Exit this loop and - * come back next tick. - * - * On the next tick, the state will be checked by the tick processor and - * may change out of DATA_NORMAL if necessary. Otherwise if it stays in - * DATA_NORMAL we will simply resume. - * - * Note the loop here is to adhere to the priority ordering. Items in the TX - * queue are ordered by priority so we should focus only on the first entry - * when sending new file data, then return CF_CLIST_EXIT to stop. If we exited - * with CF_CLIST_CONT it would effectively round robin between all entries. - */ - do - { - last_outgoing_counter = chan->outgoing_counter; + last_outgoing_counter = chan->outgoing_counter; - CFE_ES_PerfLogEntry(CF_PERF_ID_PDUSENT(txn->chan_num)); - CF_CFDP_S_SubstateSendFileData(txn); - CFE_ES_PerfLogExit(CF_PERF_ID_PDUSENT(txn->chan_num)); - } while (last_outgoing_counter != chan->outgoing_counter); + CFE_ES_PerfLogEntry(CF_PERF_ID_PDUSENT(chan_num)); + CF_CFDP_S_SubstateSendFileData(txn); + CFE_ES_PerfLogExit(CF_PERF_ID_PDUSENT(chan_num)); + + } while (last_outgoing_counter != chan->outgoing_counter); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cfdp.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_CFDP_S_Tick_NewData(CF_Transaction_t *txn) +{ + if (!txn->flags.com.suspended && txn->state_data.sub_state == CF_TxSubState_DATA_NORMAL) + { + /* this is a candidate for sending data */ + CF_CFDP_S_Tick_SendFileData(txn); } } @@ -1575,12 +1628,16 @@ void CF_CFDP_TickTransactions(CF_Channel_t *chan) * See description in cf_cfdp.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority) +void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, + CF_CFDP_Class_t cfdp_class, + uint8 keep, + CF_Channel_t *chan, + uint8 priority) { - txn->chan_num = chan; + txn->chan_ptr = chan; txn->priority = priority; txn->keep = keep; - txn->reliable_mode = cfdp_class; + txn->reliable_mode = (cfdp_class == CF_CFDP_Class_2); txn->state = txn->reliable_mode ? CF_TxnState_S2 : CF_TxnState_S1; } @@ -1592,15 +1649,17 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, ui static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, CF_EntityId_t dest_id) { + CF_Engine_t *engine_ptr = CF_GetEngine(); + CFE_EVS_SendEvent(CF_CFDP_S_START_SEND_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: start class %d tx of file %lu:%.*s -> %lu:%.*s", cfdp_class + 1, - (unsigned long)CF_AppData.config_table->local_eid, + (unsigned long)engine_ptr->config.local_eid, CF_FILENAME_MAX_LEN, txn->history->fnames.src_filename, (unsigned long)dest_id, @@ -1610,11 +1669,11 @@ static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *txn, CF_CFDP_InitTxnTxFile(txn, cfdp_class, keep, chan, priority); /* Increment sequence number for new transaction */ - ++CF_AppData.engine.seq_num; + ++engine_ptr->seq_num; /* Capture info for history */ - txn->history->seq_num = CF_AppData.engine.seq_num; - txn->history->src_eid = CF_AppData.config_table->local_eid; + txn->history->seq_num = engine_ptr->seq_num; + txn->history->src_eid = engine_ptr->config.local_eid; txn->history->peer_eid = dest_id; CF_InsertSortPrio(txn, CF_QueueIdx_PEND); @@ -1630,21 +1689,21 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan_num, + CF_Channel_t *chan, uint8 priority, CF_EntityId_t dest_id) { CF_Transaction_t *txn; - CF_Channel_t *chan = &CF_AppData.engine.channels[chan_num]; - CF_Assert(chan_num < CF_NUM_CHANNELS); + + CF_Assert(chan != NULL); CFE_Status_t ret = CFE_SUCCESS; - CF_TRACE("%s(): start, channel=%d\n", __func__, (int)chan_num); + CF_TRACE("%s(): start, channel=%d\n", __func__, CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan))); if (chan->num_cmd_tx < CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN) { - txn = CF_FindUnusedTransaction(&CF_AppData.engine.channels[chan_num], CF_Direction_TX); + txn = CF_FindUnusedTransaction(chan, CF_Direction_TX); } else { @@ -1665,7 +1724,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, txn->history->fnames.src_filename[sizeof(txn->history->fnames.src_filename) - 1] = 0; strncpy(txn->history->fnames.dst_filename, dst_filename, sizeof(txn->history->fnames.dst_filename) - 1); txn->history->fnames.dst_filename[sizeof(txn->history->fnames.dst_filename) - 1] = 0; - CF_CFDP_TxFile_Initiate(txn, cfdp_class, keep, chan_num, priority, dest_id); + CF_CFDP_TxFile_Initiate(txn, cfdp_class, keep, chan, priority, dest_id); ++chan->num_cmd_tx; txn->flags.tx.cmd_tx = true; @@ -1680,14 +1739,13 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, * See description in cf_cfdp.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_Transaction_t *CF_CFDP_StartRxTransaction(uint8 chan_num) +CF_Transaction_t *CF_CFDP_StartRxTransaction(CF_Channel_t *chan) { - CF_Channel_t *chan = &CF_AppData.engine.channels[chan_num]; CF_Transaction_t *txn; - CF_TRACE("%s(): start, channel=%d\n", __func__, (int)chan_num); + CF_TRACE("%s(): start, channel=%d\n", __func__, CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan))); - if (CF_AppData.hk.Payload.channel_hk[chan_num].q_size[CF_QueueIdx_RX] < CF_MAX_SIMULTANEOUS_RX) + if (chan->stat.q_size[CF_QueueIdx_RX] < CF_MAX_SIMULTANEOUS_RX) { txn = CF_FindUnusedTransaction(chan, CF_Direction_RX); } @@ -1716,7 +1774,7 @@ static CFE_Status_t CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *pb, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, CF_EntityId_t dest_id) { @@ -1731,7 +1789,7 @@ static CFE_Status_t CF_CFDP_PlaybackDir_Initiate(CF_Playback_t *pb, "CF: failed to open playback directory %s, error=%ld", src_filename, (long)ret); - ++CF_AppData.hk.Payload.channel_hk[chan].counters.fault.directory_read; + ++chan->stat.counters.fault.directory_read; } else { @@ -1763,7 +1821,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, uint16 dest_id) { @@ -1772,7 +1830,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, for (i = 0; i < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++i) { - pb = &CF_AppData.engine.channels[chan].playback[i]; + pb = &chan->playback[i]; if (!pb->busy) { break; @@ -1854,12 +1912,7 @@ void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb) CF_FILENAME_MAX_NAME - 1, pb->pending_file); - CF_CFDP_TxFile_Initiate(txn, - pb->cfdp_class, - pb->keep, - (chan - CF_AppData.engine.channels), - pb->priority, - pb->dest_id); + CF_CFDP_TxFile_Initiate(txn, pb->cfdp_class, pb->keep, chan, pb->priority, pb->dest_id); txn->pb = pb; ++pb->num_ts; @@ -1907,15 +1960,12 @@ static void CF_CFDP_UpdatePollPbCounted(CF_Playback_t *pb, int up, uint8 *counte *-----------------------------------------------------------------*/ static void CF_CFDP_ProcessPlaybackDirectories(CF_Channel_t *chan) { - int i; - const int chan_index = (chan - CF_AppData.engine.channels); + int i; for (i = 0; i < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++i) { CF_CFDP_ProcessPlaybackDirectory(chan, &chan->playback[i]); - CF_CFDP_UpdatePollPbCounted(&chan->playback[i], - chan->playback[i].busy, - &CF_AppData.hk.Payload.channel_hk[chan_index].playback_counter); + CF_CFDP_UpdatePollPbCounted(&chan->playback[i], chan->playback[i].busy, &chan->stat.playback_counter); } } @@ -1927,19 +1977,17 @@ static void CF_CFDP_ProcessPlaybackDirectories(CF_Channel_t *chan) *-----------------------------------------------------------------*/ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) { - CF_Poll_t *poll; - CF_ChannelConfig_t *cc; - CF_PollDir_t *pd; - int i; - int chan_index; - int count_check; - int ret; + CF_Poll_t *poll; + const CF_LocalChanConfig_t *cc; + const CF_LocalPdConfig_t *pd; + int i; + int count_check; + int ret; for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) { poll = &chan->poll[i]; - chan_index = (chan - CF_AppData.engine.channels); - cc = &CF_AppData.config_table->chan[chan_index]; + cc = &chan->config; pd = &cc->polldir[i]; count_check = 0; @@ -1961,7 +2009,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) pd->dst_dir, pd->cfdp_class, 0, - chan_index, + chan, pd->priority, pd->dest_eid); if (!ret) @@ -1990,42 +2038,50 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) count_check = 1; } - CF_CFDP_UpdatePollPbCounted(&poll->pb, count_check, &CF_AppData.hk.Payload.channel_hk[chan_index].poll_counter); + CF_CFDP_UpdatePollPbCounted(&poll->pb, count_check, &chan->stat.poll_counter); } } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cfdp.h for argument/return detail + * Local helper function + * Cycles a single channel within the CFDP engine + * Compatible with CF_ForEachChannel() * *-----------------------------------------------------------------*/ -void CF_CFDP_CycleEngine(void) +static int32 CF_CFDP_DoEngineChannelCycle(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { - CF_Channel_t *chan; - int i; + chan->outgoing_counter = 0; + chan->tx_blocked = false; + + /* consume all received messages, even if channel is frozen */ + CF_CFDP_ReceiveMessage(chan); - if (CF_AppData.engine.enabled) + if (!chan->stat.frozen) { - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - chan = &CF_AppData.engine.channels[i]; + /* cycle all transactions (tick) */ + CF_CFDP_TickTransactions(chan); - chan->outgoing_counter = 0; - chan->tx_blocked = false; + CF_CFDP_ProcessPlaybackDirectories(chan); + CF_CFDP_ProcessPollingDirectories(chan); + } - /* consume all received messages, even if channel is frozen */ - CF_CFDP_ReceiveMessage(chan); + return CFE_SUCCESS; +} - if (!CF_AppData.hk.Payload.channel_hk[i].frozen) - { - /* cycle all transactions (tick) */ - CF_CFDP_TickTransactions(chan); +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cfdp.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_CFDP_CycleEngine(void) +{ + CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_CFDP_ProcessPlaybackDirectories(chan); - CF_CFDP_ProcessPollingDirectories(chan); - } - } + if (engine_ptr->enabled) + { + CF_ForEachChannel(engine_ptr, CF_CFDP_DoEngineChannelCycle, NULL); } } @@ -2111,13 +2167,13 @@ void CF_CFDP_RecycleTransaction(CF_Transaction_t *txn) txn->fd = OS_OBJECT_ID_UNDEFINED; } - CF_DequeueTransaction(txn); /* this makes it "float" (not in any queue) */ - chan = CF_GetChannelFromTxn(txn); /* this should always be */ if (chan != NULL && txn->history != NULL) { + CF_DequeueTransaction(txn); /* this makes it "float" (not in any queue) */ + if (txn->chunks != NULL) { chunklist_head = CF_GetChunkListHead(chan, txn->history->dir); @@ -2137,6 +2193,7 @@ void CF_CFDP_RecycleTransaction(CF_Transaction_t *txn) { hist_destq = CF_QueueIdx_HIST_FREE; } + CF_CList_InsertBack_Ex(chan, hist_destq, &txn->history->cl_node); txn->history = NULL; } @@ -2144,7 +2201,7 @@ void CF_CFDP_RecycleTransaction(CF_Transaction_t *txn) /* this wipes it and puts it back onto the list to be found by * CF_FindUnusedTransaction(). Need to preserve the chan_num * and keep it associated with this channel, though. */ - CF_FreeTransaction(txn, txn->chan_num); + CF_FreeTransaction(txn); } /*---------------------------------------------------------------- @@ -2210,7 +2267,7 @@ void CF_CFDP_SendEotPkt(CF_Transaction_t *txn) CFE_MSG_Init(CFE_MSG_PTR(EotPktPtr->TelemetryHeader), CFE_SB_ValueToMsgId(CF_EOT_TLM_MID), sizeof(*EotPktPtr)); - EotPktPtr->Payload.channel = txn->chan_num; + EotPktPtr->Payload.channel = CF_GetChannelFromPtr(CF_GetChannelFromTxn(txn)); EotPktPtr->Payload.direction = txn->history->dir; EotPktPtr->Payload.fnames = txn->history->fnames; EotPktPtr->Payload.state = txn->state; @@ -2283,53 +2340,62 @@ CF_CListTraverse_Status_t CF_CFDP_CloseFiles(CF_CListNode_t *node, void *context /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cfdp.h for argument/return detail + * Local helper function + * Closes/shuts down a single channel within the CFDP engine + * Compatible with CF_ForEachChannel() * *-----------------------------------------------------------------*/ -void CF_CFDP_DisableEngine(void) +static int32 CF_CFDP_DoCloseChannel(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { - int i; - int j; static const CF_QueueIdx_t CLOSE_QUEUES[] = { CF_QueueIdx_RX, CF_QueueIdx_TX }; - CF_Channel_t *chan; - CF_AppData.engine.enabled = false; + int j; - for (i = 0; i < CF_NUM_CHANNELS; ++i) + /* first, close all active files */ + for (j = 0; j < (sizeof(CLOSE_QUEUES) / sizeof(CLOSE_QUEUES[0])); ++j) { - chan = &CF_AppData.engine.channels[i]; + CF_CList_Traverse(chan->qs[CLOSE_QUEUES[j]], CF_CFDP_CloseFiles, NULL); + } - /* first, close all active files */ - for (j = 0; j < (sizeof(CLOSE_QUEUES) / sizeof(CLOSE_QUEUES[0])); ++j) + /* any playback directories need to have their directory ids closed */ + for (j = 0; j < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++j) + { + if (chan->playback[j].busy) { - CF_CList_Traverse(chan->qs[CLOSE_QUEUES[j]], CF_CFDP_CloseFiles, NULL); + OS_DirectoryClose(chan->playback[j].dir_id); } + } - /* any playback directories need to have their directory ids closed */ - for (j = 0; j < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++j) + for (j = 0; j < CF_MAX_POLLING_DIR_PER_CHAN; ++j) + { + if (chan->poll[j].pb.busy) { - if (chan->playback[j].busy) - { - OS_DirectoryClose(chan->playback[j].dir_id); - } + OS_DirectoryClose(chan->poll[j].pb.dir_id); } + } - for (j = 0; j < CF_MAX_POLLING_DIR_PER_CHAN; ++j) - { - if (chan->poll[j].pb.busy) - { - OS_DirectoryClose(chan->poll[j].pb.dir_id); - } - } + /* finally all queue counters must be reset */ + memset(&chan->stat.q_size, 0, sizeof(chan->stat.q_size)); - /* finally all queue counters must be reset */ - memset(&CF_AppData.hk.Payload.channel_hk[i].q_size, 0, sizeof(CF_AppData.hk.Payload.channel_hk[i].q_size)); + /* SAD: Suppress Ignored Return Value warning from CodeSonar. CFE_SB_DeletePipe() will send event message if + * there is any error */ + (void)CFE_SB_DeletePipe(chan->pipe); - /* SAD: Suppress Ignored Return Value warning from CodeSonar. CFE_SB_DeletePipe() will send event message if - * there is any error */ - (void)CFE_SB_DeletePipe(chan->pipe); - } + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cfdp.h for argument/return detail + * + *-----------------------------------------------------------------*/ +void CF_CFDP_DisableEngine(void) +{ + CF_Engine_t *engine_ptr = CF_GetEngine(); + + engine_ptr->enabled = false; + CF_ForEachChannel(engine_ptr, CF_CFDP_DoCloseChannel, NULL); } /*---------------------------------------------------------------- @@ -2340,11 +2406,13 @@ void CF_CFDP_DisableEngine(void) *-----------------------------------------------------------------*/ void CF_CFDP_GetTempName(const CF_History_t *hist, char *FileNameBuf, size_t FileNameSize) { + CF_Engine_t *engine_ptr = CF_GetEngine(); + snprintf(FileNameBuf, FileNameSize, "%.*s/%lu_%lu.tmp", CF_FILENAME_MAX_PATH - 1, - CF_AppData.config_table->tmp_dir, + engine_ptr->config.tmp_dir, (unsigned long)hist->src_eid, (unsigned long)hist->seq_num); } diff --git a/fsw/src/cf_cfdp.h b/fsw/src/cf_cfdp.h index 3638660f..c1eb2d9b 100644 --- a/fsw/src/cf_cfdp.h +++ b/fsw/src/cf_cfdp.h @@ -225,11 +225,12 @@ void CF_CFDP_CompleteTick(CF_Transaction_t *txn); * @par Assumptions, External Events, and Notes: * Only called once. * + * @param engine_ptr CF engine pointer (must not be NULL) * @retval #CFE_SUCCESS \copydoc CFE_SUCCESS * @returns anything else on error. * */ -CFE_Status_t CF_CFDP_InitEngine(void); +CFE_Status_t CF_CFDP_InitEngine(CF_Engine_t *engine_ptr); /************************************************************************/ /** @brief Cycle the engine. Called once per wakeup. @@ -263,7 +264,7 @@ void CF_CFDP_DisableEngine(void); * @param dst_filename Remote filename * @param cfdp_class Whether to perform a class 1 or class 2 transfer * @param keep Whether to keep or delete the local file after completion - * @param chan CF channel number to use + * @param chan CF channel pointer (must not be NULL) * @param priority CF priority level * @param dest_id Entity ID of remote receiver * @@ -274,7 +275,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, CF_EntityId_t dest_id); @@ -292,7 +293,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, * @param dst_filename Remote filename * @param cfdp_class Whether to perform a class 1 or class 2 transfer * @param keep Whether to keep or delete the local file after completion - * @param chan CF channel number to use + * @param chan CF channel pointer (must not be NULL) * @param priority CF priority level * @param dest_id Entity ID of remote receiver * @@ -303,7 +304,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, uint16 dest_id); @@ -453,7 +454,7 @@ void CF_CFDP_AppendTlv(CF_Logical_TlvList_t *ptlv_list, CF_CFDP_TlvType_t tlv_ty * @par Assumptions, External Events, and Notes: * A new message has been received. * - * @param chan_num The channel number for statistics purposes + * @param chan CF channel pointer (must not be NULL) * @param ph The logical PDU buffer being received * * @returns integer status code @@ -461,7 +462,7 @@ void CF_CFDP_AppendTlv(CF_Logical_TlvList_t *ptlv_list, CF_CFDP_TlvType_t tlv_ty * @retval CF_ERROR for general errors * @retval CF_SHORT_PDU_ERROR if PDU too short */ -CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph); +CFE_Status_t CF_CFDP_RecvPh(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph); /************************************************************************/ /** @brief Unpack a metadata PDU from a received message. @@ -610,11 +611,15 @@ void CF_CFDP_CancelTransaction(CF_Transaction_t *txn); * @param txn Pointer to the transaction state * @param cfdp_class Set to class 1 or class 2 * @param keep Whether to keep the local file - * @param chan CF channel number + * @param chan CF channel pointer (must not be NULL) * @param priority Priority of transfer * */ -void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority); +void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, + CF_CFDP_Class_t cfdp_class, + uint8 keep, + CF_Channel_t *chan, + uint8 priority); /************************************************************************/ /** @brief Helper function to start a new RX transaction @@ -626,11 +631,11 @@ void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, ui * * If there is no capacity for another RX transaction, this returns NULL. * - * @param chan_num CF channel number + * @param chan CF channel pointer (must not be NULL) * @returns Pointer to new transaction * */ -CF_Transaction_t *CF_CFDP_StartRxTransaction(uint8 chan_num); +CF_Transaction_t *CF_CFDP_StartRxTransaction(CF_Channel_t *chan); /* functions to handle LVs (length-value, CFDP spec) */ /* returns number of bytes copied, or -1 on error */ diff --git a/fsw/src/cf_cfdp_dispatch.c b/fsw/src/cf_cfdp_dispatch.c index c5a360f3..a7bb4397 100644 --- a/fsw/src/cf_cfdp_dispatch.c +++ b/fsw/src/cf_cfdp_dispatch.c @@ -44,6 +44,7 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, { CF_CFDP_StateRecvFunc_t selected_handler; CF_Logical_PduFileDirectiveHeader_t *fdh; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); selected_handler = NULL; @@ -60,7 +61,7 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, } else { - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.spurious; + ++chan->stat.counters.recv.spurious; CFE_EVS_SendEvent(CF_CFDP_R_DC_INV_ERR_EID, CFE_EVS_EventType_ERROR, "CF R%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d", @@ -79,7 +80,7 @@ void CF_CFDP_R_DispatchRecv(CF_Transaction_t *txn, } else { - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.dropped; + ++chan->stat.counters.recv.dropped; } } @@ -106,6 +107,7 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, const CF_CFDP_FileDirectiveDispatchTable_t *substate_tbl; CF_CFDP_StateRecvFunc_t selected_handler; CF_Logical_PduFileDirectiveHeader_t *fdh; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* send state, so we only care about file directive PDU */ selected_handler = NULL; @@ -123,7 +125,7 @@ void CF_CFDP_S_DispatchRecv(CF_Transaction_t *txn, } else { - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.spurious; + ++chan->stat.counters.recv.spurious; CFE_EVS_SendEvent(CF_CFDP_S_DC_INV_ERR_EID, CFE_EVS_EventType_ERROR, "CF S%d(%lu:%lu): received PDU with invalid directive code %d for sub-state %d", diff --git a/fsw/src/cf_cfdp_r.c b/fsw/src/cf_cfdp_r.c index a0b69092..61347e26 100644 --- a/fsw/src/cf_cfdp_r.c +++ b/fsw/src/cf_cfdp_r.c @@ -46,7 +46,8 @@ *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn) { - CFE_Status_t ret; + CFE_Status_t ret; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); if (txn->crc.result != txn->state_data.eof_crc) { @@ -58,7 +59,7 @@ CFE_Status_t CF_CFDP_R_CheckCrc(CF_Transaction_t *txn) (unsigned long)txn->history->seq_num, (unsigned long)txn->crc.result, (unsigned long)txn->state_data.eof_crc); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch; + ++chan->stat.counters.fault.crc_mismatch; ret = CF_ERROR; } else @@ -111,6 +112,7 @@ CFE_Status_t CF_CFDP_R_ProcessFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t * const CF_Logical_PduFileDataHeader_t *fd; int32 fret; CFE_Status_t ret; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* this function is only entered for data PDUs */ fd = &ph->int_header.fd; @@ -136,7 +138,7 @@ CFE_Status_t CF_CFDP_R_ProcessFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t * (long)fd->offset, (long)fret); CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILE_SIZE_ERROR); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek; + ++chan->stat.counters.fault.file_seek; ret = CF_ERROR; /* connection will reset in caller */ } else @@ -159,13 +161,13 @@ CFE_Status_t CF_CFDP_R_ProcessFd(CF_Transaction_t *txn, CF_Logical_PduBuffer_t * (long)fd->data_len, (long)fret); CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_write; + ++chan->stat.counters.fault.file_write; ret = CF_ERROR; /* connection will reset in caller */ } else { - txn->state_data.cached_pos = fd->data_len + fd->offset; - CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.file_data_bytes += fd->data_len; + txn->state_data.cached_pos = fd->data_len + fd->offset; + chan->stat.counters.recv.file_data_bytes += fd->data_len; /* insert gap data in chunks */ CF_ChunkListAdd(&txn->chunks->chunks, fd->offset, fd->data_len); @@ -185,6 +187,7 @@ void CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph { CFE_Status_t ret = CFE_SUCCESS; const CF_Logical_PduEof_t *eof; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* this function is only entered for PDUs identified as EOF type */ ret = CF_CFDP_RecvEof(txn, ph); @@ -223,7 +226,7 @@ void CF_CFDP_R_SubstateRecvEof(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph CF_CFDP_GetPrintClass(txn), (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; } } @@ -296,16 +299,18 @@ void CF_CFDP_R2_GapCompute(const CF_ChunkList_t *chunks, const CF_Chunk_t *chunk *-----------------------------------------------------------------*/ CFE_Status_t CF_CFDP_R_SendNak(CF_Transaction_t *txn) { - CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, CF_CFDP_FileDirective_NAK, txn->history->peer_eid, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, 1, txn->history->seq_num, 1); CF_Logical_PduNak_t *nak; uint32 cret; CFE_Status_t ret; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); if (ph == NULL) { @@ -350,7 +355,7 @@ CFE_Status_t CF_CFDP_R_SendNak(CF_Transaction_t *txn) { CF_CFDP_SendNak(txn, ph); - CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.nak_segment_requests += cret; + chan->stat.counters.sent.nak_segment_requests += cret; } } else @@ -386,8 +391,9 @@ CFE_Status_t CF_CFDP_R_SendNak(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_R_Init(CF_Transaction_t *txn) { - int32 ret; - char TempName[CFE_MISSION_MAX_FILE_LEN]; + int32 ret; + char TempName[CFE_MISSION_MAX_FILE_LEN]; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* set default FIN status */ txn->state_data.fin_dc = CF_CFDP_FinDeliveryCode_INVALID; @@ -408,7 +414,7 @@ void CF_CFDP_R_Init(CF_Transaction_t *txn) TempName, (long)ret); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_open; + ++chan->stat.counters.fault.file_open; txn->fd = OS_OBJECT_ID_UNDEFINED; /* just in case */ CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); @@ -435,7 +441,8 @@ void CF_CFDP_R_Init(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_R_CalcCrcStart(CF_Transaction_t *txn) { - int32 OsStatus; + int32 OsStatus; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); if (txn->fsize != txn->state_data.eof_size) { @@ -463,7 +470,7 @@ void CF_CFDP_R_CalcCrcStart(CF_Transaction_t *txn) (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, (long)OsStatus); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek; + ++chan->stat.counters.fault.file_seek; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILE_SIZE_ERROR); txn->flags.com.crc_complete = true; @@ -484,19 +491,20 @@ void CF_CFDP_R_CalcCrcStart(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_R_CalcCrcChunk(CF_Transaction_t *txn) { - uint8 buf[CF_R2_CRC_CHUNK_SIZE]; - size_t count_bytes; - size_t want_offs_size; - size_t read_size; - int fret; - bool success = true; + uint8 buf[CF_R2_CRC_CHUNK_SIZE]; + size_t count_bytes; + size_t want_offs_size; + size_t read_size; + int fret; + bool success = true; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); memset(buf, 0, sizeof(buf)); count_bytes = 0; - while ((count_bytes < CF_AppData.config_table->rx_crc_calc_bytes_per_wakeup) - && (txn->state_data.cached_pos < txn->fsize)) + while ((count_bytes < engine_ptr->config.rx_crc_calc_bytes_per_wakeup) && (txn->state_data.cached_pos < txn->fsize)) { want_offs_size = txn->state_data.cached_pos + sizeof(buf); @@ -521,7 +529,7 @@ void CF_CFDP_R_CalcCrcChunk(CF_Transaction_t *txn) (unsigned long)read_size, (long)fret); CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILE_SIZE_ERROR); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_read; + ++chan->stat.counters.fault.file_read; success = false; break; } @@ -558,6 +566,7 @@ void CF_CFDP_R2_SubstateRecvFinAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t { CFE_Status_t status; CF_Logical_PduAck_t *ack; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* receipt of fin-ack is only valid if we had previously sent * a fin and it decodes as expected */ @@ -591,7 +600,7 @@ void CF_CFDP_R2_SubstateRecvFinAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t CF_CFDP_GetPrintClass(txn), (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; } } @@ -1129,6 +1138,7 @@ void CF_CFDP_R_Tick_Maintenance(CF_Transaction_t *txn) void CF_CFDP_R_Tick(CF_Transaction_t *txn) { CF_CFDP_AckTxnStatus_t CurrStatus; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); CurrStatus = CF_CFDP_GetAckTxnStatus(txn); @@ -1152,7 +1162,7 @@ void CF_CFDP_R_Tick(CF_Transaction_t *txn) CF_CFDP_GetPrintClass(txn), (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.inactivity_timer; + ++chan->stat.counters.fault.inactivity_timer; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_INACTIVITY_DETECTED); } diff --git a/fsw/src/cf_cfdp_s.c b/fsw/src/cf_cfdp_s.c index 8ec9040f..75265b83 100644 --- a/fsw/src/cf_cfdp_s.c +++ b/fsw/src/cf_cfdp_s.c @@ -50,9 +50,10 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 { int32 status = 0; CFE_Status_t ret; - CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Logical_PduBuffer_t *ph = CF_CFDP_ConstructPduHeader(txn, 0, - CF_AppData.config_table->local_eid, + engine_ptr->config.local_eid, txn->history->peer_eid, 0, txn->history->seq_num, @@ -60,6 +61,7 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 CF_Logical_PduFileDataHeader_t *fd; size_t actual_bytes; void *data_ptr; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); if (!ph) { @@ -86,9 +88,9 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 { actual_bytes = bytes_to_read; } - if (actual_bytes > CF_AppData.config_table->outgoing_file_chunk_size) + if (actual_bytes > engine_ptr->config.outgoing_file_chunk_size) { - actual_bytes = CF_AppData.config_table->outgoing_file_chunk_size; + actual_bytes = engine_ptr->config.outgoing_file_chunk_size; } /* @@ -118,7 +120,7 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 (unsigned long)txn->history->seq_num, (long)foffs, (long)status); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek; + ++chan->stat.counters.fault.file_seek; ret = CF_ERROR; } else @@ -140,7 +142,7 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 (unsigned long)txn->history->seq_num, (long)actual_bytes, (long)status); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_read; + ++chan->stat.counters.fault.file_read; ret = CF_ERROR; } else @@ -153,7 +155,7 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 { CF_CFDP_SendFd(txn, ph); /* CF_CFDP_SendFd only returns CFE_SUCCESS */ - CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes += actual_bytes; + chan->stat.counters.sent.file_data_bytes += actual_bytes; if (calc_crc) { CF_CRC_Digest(&txn->crc, fd->data_ptr, fd->data_len); @@ -268,6 +270,7 @@ void CF_CFDP_S2_SubstateNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) const CF_Logical_PduNak_t *nak; uint8 counter; uint8 bad_sr; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); bad_sr = 0; @@ -314,8 +317,7 @@ void CF_CFDP_S2_SubstateNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) } } - CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.nak_segment_requests += - nak->segment_list.num_segments; + chan->stat.counters.recv.nak_segment_requests += nak->segment_list.num_segments; if (bad_sr) { CFE_EVS_SendEvent(CF_CFDP_S_INVALID_SR_ERR_EID, @@ -335,7 +337,7 @@ void CF_CFDP_S2_SubstateNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) CF_CFDP_GetPrintClass(txn), (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; } } @@ -349,6 +351,7 @@ void CF_CFDP_S2_SubstateEofAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph { CFE_Status_t ret; CF_Logical_PduAck_t *ack; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); ret = CF_CFDP_RecvAck(txn, ph); if (ret == CFE_SUCCESS) @@ -375,7 +378,7 @@ void CF_CFDP_S2_SubstateEofAck(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph CF_CFDP_GetPrintClass(txn), (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error; + ++chan->stat.counters.recv.error; } } @@ -439,8 +442,9 @@ void CF_CFDP_S2_Recv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ void CF_CFDP_S_Init(CF_Transaction_t *txn) { - int32 OsStatus; - osal_id_t PendingFd; + int32 OsStatus; + osal_id_t PendingFd; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); PendingFd = OS_OBJECT_ID_UNDEFINED; @@ -458,7 +462,7 @@ void CF_CFDP_S_Init(CF_Transaction_t *txn) (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_open; + ++chan->stat.counters.fault.file_open; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); } } @@ -476,7 +480,7 @@ void CF_CFDP_S_Init(CF_Transaction_t *txn) (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)OsStatus); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_open; + ++chan->stat.counters.fault.file_open; PendingFd = OS_OBJECT_ID_UNDEFINED; /* just in case */ CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); } @@ -495,7 +499,7 @@ void CF_CFDP_S_Init(CF_Transaction_t *txn) (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)OsStatus); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek; + ++chan->stat.counters.fault.file_seek; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); } else @@ -517,7 +521,7 @@ void CF_CFDP_S_Init(CF_Transaction_t *txn) (unsigned long)txn->history->seq_num, txn->history->fnames.src_filename, (long)OsStatus); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek; + ++chan->stat.counters.fault.file_seek; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_FILESTORE_REJECTION); } } @@ -553,14 +557,14 @@ void CF_CFDP_S_HandleFileRetention(CF_Transaction_t *txn) * the local file deletion policy, either delete directly or move to recycle dir * - If the transfer is not successful or the "keep" flag is true, then do nothing */ - char TempName[CFE_MISSION_MAX_PATH_LEN]; - const char *SubjectFile; - const char *MoveDest; - const CF_ChannelConfig_t *config; - int32 OsStatus; - bool AllowLocalRemove; - - config = &CF_AppData.config_table->chan[txn->chan_num]; + char TempName[CFE_MISSION_MAX_PATH_LEN]; + const char *SubjectFile; + const char *MoveDest; + int32 OsStatus; + bool AllowLocalRemove; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + SubjectFile = txn->history->fnames.src_filename; MoveDest = NULL; AllowLocalRemove = false; @@ -574,8 +578,7 @@ void CF_CFDP_S_HandleFileRetention(CF_Transaction_t *txn) * while making it so the automatic transfer will not re-trigger on the same file. */ if (!txn->flags.tx.cmd_tx) { - MoveDest = - CF_CFDP_GetMoveTarget(CF_AppData.config_table->fail_dir, SubjectFile, TempName, sizeof(TempName)); + MoveDest = CF_CFDP_GetMoveTarget(engine_ptr->config.fail_dir, SubjectFile, TempName, sizeof(TempName)); } } else if (!txn->keep) @@ -597,7 +600,7 @@ void CF_CFDP_S_HandleFileRetention(CF_Transaction_t *txn) if (AllowLocalRemove) { /* Everything checked out, If move directory is defined attempt move */ - MoveDest = CF_CFDP_GetMoveTarget(config->move_dir, SubjectFile, TempName, sizeof(TempName)); + MoveDest = CF_CFDP_GetMoveTarget(chan->config.move_dir, SubjectFile, TempName, sizeof(TempName)); } } @@ -886,6 +889,7 @@ void CF_CFDP_S_CheckState(CF_Transaction_t *txn) void CF_CFDP_S_Tick(CF_Transaction_t *txn) { CF_CFDP_AckTxnStatus_t CurrStatus; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); CurrStatus = CF_CFDP_GetAckTxnStatus(txn); @@ -911,7 +915,7 @@ void CF_CFDP_S_Tick(CF_Transaction_t *txn) "CF S(%lu:%lu): inactivity timer expired", (unsigned long)txn->history->src_eid, (unsigned long)txn->history->seq_num); - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.inactivity_timer; + ++chan->stat.counters.fault.inactivity_timer; CF_CFDP_SetTxnStatus(txn, CF_TxnStatus_INACTIVITY_DETECTED); } diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index c60353fa..4a994b79 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -61,29 +61,30 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool silent) { /* if channel is frozen, do not take message */ - CF_Channel_t *chan = CF_AppData.engine.channels + txn->chan_num; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); bool success = true; CF_Logical_PduBuffer_t *ret; int32 os_status; + CF_Engine_t *engine_ptr = CF_GetEngine(); /* this function should not be called more than once before the message * is sent, so if there's already an outgoing message allocated * then drop and get a new one (not likely) */ ret = NULL; - if (CF_AppData.engine.out.msg) + if (engine_ptr->out.msg) { - CFE_SB_ReleaseMessageBuffer(CF_AppData.engine.out.msg); - CF_AppData.engine.out.msg = NULL; + CFE_SB_ReleaseMessageBuffer(engine_ptr->out.msg); + engine_ptr->out.msg = NULL; } - if (CF_AppData.config_table->chan[txn->chan_num].max_outgoing_messages_per_wakeup - && (chan->outgoing_counter >= CF_AppData.config_table->chan[txn->chan_num].max_outgoing_messages_per_wakeup)) + if (chan->config.max_outgoing_messages_per_wakeup + && (chan->outgoing_counter >= chan->config.max_outgoing_messages_per_wakeup)) { /* no more messages this wakeup allowed */ success = false; } - if (success && !CF_AppData.hk.Payload.channel_hk[txn->chan_num].frozen && !txn->flags.com.suspended) + if (success && !chan->stat.frozen && !txn->flags.com.suspended) { /* first, check if there's room in the pipe for the message we want to build */ if (OS_ObjectIdDefined(chan->sem_id)) @@ -98,11 +99,11 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile /* Allocate message buffer on success */ if (os_status == OS_SUCCESS) { - CF_AppData.engine.out.msg = CFE_SB_AllocateMessageBuffer(offsetof(CF_PduTlmMsg_t, ph) + CF_MAX_PDU_SIZE - + CF_PDU_ENCAPSULATION_EXTRA_TRAILING_BYTES); + engine_ptr->out.msg = CFE_SB_AllocateMessageBuffer(offsetof(CF_PduTlmMsg_t, ph) + CF_MAX_PDU_SIZE + + CF_PDU_ENCAPSULATION_EXTRA_TRAILING_BYTES); } - if (!CF_AppData.engine.out.msg) + if (!engine_ptr->out.msg) { if (!silent && (os_status == OS_SUCCESS)) { @@ -115,14 +116,14 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile if (success) { - CFE_MSG_Init(&CF_AppData.engine.out.msg->Msg, - CFE_SB_ValueToMsgId(CF_AppData.config_table->chan[txn->chan_num].mid_output), + CFE_MSG_Init(&engine_ptr->out.msg->Msg, + CFE_SB_ValueToMsgId(chan->config.mid_output), offsetof(CF_PduTlmMsg_t, ph)); ++chan->outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok to inc this */ /* prepare for encoding - the "tx_pdudata" is what serves as the temporary holding area for content */ - ret = &CF_AppData.engine.out.tx_pdudata; + ret = &engine_ptr->out.tx_pdudata; } } @@ -136,8 +137,8 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile else { /* if returning a buffer, then reset the encoder state to point to the beginning of the encapsulation msg */ - CF_CFDP_EncodeStart(&CF_AppData.engine.out.encode, - CF_AppData.engine.out.msg, + CF_CFDP_EncodeStart(&engine_ptr->out.encode, + engine_ptr->out.msg, ret, offsetof(CF_PduTlmMsg_t, ph), offsetof(CF_PduTlmMsg_t, ph) + CF_MAX_PDU_SIZE); @@ -152,11 +153,12 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile * See description in cf_cfdp_sbintf.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph) +void CF_CFDP_Send(CF_Channel_t *chan, const CF_Logical_PduBuffer_t *ph) { CFE_MSG_Size_t sb_msgsize; + CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Assert(chan_num < CF_NUM_CHANNELS); + CF_Assert(chan); /* now handle the SB encapsulation - this should reflect the * length of the entire message, including encapsulation */ @@ -165,13 +167,13 @@ void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph) sb_msgsize += ph->pdu_header.data_encoded_length; sb_msgsize += CF_PDU_ENCAPSULATION_EXTRA_TRAILING_BYTES; - CFE_MSG_SetSize(&CF_AppData.engine.out.msg->Msg, sb_msgsize); - CFE_MSG_SetMsgTime(&CF_AppData.engine.out.msg->Msg, CFE_TIME_GetTime()); - CFE_SB_TransmitBuffer(CF_AppData.engine.out.msg, true); + CFE_MSG_SetSize(&engine_ptr->out.msg->Msg, sb_msgsize); + CFE_MSG_SetMsgTime(&engine_ptr->out.msg->Msg, CFE_TIME_GetTime()); + CFE_SB_TransmitBuffer(engine_ptr->out.msg, true); - ++CF_AppData.hk.Payload.channel_hk[chan_num].counters.sent.pdu; + ++chan->stat.counters.sent.pdu; - CF_AppData.engine.out.msg = NULL; + engine_ptr->out.msg = NULL; } /*---------------------------------------------------------------- @@ -182,16 +184,16 @@ void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph) *-----------------------------------------------------------------*/ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) { - uint32 count = 0; - int32 status; - const int chan_num = (chan - CF_AppData.engine.channels); - CFE_SB_Buffer_t *bufptr; - CFE_MSG_Size_t msg_size; - CFE_MSG_Type_t msg_type; - + uint32 count = 0; + int32 status; + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); /* for perf log */ + CFE_SB_Buffer_t *bufptr; + CFE_MSG_Size_t msg_size; + CFE_MSG_Type_t msg_type; + CF_Engine_t *engine_ptr = CF_GetEngine(); CF_Logical_PduBuffer_t *ph; - for (; count < CF_AppData.config_table->chan[chan_num].rx_max_messages_per_wakeup; ++count) + for (; count < chan->config.rx_max_messages_per_wakeup; ++count) { bufptr = NULL; msg_size = 0; @@ -202,7 +204,7 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) break; /* no more messages */ } - ph = &CF_AppData.engine.in.rx_pdudata; + ph = &engine_ptr->in.rx_pdudata; CFE_ES_PerfLogEntry(CF_PERF_ID_PDURCVD(chan_num)); CFE_MSG_GetSize(&bufptr->Msg, &msg_size); CFE_MSG_GetType(&bufptr->Msg, &msg_type); @@ -218,11 +220,11 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) } if (msg_type == CFE_MSG_Type_Tlm) { - CF_CFDP_DecodeStart(&CF_AppData.engine.in.decode, bufptr, ph, offsetof(CF_PduTlmMsg_t, ph), msg_size); + CF_CFDP_DecodeStart(&engine_ptr->in.decode, bufptr, ph, offsetof(CF_PduTlmMsg_t, ph), msg_size); } else { - CF_CFDP_DecodeStart(&CF_AppData.engine.in.decode, bufptr, ph, offsetof(CF_PduCmdMsg_t, ph), msg_size); + CF_CFDP_DecodeStart(&engine_ptr->in.decode, bufptr, ph, offsetof(CF_PduCmdMsg_t, ph), msg_size); } /* Identify and dispatch this PDU */ diff --git a/fsw/src/cf_cfdp_sbintf.h b/fsw/src/cf_cfdp_sbintf.h index ac49e710..489b3003 100644 --- a/fsw/src/cf_cfdp_sbintf.h +++ b/fsw/src/cf_cfdp_sbintf.h @@ -91,11 +91,11 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile * @par Assumptions, External Events, and Notes: * The PDU in the output buffer is ready to transmit. * - * @param chan_num Channel number for statistics/accounting purposes + * @param chan CF channel pointer (must not be NULL) * @param ph Pointer to PDU buffer to send * */ -void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph); +void CF_CFDP_Send(CF_Channel_t *chan, const CF_Logical_PduBuffer_t *ph); /************************************************************************/ /** @brief Process received message on channel PDU input pipe. diff --git a/fsw/src/cf_cfdp_types.h b/fsw/src/cf_cfdp_types.h index a10fadcb..01fb0f1e 100644 --- a/fsw/src/cf_cfdp_types.h +++ b/fsw/src/cf_cfdp_types.h @@ -170,12 +170,26 @@ typedef enum CF_TxnStatus_MAX = 24 } CF_TxnStatus_t; +/* + * Forward typedef declarations + * + * These are needed as some of these structures that reference + * each other. Typedefs are created early, then the content + * is defined below. + */ +typedef struct CF_Channel CF_Channel_t; +typedef struct CF_Transaction CF_Transaction_t; +typedef struct CF_History CF_History_t; +typedef struct CF_ChunkWrapper CF_ChunkWrapper_t; +typedef struct CF_Playback CF_Playback_t; +typedef struct CF_Poll CF_Poll_t; + /** * @brief CF History entry * * Records CF app operations for future reference */ -typedef struct CF_History +struct CF_History { CF_TxnFilenames_t fnames; /**< \brief file names associated with this history entry */ CF_CListNode_t cl_node; /**< \brief for connection to a CList */ @@ -184,25 +198,25 @@ typedef struct CF_History CF_EntityId_t src_eid; /**< \brief the source eid of the transaction */ CF_EntityId_t peer_eid; /**< \brief peer_eid is always the "other guy", same src_eid for RX */ CF_TransactionSeq_t seq_num; /**< \brief transaction identifier, stays constant for entire transfer */ -} CF_History_t; +}; /** * @brief Wrapper around a CF_ChunkList_t object * * This allows a CF_ChunkList_t to be stored within a CList data storage structure */ -typedef struct CF_ChunkWrapper +struct CF_ChunkWrapper { CF_ChunkList_t chunks; CF_CListNode_t cl_node; -} CF_ChunkWrapper_t; +}; /** * @brief CF Playback entry * * Keeps the state of CF playback requests */ -typedef struct CF_Playback +struct CF_Playback { osal_id_t dir_id; CF_CFDP_Class_t cfdp_class; @@ -216,19 +230,19 @@ typedef struct CF_Playback bool diropen; bool keep; bool counted; -} CF_Playback_t; +}; /** * @brief CF Poll entry * * Keeps the state of CF directory polling */ -typedef struct CF_Poll +struct CF_Poll { CF_Playback_t pb; CF_Timer_t interval_timer; bool timer_set; -} CF_Poll_t; +}; /** * @brief Data that applies to all types of transactions @@ -317,12 +331,13 @@ typedef struct CF_StateData * * This keeps the state of CF file transactions */ -typedef struct CF_Transaction +struct CF_Transaction { CF_TxnState_t state; /**< \brief each engine is commanded to do something, which is the overall state */ CF_History_t *history; /**< \brief weird, holds active filenames and possibly other info */ CF_ChunkWrapper_t *chunks; /**< \brief for gap tracking, only used on class 2 */ + CF_Channel_t *chan_ptr; /**< \brief reference to the CF channel for this transaction */ CF_Timer_t inactivity_timer; /**< \brief set to the overall inactivity timer of a remote */ CF_Timer_t ack_timer; /**< \brief called ack_timer, but is also nak_timer */ @@ -334,7 +349,6 @@ typedef struct CF_Transaction bool reliable_mode; /**< Set true if class 2, false in class 1 */ uint8 keep; - uint8 chan_num; /**< \brief if ever more than one engine, this may need to change to pointer */ uint8 priority; CF_CListNode_t cl_node; @@ -352,7 +366,7 @@ typedef struct CF_Transaction * Please ignore the duplicate declarations of the "all" flags. */ CF_StateFlags_t flags; -} CF_Transaction_t; +}; /** * @brief Identifies the type of timer tick being processed @@ -369,6 +383,67 @@ typedef enum CF_TickState_NUM_TYPES } CF_TickState_t; +/** + * \brief Configuration entry for directory polling + * + * This is a mirror of what came from the configuration table, stored locally in the app global + */ +typedef struct CF_LocalPdConfig +{ + bool enabled; /**< \brief Enabled flag */ + uint8 priority; /**< \brief priority to use when placing transactions on the pending queue */ + + uint32 interval_sec; /**< \brief number of seconds to wait before trying a new directory */ + + CF_CFDP_Class_t cfdp_class; /**< \brief the CFDP class to send */ + CF_EntityId_t dest_eid; /**< \brief destination entity id */ + + char src_dir[OS_MAX_PATH_LEN]; /**< \brief path to source dir */ + char dst_dir[OS_MAX_PATH_LEN]; /**< \brief path to destination dir */ + +} CF_LocalPdConfig_t; + +/** + * \brief Configuration entry for channel config + * + * This is a mirror of what came from the configuration table, stored locally in the app global + */ +typedef struct CF_LocalChanConfig +{ + uint32 max_outgoing_messages_per_wakeup; /**< \brief max number of messages to send per wakeup (0 - unlimited) */ + uint32 rx_max_messages_per_wakeup; /**< \brief max number of rx messages to process per wakeup */ + + uint32 ack_timer_s; /**< \brief Acknowledge timer in seconds */ + uint32 nak_timer_s; /**< \brief Non-acknowledge timer in seconds */ + uint32 inactivity_timer_s; /**< \brief Inactivity timer in seconds */ + + bool dequeue_enabled; /**< \brief if 1, then the channel will make pending transactions active */ + uint8 ack_limit; /**< number of times to retry ACK (for ex, send FIN and wait for fin-ack) */ + uint8 nak_limit; /**< number of times to retry NAK before giving up (resets on a single response */ + + CFE_SB_MsgId_Atom_t mid_input; /**< \brief msgid integer value for incoming messages */ + CFE_SB_MsgId_Atom_t mid_output; /**< \brief msgid integer value for outgoing messages */ + + uint16 pipe_depth_input; /**< \brief depth of pipe to receive incoming PDU */ + + CF_LocalPdConfig_t polldir[CF_MAX_POLLING_DIR_PER_CHAN]; /**< \brief Configuration for polled directories */ + + char sem_name[OS_MAX_API_NAME]; /**< \brief name of throttling semaphore in TO */ + char move_dir[OS_MAX_PATH_LEN]; /**< \brief Move directory if not empty */ +} CF_LocalChanConfig_t; + +/** + * \brief Housekeeping channel data + */ +typedef struct CF_LocalChanStat +{ + CF_HkCounters_t counters; /**< \brief Counters */ + uint16 q_size[CF_QueueIdx_NUM]; /**< \brief Queue sizes */ + uint8 poll_counter; /**< \brief Number of active polling directories */ + uint8 playback_counter; /**< \brief Number of active playback directories */ + bool frozen; /**< \brief Frozen state: 0 == not frozen, else frozen */ +} CF_LocalChanStat_t; + /** * @brief Channel state object * @@ -378,7 +453,7 @@ typedef enum * and poll state, as well as separate addresses on the underlying message * transport (e.g. SB). */ -typedef struct CF_Channel +struct CF_Channel { CF_CListNode_t *qs[CF_QueueIdx_NUM]; CF_CListNode_t *cs[CF_Direction_NUM]; @@ -405,7 +480,9 @@ typedef struct CF_Channel bool tx_blocked; /**< Set true if PDU transmission was blocked due to limits */ -} CF_Channel_t; + CF_LocalChanConfig_t config; + CF_LocalChanStat_t stat; +}; /** * @brief CF engine output state @@ -431,6 +508,21 @@ typedef struct CF_Input CF_Logical_PduBuffer_t rx_pdudata; /**< \brief Rx PDU logical values */ } CF_Input_t; +typedef struct CF_EngineConfig +{ + uint32 ticks_per_second; /**< \brief expected ticks per second to CFDP app */ + uint32 rx_crc_calc_bytes_per_wakeup; /**< \brief max number of bytes per wakeup to calculate + * r2 CRC for recvd file (must be 1024-byte aligned) + */ + + CF_EntityId_t local_eid; /**< \brief the local entity ID of the CF app */ + + uint16 outgoing_file_chunk_size; /**< \brief maximum size of outgoing file data chunk in a PDU. + * Limited by CF_MAX_PDU_SIZE minus the PDU header(s) */ + char tmp_dir[OS_MAX_PATH_LEN]; /**< \brief directory to put temp files */ + char fail_dir[OS_MAX_PATH_LEN]; /**< \brief fail directory */ +} CF_EngineConfig_t; + /** * @brief An engine represents a pairing to a local EID * @@ -443,6 +535,8 @@ typedef struct CF_Engine CF_Output_t out; CF_Input_t in; + CF_EngineConfig_t config; + /* NOTE: could have separate array of transactions as part of channel? */ CF_Transaction_t transactions[CF_NUM_TRANSACTIONS]; CF_History_t histories[CF_NUM_HISTORIES]; diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index da2b7308..742bee87 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -39,6 +39,66 @@ #include +/* Helper struct for CF_DoChanAction() */ +typedef struct CF_ChanActionContext +{ + CF_ChanAction_Status_t ret; + CF_ChanActionFn_t fn; + void *context; +} CF_ChanActionContext_t; + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with CF_ForEachChannel() + * Resets fault counters + * + *-----------------------------------------------------------------*/ +static int32 CF_DoResetFaultCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + memset(&chan->stat.counters.fault, 0, sizeof(chan->stat.counters.fault)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with CF_ForEachChannel() + * Resets up counters + * + *-----------------------------------------------------------------*/ +static int32 CF_DoResetUpCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + memset(&chan->stat.counters.recv, 0, sizeof(chan->stat.counters.recv)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with CF_ForEachChannel() + * Resets down counters + * + *-----------------------------------------------------------------*/ +static int32 CF_DoResetDownCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + memset(&chan->stat.counters.sent, 0, sizeof(chan->stat.counters.sent)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Invokes the requested action on a single channel + * compatible with CF_ForEachChannel() + * + *-----------------------------------------------------------------*/ +static int32 CF_DoSingleChannelAction(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + CF_ChanActionContext_t *ctxt = arg; + + ctxt->ret |= ctxt->fn(chan, ctxt->context); + + return CFE_SUCCESS; +} + /*---------------------------------------------------------------- * * Application-scope internal function @@ -55,7 +115,7 @@ CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg) CF_REVISION, CF_MISSION_REV); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; return CFE_SUCCESS; } @@ -68,69 +128,59 @@ CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_ResetCountersCmd(const CF_ResetCountersCmd_t *msg) { - const CF_UnionArgs_Payload_t *data = &msg->Payload; - static const char *names[5] = { "all", "cmd", "fault", "up", "down" }; + const CF_ResetCountersCmd_Payload_t *data = &msg->Payload; + static const char *names[5] = { "all", "cmd", "fault", "up", "down" }; /* 0=all, 1=cmd, 2=fault 3=up 4=down */ - uint8 param = data->byte[0]; - int i; - bool acc = true; + bool acc = true; + CF_Engine_t *engine_ptr = CF_GetEngine(); - if (param > 4) + if (data->ResetType > 4) { CFE_EVS_SendEvent(CF_CMD_RESET_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, "CF: Received RESET COUNTERS command with invalid parameter %d", - param); - ++CF_AppData.hk.Payload.counters.err; + (int)data->ResetType); + ++CF_AppData.counters.err; } else { CFE_EVS_SendEvent(CF_RESET_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: Received RESET COUNTERS command: %s", - names[param]); + names[data->ResetType]); /* if the param is CF_Reset_command, or all counters */ - if ((param == CF_Reset_all) || (param == CF_Reset_command)) + if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_command)) { /* command counters */ - memset(&CF_AppData.hk.Payload.counters, 0, sizeof(CF_AppData.hk.Payload.counters)); + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); acc = false; /* don't increment accept counter on command counter reset */ } /* if the param is CF_Reset_fault, or all counters */ - if ((param == CF_Reset_all) || (param == CF_Reset_fault)) + if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_fault)) { /* fault counters */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) - memset(&CF_AppData.hk.Payload.channel_hk[i].counters.fault, - 0, - sizeof(CF_AppData.hk.Payload.channel_hk[i].counters.fault)); + CF_ForEachChannel(engine_ptr, CF_DoResetFaultCount, NULL); } /* if the param is CF_Reset_up, or all counters */ - if ((param == CF_Reset_all) || (param == CF_Reset_up)) + if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_up)) { /* up counters */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) - memset(&CF_AppData.hk.Payload.channel_hk[i].counters.recv, - 0, - sizeof(CF_AppData.hk.Payload.channel_hk[i].counters.recv)); + CF_ForEachChannel(engine_ptr, CF_DoResetUpCount, NULL); } /* if the param is CF_Reset_down, or all counters */ - if ((param == CF_Reset_all) || (param == CF_Reset_down)) + if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_down)) { /* down counters */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) - memset(&CF_AppData.hk.Payload.channel_hk[i].counters.sent, - 0, - sizeof(CF_AppData.hk.Payload.channel_hk[i].counters.sent)); + CF_ForEachChannel(engine_ptr, CF_DoResetDownCount, NULL); } if (acc) { - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } } @@ -145,46 +195,41 @@ CFE_Status_t CF_ResetCountersCmd(const CF_ResetCountersCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) { - const CF_TxFile_Payload_t *tx = &msg->Payload; + const CF_TxFile_Payload_t *tx = &msg->Payload; + CF_Channel_t *chan = CF_GetChannelPtr(tx->chan_num); + CFE_Status_t ret; /* * This needs to validate all its inputs. * "keep" should only be 0 or 1 (logical true/false). * For priority and dest_id params, anything is acceptable. */ - if ((tx->cfdp_class != CF_CFDP_CLASS_1 && tx->cfdp_class != CF_CFDP_CLASS_2) || tx->chan_num >= CF_NUM_CHANNELS - || (int)tx->keep > 1) + if (chan == NULL || !CF_IsValidClass(tx->cfdp_class) || (int)tx->keep > 1) { CFE_EVS_SendEvent(CF_CMD_BAD_PARAM_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: bad parameter in CF_TxFileCmd(): chan=%u, class=%u keep=%u", - (unsigned int)tx->chan_num, + "CF: bad parameter in CF_TxFileCmd(): chan=%d, class=%u keep=%u", + CF_ChannelSelect_AsInt(tx->chan_num), (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ return CFE_SUCCESS; } - if (CF_CFDP_TxFile(tx->src_filename, - tx->dst_filename, - tx->cfdp_class, - tx->keep, - tx->chan_num, - tx->priority, - tx->dest_id) - == CFE_SUCCESS) + ret = CF_CFDP_TxFile(tx->src_filename, tx->dst_filename, tx->cfdp_class, tx->keep, chan, tx->priority, tx->dest_id); + if (ret == CFE_SUCCESS) { CFE_EVS_SendEvent(CF_CMD_TX_FILE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: file transfer successfully initiated"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_TX_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: file transfer initiation failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -198,48 +243,49 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) { - const CF_TxFile_Payload_t *tx = &msg->Payload; + const CF_TxFile_Payload_t *tx = &msg->Payload; + CF_Channel_t *chan = CF_GetChannelPtr(tx->chan_num); + CFE_Status_t ret; /* * This needs to validate all its inputs. * "keep" should only be 0 or 1 (logical true/false). * For priority and dest_id params, anything is acceptable. */ - if ((tx->cfdp_class != CF_CFDP_CLASS_1 && tx->cfdp_class != CF_CFDP_CLASS_2) || tx->chan_num >= CF_NUM_CHANNELS - || (int)tx->keep > 1) + if (chan == NULL || !CF_IsValidClass(tx->cfdp_class) || (int)tx->keep > 1) { CFE_EVS_SendEvent(CF_CMD_BAD_PARAM_ERR_EID, CFE_EVS_EventType_ERROR, "CF: bad parameter in CF_PlaybackDirCmd(): chan=%u, class=%u keep=%u", - (unsigned int)tx->chan_num, + CF_ChannelSelect_AsInt(tx->chan_num), (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ return CFE_SUCCESS; } - if (CF_CFDP_PlaybackDir(tx->src_filename, - tx->dst_filename, - tx->cfdp_class, - tx->keep, - tx->chan_num, - tx->priority, - tx->dest_id) - == CFE_SUCCESS) + ret = CF_CFDP_PlaybackDir(tx->src_filename, + tx->dst_filename, + tx->cfdp_class, + tx->keep, + chan, + tx->priority, + tx->dest_id); + if (ret == CFE_SUCCESS) { CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: directory playback initiation successful"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_ERR_EID, CFE_EVS_EventType_ERROR, "CF: directory playback initiation failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -252,23 +298,26 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) * *-----------------------------------------------------------------*/ CF_ChanAction_Status_t -CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanActionFn_t fn, void *context) +CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context) { - int i; - CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_ChanActionContext_t local_ctxt; + + memset(&local_ctxt, 0, sizeof(local_ctxt)); + local_ctxt.fn = fn; + local_ctxt.context = context; /* this function is generic for any ground command that takes a single channel * argument which must be less than CF_NUM_CHANNELS or 255 which is a special * value that means apply command to all channels */ - if (data->byte[0] == CF_ALL_CHANNELS) + if (CF_IsAllChannels(chan_select)) { /* apply to all channels */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) - ret |= fn(i, context); + CF_ForEachChannel(engine_ptr, CF_DoSingleChannelAction, &local_ctxt); } - else if (data->byte[0] < CF_NUM_CHANNELS) + else if (CF_IsValidChannel(chan_select)) { - ret = fn(data->byte[0], context); + CF_DoSingleChannelAction(engine_ptr, CF_GetChannelPtr(chan_select), &local_ctxt); } else { @@ -277,11 +326,11 @@ CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanA CFE_EVS_EventType_ERROR, "CF: %s: channel parameter out of range. received %d", errstr, - data->byte[0]); - ret = CF_ChanAction_Status_ERROR; + CF_ChannelSelect_AsInt(chan_select)); + local_ctxt.ret = CF_ChanAction_Status_ERROR; } - return ret; + return local_ctxt.ret; } /*---------------------------------------------------------------- @@ -290,11 +339,12 @@ CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanA * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoFreezeThaw(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg) { - const CF_ChanAction_BoolArg_t *context = arg; + const CF_ChanAction_BoolArg_t *context = arg; + /* no need to bounds check chan_num, done in caller */ - CF_AppData.hk.Payload.channel_hk[chan_num].frozen = context->barg; + chan->stat.frozen = context->barg; return CF_ChanAction_Status_SUCCESS; } @@ -308,15 +358,15 @@ CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) { CF_ChanAction_BoolArg_t barg = { 1 }; /* param is frozen, so 1 means freeze */ - if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(&msg->Payload, "freeze", CF_DoFreezeThaw, &barg))) + if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(msg->Payload.ChannelSelect, "freeze", CF_DoFreezeThaw, &barg))) { CFE_EVS_SendEvent(CF_CMD_FREEZE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: freeze successful"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_FREEZE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: freeze cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -332,15 +382,15 @@ CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) { CF_ChanAction_BoolArg_t barg = { 0 }; /* param is frozen, so 0 means thawed */ - if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(&msg->Payload, "thaw", CF_DoFreezeThaw, &barg))) + if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(msg->Payload.ChannelSelect, "thaw", CF_DoFreezeThaw, &barg))) { CFE_EVS_SendEvent(CF_CMD_THAW_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: thaw successful"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_THAW_ERR_EID, CFE_EVS_EventType_ERROR, "CF: thaw cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -364,7 +414,9 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSe * to suspend, we need to search across all channels for it. */ for (i = 0; i < CF_NUM_CHANNELS; ++i) { - ret = CF_FindTransactionBySequenceNumber(CF_AppData.engine.channels + i, ts, eid); + CF_Channel_t *chan = CF_GetChannelPtr(CF_ChannelSelect_FromInt(i)); + + ret = CF_FindTransactionBySequenceNumber(chan, ts, eid); if (ret) { break; @@ -386,9 +438,10 @@ int32 CF_TsnChanAction(const CF_Transaction_Payload_t *data, void *context) { CF_Transaction_t *txn; + CF_Channel_t *chan; int32 ret = -1; - if (data->chan == CF_COMPOUND_KEY) + if (CF_IsCompoundKey(data->chan_num)) { /* special value 254 means to use the compound key (data->eid, data->ts) to find the transaction * to act upon */ @@ -408,23 +461,27 @@ int32 CF_TsnChanAction(const CF_Transaction_Payload_t *data, (unsigned long)data->ts); } } - else if (data->chan == CF_ALL_CHANNELS) + else if (CF_IsAllChannels(data->chan_num)) { /* perform action on all channels, all transactions */ ret = CF_TraverseAllTransactions_All_Channels(fn, context); } - else if (data->chan < CF_NUM_CHANNELS) - { - /* perform action on a specific channel, all transactions */ - ret = CF_TraverseAllTransactions(CF_AppData.engine.channels + data->chan, fn, context); - } else { - CFE_EVS_SendEvent(CF_CMD_TSN_CHAN_INVALID_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: %s cmd: invalid channel %d", - cmdstr, - data->chan); + chan = CF_GetChannelPtr(data->chan_num); + if (chan != NULL) + { + /* perform action on a specific channel, all transactions */ + ret = CF_TraverseAllTransactions(chan, fn, context); + } + else + { + CFE_EVS_SendEvent(CF_CMD_TSN_CHAN_INVALID_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: %s cmd: invalid channel %d", + cmdstr, + CF_ChannelSelect_AsInt(data->chan_num)); + } } return ret; @@ -476,7 +533,7 @@ void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) "CF: %s cmd: setting suspend flag to current value of %d", msgstr[action], action); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else if (ret <= 0) { @@ -485,7 +542,7 @@ void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) CFE_EVS_EventType_ERROR, "CF: %s cmd: no transaction found", msgstr[action]); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } else { @@ -494,7 +551,7 @@ void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) "CF: %s cmd: setting suspend flag to %d", msgstr[action], action); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } } @@ -546,13 +603,13 @@ CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) CFE_EVS_SendEvent(CF_CMD_CANCEL_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: cancel transaction successfully initiated"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { /* No transaction was matched for the given combination of chan + eid + ts */ CFE_EVS_SendEvent(CF_CMD_CANCEL_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: cancel cmd: no transaction found"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -580,7 +637,7 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) if (CF_TsnChanAction(&msg->Payload, "abandon", CF_Abandon_TxnCmd, NULL) > 0) { CFE_EVS_SendEvent(CF_CMD_ABANDON_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: abandon successful"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { @@ -588,7 +645,7 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) CFE_EVS_SendEvent(CF_CMD_ABANDON_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: abandon cmd: no transaction found"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -600,11 +657,12 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg) { - const CF_ChanAction_BoolArg_t *context = arg; + const CF_ChanAction_BoolArg_t *context = arg; + /* no need to bounds check chan_num, done in caller */ - CF_AppData.config_table->chan[chan_num].dequeue_enabled = context->barg; + chan->config.dequeue_enabled = context->barg; return CF_ChanAction_Status_SUCCESS; } @@ -619,15 +677,15 @@ CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) CF_ChanAction_BoolArg_t barg = { 1 }; if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(&msg->Payload, "enable_dequeue", CF_DoEnableDisableDequeue, &barg))) + CF_DoChanAction(msg->Payload.ChannelSelect, "enable_dequeue", CF_DoEnableDisableDequeue, &barg))) { CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue enabled"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: enable dequeue cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -644,15 +702,15 @@ CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) CF_ChanAction_BoolArg_t barg = { 0 }; if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(&msg->Payload, "disable_dequeue", CF_DoEnableDisableDequeue, &barg))) + CF_DoChanAction(msg->Payload.ChannelSelect, "disable_dequeue", CF_DoEnableDisableDequeue, &barg))) { CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue disabled"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: disable dequeue cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -664,29 +722,35 @@ CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg) { int i; - const CF_ChanAction_BoolMsgArg_t *context = arg; - CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; + const CF_ChanAction_BoolMsgArg_t *context; + const CF_PollDirSelect_Payload_t *payload; + CF_ChanAction_Status_t ret; + + context = arg; + payload = context->opaque_data; + ret = CF_ChanAction_Status_SUCCESS; + /* no need to bounds check chan_num, done in caller */ - if (context->data->byte[1] == CF_ALL_POLLDIRS) + if (payload->PollDirIndx == CF_ALL_POLLDIRS) { /* all polldirs in channel */ for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) - CF_AppData.config_table->chan[chan_num].polldir[i].enabled = context->barg; + chan->config.polldir[i].enabled = context->barg; } - else if (context->data->byte[1] < CF_MAX_POLLING_DIR_PER_CHAN) + else if (payload->PollDirIndx < CF_MAX_POLLING_DIR_PER_CHAN) { - CF_AppData.config_table->chan[chan_num].polldir[context->data->byte[1]].enabled = context->barg; + chan->config.polldir[payload->PollDirIndx].enabled = context->barg; } else { CFE_EVS_SendEvent(CF_CMD_POLLDIR_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, "CF: enable/disable polldir: invalid polldir %d on channel %d", - context->data->byte[1], - chan_num); + (int)payload->PollDirIndx, + CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan))); ret = CF_ChanAction_Status_ERROR; } @@ -704,19 +768,19 @@ CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg) CF_ChanAction_BoolMsgArg_t barg = { &msg->Payload, 1 }; if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(&msg->Payload, "enable_polldir", CF_DoEnableDisablePolldir, &barg))) + CF_DoChanAction(msg->Payload.ChannelSelect, "enable_polldir", CF_DoEnableDisablePolldir, &barg))) { CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: enabled polling directory"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_ERR_EID, CFE_EVS_EventType_ERROR, "CF: enable polling directory cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -733,19 +797,19 @@ CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg) CF_ChanAction_BoolMsgArg_t barg = { &msg->Payload, 0 }; if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(&msg->Payload, "disable_polldir", CF_DoEnableDisablePolldir, &barg))) + CF_DoChanAction(msg->Payload.ChannelSelect, "disable_polldir", CF_DoEnableDisablePolldir, &barg))) { CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: disabled polling directory"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_ERR_EID, CFE_EVS_EventType_ERROR, "CF: disable polling directory cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -784,27 +848,30 @@ CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignore * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg) { - CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; - /* no need to bounds check chan_num, done in caller */ - CF_Channel_t *chan = &CF_AppData.engine.channels[chan_num]; - const CF_UnionArgs_Payload_t *data = ((CF_ChanAction_MsgArg_t *)arg)->data; + CF_ChanAction_Status_t ret; + const CF_ChanAction_MsgArg_t *context; + const CF_QueueSelect_Payload_t *payload; bool pend = false; bool hist = false; - switch (data->byte[1]) + context = arg; + payload = context->opaque_data; + ret = CF_ChanAction_Status_SUCCESS; + + switch (payload->QueueSelect) { - case 0: /* pend */ + case CF_QueueSelect_Pending: pend = true; break; - case 1: /* history */ + case CF_QueueSelect_History: hist = true; break; - case 2: /* both */ + case CF_QueueSelect_All: pend = true; hist = true; break; @@ -813,7 +880,7 @@ CF_ChanAction_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg) CFE_EVS_SendEvent(CF_CMD_PURGE_ARG_ERR_EID, CFE_EVS_EventType_ERROR, "CF: purge queue invalid arg %d", - data->byte[1]); + (int)payload->QueueSelect); ret = CF_ChanAction_Status_ERROR; break; } @@ -840,15 +907,19 @@ CF_ChanAction_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg) CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) { CF_ChanAction_MsgArg_t arg = { &msg->Payload }; - if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(&msg->Payload, "purge_queue", CF_DoPurgeQueue, &arg))) + CF_ChanAction_Status_t status; + + status = CF_DoChanAction(msg->Payload.ChannelSelect, "purge_queue", CF_DoPurgeQueue, &arg); + + if (CF_ChanAction_Status_IS_SUCCESS(status)) { CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: queue purged"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: purge queue cmd failed"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } return CFE_SUCCESS; @@ -864,25 +935,25 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) { const CF_WriteQueue_Payload_t *wq = &msg->Payload; - CF_Channel_t *chan = &CF_AppData.engine.channels[wq->chan]; + CF_Channel_t *chan = CF_GetChannelPtr(wq->chan); osal_id_t fd = OS_OBJECT_ID_UNDEFINED; bool success = true; int32 ret; /* check the commands for validity */ - if (wq->chan >= CF_NUM_CHANNELS) + if (chan == NULL) { CFE_EVS_SendEvent(CF_CMD_WQ_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: write queue invalid channel arg"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } /* only invalid combination is up direction, pending queue */ - else if ((wq->type == CF_Type_up) && (wq->queue == CF_Queue_pend)) + else if ((wq->type == CF_Type_up) && (wq->queue == CF_QueueSelect_Pending)) { CFE_EVS_SendEvent(CF_CMD_WQ_ARGS_ERR_EID, CFE_EVS_EventType_ERROR, "CF: write queue invalid command parameters"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } else @@ -896,7 +967,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to open file %s", wq->filename); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } @@ -905,7 +976,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) if (success && ((wq->type == CF_Type_all) || (wq->type == CF_Type_up))) { /* process uplink queue data */ - if ((wq->queue == CF_Queue_all) || (wq->queue == CF_Queue_active)) + if ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Active)) { ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_RX); if (ret) @@ -914,12 +985,12 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to write CF_QueueIdx_RX data"); CF_WrappedClose(fd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } - if (success && ((wq->queue == CF_Queue_all) || (wq->queue == CF_Queue_history))) + if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_History))) { ret = CF_WriteHistoryQueueDataToFile(fd, chan, CF_Direction_RX); if (ret) @@ -928,7 +999,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to write history RX data"); CF_WrappedClose(fd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } @@ -938,7 +1009,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) if (success && ((wq->type == CF_Type_all) || (wq->type == CF_Type_down))) { /* process downlink queue data */ - if ((wq->queue == CF_Queue_all) || (wq->queue == CF_Queue_active)) + if ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Active)) { ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_TX); if (ret) @@ -947,12 +1018,12 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to write CF_QueueIdx_TX data"); CF_WrappedClose(fd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } - if (success && ((wq->queue == CF_Queue_all) || (wq->queue == CF_Queue_pend))) + if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Pending))) { /* write pending queue */ ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_PEND); @@ -962,12 +1033,12 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to write pending queue"); CF_WrappedClose(fd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } - if (success && ((wq->queue == CF_Queue_all) || (wq->queue == CF_Queue_history))) + if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_History))) { /* write history queue */ ret = CF_WriteHistoryQueueDataToFile(fd, chan, CF_Direction_TX); @@ -977,7 +1048,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) CFE_EVS_EventType_ERROR, "CF: write queue failed to write CF_QueueIdx_TX data"); CF_WrappedClose(fd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; success = false; } } @@ -986,7 +1057,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) if (success) { CFE_EVS_SendEvent(CF_CMD_WQ_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: write queue successful"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } return CFE_SUCCESS; @@ -998,7 +1069,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_num /* ignored */) +CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan /* ignored */) { CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; if (val > sizeof(CF_CFDP_PduFileDataContent_t)) @@ -1014,11 +1085,11 @@ CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_nu * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, uint8 chan_num) +CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) { CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; - if (!val && !CF_AppData.config_table->chan[chan_num].sem_name[0]) + if (!val && !chan->config.sem_name[0]) { /* can't have unlimited messages and no semaphore */ ret = CF_ChanAction_Status_ERROR; /* failed */ @@ -1033,64 +1104,75 @@ CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, uint8 chan_num) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num) +void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num) { - CF_ConfigTable_t *config; - CFE_Status_t status = CF_ERROR; - bool valid_set; + CFE_Status_t status = CF_ERROR; + bool valid_set; struct { void *ptr; size_t size; - CF_ChanAction_Status_t (*fn)(uint32, uint8 chan_num); + CF_ChanAction_Status_t (*fn)(uint32, CF_Channel_t *); } item; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + + if (chan == NULL) + { + CFE_EVS_SendEvent(CF_CMD_GETSET_CHAN_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: invalid configuration channel id %d received", + CF_ChannelSelect_AsInt(chan_num)); + ++CF_AppData.counters.err; + return; + } + valid_set = false; - config = CF_AppData.config_table; memset(&item, 0, sizeof(item)); switch (param_id) { case CF_GetSet_ValueID_ticks_per_second: - item.ptr = &config->ticks_per_second; - item.size = sizeof(config->ticks_per_second); + item.ptr = &engine_ptr->config.ticks_per_second; + item.size = sizeof(engine_ptr->config.ticks_per_second); break; case CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup: - item.ptr = &config->rx_crc_calc_bytes_per_wakeup; - item.size = sizeof(config->rx_crc_calc_bytes_per_wakeup); + item.ptr = &engine_ptr->config.rx_crc_calc_bytes_per_wakeup; + item.size = sizeof(engine_ptr->config.rx_crc_calc_bytes_per_wakeup); break; case CF_GetSet_ValueID_ack_timer_s: - item.ptr = &config->chan[chan_num].ack_timer_s; - item.size = sizeof(config->chan[chan_num].ack_timer_s); + item.ptr = &chan->config.ack_timer_s; + item.size = sizeof(chan->config.ack_timer_s); break; case CF_GetSet_ValueID_nak_timer_s: - item.ptr = &config->chan[chan_num].nak_timer_s; - item.size = sizeof(config->chan[chan_num].nak_timer_s); + item.ptr = &chan->config.nak_timer_s; + item.size = sizeof(chan->config.nak_timer_s); break; case CF_GetSet_ValueID_inactivity_timer_s: - item.ptr = &config->chan[chan_num].inactivity_timer_s; - item.size = sizeof(config->chan[chan_num].inactivity_timer_s); + item.ptr = &chan->config.inactivity_timer_s; + item.size = sizeof(chan->config.inactivity_timer_s); break; case CF_GetSet_ValueID_outgoing_file_chunk_size: - item.ptr = &config->outgoing_file_chunk_size; - item.size = sizeof(config->outgoing_file_chunk_size); + item.ptr = &engine_ptr->config.outgoing_file_chunk_size; + item.size = sizeof(engine_ptr->config.outgoing_file_chunk_size); item.fn = CF_ValidateChunkSizeCmd; break; case CF_GetSet_ValueID_ack_limit: - item.ptr = &config->chan[chan_num].ack_limit; - item.size = sizeof(config->chan[chan_num].ack_limit); + item.ptr = &chan->config.ack_limit; + item.size = sizeof(chan->config.ack_limit); break; case CF_GetSet_ValueID_nak_limit: - item.ptr = &config->chan[chan_num].nak_limit; - item.size = sizeof(config->chan[chan_num].nak_limit); + item.ptr = &chan->config.nak_limit; + item.size = sizeof(chan->config.nak_limit); break; case CF_GetSet_ValueID_local_eid: - item.ptr = &config->local_eid; - item.size = sizeof(config->local_eid); + item.ptr = &engine_ptr->config.local_eid; + item.size = sizeof(engine_ptr->config.local_eid); break; case CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup: - item.ptr = &config->chan[chan_num].max_outgoing_messages_per_wakeup; - item.size = sizeof(config->chan[chan_num].max_outgoing_messages_per_wakeup); + item.ptr = &chan->config.max_outgoing_messages_per_wakeup; + item.size = sizeof(chan->config.max_outgoing_messages_per_wakeup); item.fn = CF_ValidateMaxOutgoingCmd; break; default: @@ -1104,18 +1186,11 @@ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, "CF: invalid configuration parameter id %d received", param_id); } - else if (chan_num >= CF_NUM_CHANNELS) - { - CFE_EVS_SendEvent(CF_CMD_GETSET_CHAN_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: invalid configuration channel id %d received", - chan_num); - } else if (is_set) { if (item.fn) { - if (CF_ChanAction_Status_IS_SUCCESS(item.fn(value, chan_num))) + if (CF_ChanAction_Status_IS_SUCCESS(item.fn(value, chan))) { valid_set = true; } @@ -1186,11 +1261,11 @@ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, if (status == CFE_SUCCESS) { - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } } @@ -1232,19 +1307,21 @@ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) { - if (!CF_AppData.engine.enabled) + CF_Engine_t *engine_ptr = CF_GetEngine(); + + if (!engine_ptr->enabled) { - if (CF_CFDP_InitEngine() == CFE_SUCCESS) + if (CF_CFDP_InitEngine(engine_ptr) == CFE_SUCCESS) { CFE_EVS_SendEvent(CF_CMD_ENABLE_ENGINE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: enabled CFDP engine"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } else { CFE_EVS_SendEvent(CF_CMD_ENABLE_ENGINE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: failed to re-initialize and enable CFDP engine"); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } } else @@ -1252,7 +1329,7 @@ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) CFE_EVS_SendEvent(CF_CMD_ENG_ALREADY_ENA_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: received enable engine command while engine already enabled"); - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; } return CFE_SUCCESS; @@ -1266,7 +1343,9 @@ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) { - if (CF_AppData.engine.enabled) + CF_Engine_t *engine_ptr = CF_GetEngine(); + + if (engine_ptr->enabled) { CF_CFDP_DisableEngine(); CFE_EVS_SendEvent(CF_CMD_DISABLE_ENGINE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: disabled CFDP engine"); @@ -1278,7 +1357,35 @@ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) "CF: received disable engine command while engine already disabled"); } - ++CF_AppData.hk.Payload.counters.cmd; + ++CF_AppData.counters.cmd; + + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Obtains HK stats for a single channel within the CFDP engine + * Compatible with CF_ForEachChannel() + * + *-----------------------------------------------------------------*/ +static int32 CF_DoHkStats(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + CF_HkChannel_Data_t *out_chan_hk; + CF_HkPacket_t *hk = arg; + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); + int q_idx; + + out_chan_hk = &hk->Payload.channel_hk[chan_num]; + + out_chan_hk->counters = chan->stat.counters; + for (q_idx = 0; q_idx < CF_QueueIdx_NUM; ++q_idx) + { + out_chan_hk->q_size[q_idx] = chan->stat.q_size[q_idx]; + } + out_chan_hk->poll_counter = chan->stat.poll_counter; + out_chan_hk->playback_counter = chan->stat.playback_counter; + out_chan_hk->frozen = chan->stat.frozen; return CFE_SUCCESS; } @@ -1291,11 +1398,23 @@ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) *-----------------------------------------------------------------*/ CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) { - CFE_SB_TimeStampMsg(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader)); - /* return value ignored */ CFE_SB_TransmitMsg(CFE_MSG_PTR(CF_AppData.hk.TelemetryHeader), true); + CF_Engine_t *engine_ptr = CF_GetEngine(); + CFE_SB_Buffer_t *sb_buf; + CF_HkPacket_t *hk; - /* This is also used to check tables */ - CF_CheckTables(); + sb_buf = CFE_SB_AllocateMessageBuffer(sizeof(*hk)); + if (sb_buf) + { + CFE_MSG_Init(&sb_buf->Msg, CFE_SB_ValueToMsgId(CF_HK_TLM_MID), sizeof(*hk)); + + hk = (void *)&sb_buf->Msg; + hk->Payload.counters = CF_AppData.counters; + + CF_ForEachChannel(engine_ptr, CF_DoHkStats, hk); + + /* return value ignored */ + CFE_SB_TransmitBuffer(sb_buf, true); + } return CFE_SUCCESS; } @@ -1312,5 +1431,8 @@ CFE_Status_t CF_WakeupCmd(const CF_WakeupCmd_t *msg) CF_CFDP_CycleEngine(); CFE_ES_PerfLogExit(CF_PERF_ID_CYCLE_ENG); + /* This is also used to check tables */ + CF_CheckTables(); + return CFE_SUCCESS; } diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 8be5fe18..87fbc3f1 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -47,10 +47,10 @@ static inline bool CF_ChanAction_Status_IS_SUCCESS(CF_ChanAction_Status_t stat) /** * @brief A callback function for use with CF_DoChanAction() * - * @param chan_num The CF channel number, for statistics purposes + * @param chan The CF channel pointer * @param context Opaque object passed through from initial call */ -typedef CF_ChanAction_Status_t (*CF_ChanActionFn_t)(uint8 chan_num, void *context); +typedef CF_ChanAction_Status_t (*CF_ChanActionFn_t)(CF_Channel_t *chan, void *context); /** * @brief An object to use with channel-scope actions requiring only a boolean argument @@ -86,8 +86,8 @@ typedef struct CF_ChanAction_SuspResArg */ typedef struct CF_ChanAction_BoolMsgArg { - const CF_UnionArgs_Payload_t *data; - bool barg; + const void *opaque_data; + bool barg; } CF_ChanAction_BoolMsgArg_t; /** @@ -97,7 +97,7 @@ typedef struct CF_ChanAction_BoolMsgArg */ typedef struct CF_ChanAction_MsgArg { - const CF_UnionArgs_Payload_t *data; + const void *opaque_data; } CF_ChanAction_MsgArg_t; /************************************************************************/ @@ -208,7 +208,7 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg); * @retval CF_ChanAction_Status_ERROR on error */ CF_ChanAction_Status_t -CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanActionFn_t fn, void *context); +CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context); /************************************************************************/ /** @brief Channel action to set the frozen bit for a channel. @@ -221,7 +221,7 @@ CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanA * * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. */ -CF_ChanAction_Status_t CF_DoFreezeThaw(uint8 chan_num, void *arg); +CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg); /************************************************************************/ /** @brief Freeze a channel. @@ -386,7 +386,7 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg); * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. * */ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, void *arg); +CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg); /************************************************************************/ /** @brief Handle an enable dequeue ground command. @@ -421,7 +421,7 @@ CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg); * @retval CF_ChanAction_Status_SUCCESS if successful * @retval CF_ChanAction_Status_ERROR if failed */ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, void *arg); +CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg); /************************************************************************/ /** @brief Enable a polling dir ground command. @@ -490,7 +490,7 @@ CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignore * @retval CF_ChanAction_Status_SUCCESS if successful * @retval CF_ChanAction_Status_ERROR on error */ -CF_ChanAction_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg); +CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg); /************************************************************************/ /** @brief Ground command to purge either the history or pending queues. @@ -526,7 +526,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg); * @retval CF_ChanAction_Status_ERROR if failed (val is greater than max PDU) * */ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_num); +CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan); /************************************************************************/ /** @brief Checks if the value is within allowable range as outgoing packets per wakeup @@ -542,7 +542,7 @@ CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_nu * @retval CF_ChanAction_Status_ERROR if failed (val is not allowed) * */ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, uint8 chan_num); +CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan); /************************************************************************/ /** @brief Perform a configuration get/set operation. @@ -562,7 +562,7 @@ CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, uint8 chan_num); * @param chan_num Channel number to operate on * */ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num); +void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num); /************************************************************************/ /** @brief Ground command to set a configuration parameter. diff --git a/fsw/src/cf_dispatch.c b/fsw/src/cf_dispatch.c index 49e3187a..ed7e0abc 100644 --- a/fsw/src/cf_dispatch.c +++ b/fsw/src/cf_dispatch.c @@ -115,7 +115,7 @@ void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *BufPtr) cmd, expected_lengths[cmd], len); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } } else @@ -124,7 +124,7 @@ void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *BufPtr) CFE_EVS_EventType_ERROR, "CF: invalid ground command packet cmd_code=0x%02x", cmd); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; } } @@ -170,7 +170,7 @@ void CF_AppPipe(const CFE_SB_Buffer_t *BufPtr) } else { - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; CFE_EVS_SendEvent(CF_MID_ERR_EID, CFE_EVS_EventType_ERROR, "CF: invalid command packet id=0x%lx", diff --git a/fsw/src/cf_eds_dispatch.c b/fsw/src/cf_eds_dispatch.c index f65d293d..8bcb9946 100644 --- a/fsw/src/cf_eds_dispatch.c +++ b/fsw/src/cf_eds_dispatch.c @@ -53,7 +53,7 @@ void CF_AppPipe(const CFE_SB_Buffer_t *BufPtr) if (status != CFE_SUCCESS) { CFE_MSG_GetMsgId(&BufPtr->Msg, &MsgId); - ++CF_AppData.hk.Payload.counters.err; + ++CF_AppData.counters.err; if (status == CFE_STATUS_UNKNOWN_MSG_ID) { diff --git a/fsw/src/cf_timer.c b/fsw/src/cf_timer.c index 4ea2600e..d82b9252 100644 --- a/fsw/src/cf_timer.c +++ b/fsw/src/cf_timer.c @@ -42,7 +42,8 @@ *-----------------------------------------------------------------*/ uint32 CF_Timer_Sec2Ticks(CF_Timer_Seconds_t sec) { - return sec * CF_AppData.config_table->ticks_per_second; + CF_Engine_t *engine_ptr = CF_GetEngine(); + return sec * engine_ptr->config.ticks_per_second; } /*---------------------------------------------------------------- diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index fe1267b7..2633522e 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -34,27 +34,15 @@ #include "cf_assert.h" -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in cf_utils.h for argument/return detail - * - *-----------------------------------------------------------------*/ -CF_Channel_t *CF_GetChannelFromTxn(CF_Transaction_t *txn) +/* + * Local type to support CF_DoTraverseAllTransactions + */ +typedef struct { - CF_Channel_t *chan; - - if (txn->chan_num < CF_NUM_CHANNELS) - { - chan = &CF_AppData.engine.channels[txn->chan_num]; - } - else - { - chan = NULL; - } - - return chan; -} + CF_TraverseAllTransactions_fn_t fn; + void *context; + int32 ret; +} CF_TraverseAllTransactions_State_t; /*---------------------------------------------------------------- * @@ -159,6 +147,7 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *chan, CF_Direction_t di /* notably this state is distinguishable from items still on the free list */ txn->state = CF_TxnState_INIT; txn->history->dir = direction; + txn->chan_ptr = chan; } else { @@ -186,12 +175,14 @@ void CF_ResetHistory(CF_Channel_t *chan, CF_History_t *history) * See description in cf_utils.h for argument/return detail * *-----------------------------------------------------------------*/ -void CF_FreeTransaction(CF_Transaction_t *txn, uint8 chan) +void CF_FreeTransaction(CF_Transaction_t *txn) { + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + memset(txn, 0, sizeof(*txn)); - txn->chan_num = chan; + txn->chan_ptr = chan; CF_CList_InitNode(&txn->cl_node); - CF_CList_InsertBack_Ex(&CF_AppData.engine.channels[chan], CF_QueueIdx_FREE, &txn->cl_node); + CF_CList_InsertBack_Ex(chan, CF_QueueIdx_FREE, &txn->cl_node); } /*---------------------------------------------------------------- @@ -423,9 +414,9 @@ CF_CListTraverse_Status_t CF_PrioSearch(CF_CListNode_t *node, void *context) void CF_InsertSortPrio(CF_Transaction_t *txn, CF_QueueIdx_t queue) { bool insert_back = false; - CF_Channel_t *chan = &CF_AppData.engine.channels[txn->chan_num]; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); - CF_Assert(txn->chan_num < CF_NUM_CHANNELS); + CF_Assert(chan); /* look for proper position on PEND queue for this transaction. * This is a simple priority sort. */ @@ -487,6 +478,22 @@ int32 CF_TraverseAllTransactions(CF_Channel_t *chan, CF_TraverseAllTransactions_ return args.counter; } +/*---------------------------------------------------------------- + * + * Local helper function + * Invokes CF_TraverseAllTransactions() for a single channel within the CFDP engine + * Compatible with CF_ForEachChannel() + * + *-----------------------------------------------------------------*/ +static int32 CF_DoTraverseAllTransactions(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + CF_TraverseAllTransactions_State_t *state = arg; + + state->ret += CF_TraverseAllTransactions(chan, state->fn, state->context); + + return CFE_SUCCESS; +} + /*---------------------------------------------------------------- * * Application-scope internal function @@ -495,11 +502,16 @@ int32 CF_TraverseAllTransactions(CF_Channel_t *chan, CF_TraverseAllTransactions_ *-----------------------------------------------------------------*/ int32 CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context) { - int i; - int32 ret = 0; - for (i = 0; i < CF_NUM_CHANNELS; ++i) - ret += CF_TraverseAllTransactions(CF_AppData.engine.channels + i, fn, context); - return ret; + CF_TraverseAllTransactions_State_t state; + + memset(&state, 0, sizeof(state)); + + state.fn = fn; + state.context = context; + + CF_ForEachChannel(CF_GetEngine(), CF_DoTraverseAllTransactions, &state); + + return state.ret; } /*---------------------------------------------------------------- @@ -668,3 +680,25 @@ CF_TxnStatus_t CF_TxnStatus_From_ConditionCode(CF_CFDP_ConditionCode_t cc) /* All CFDP CC values directly correspond to a Transaction Status of the same numeric value */ return (CF_TxnStatus_t)cc; } + +/*---------------------------------------------------------------- + * + * Function: CF_ForEachChannel + * + * Application-scope internal function + * See description in cf_utils.h for argument/return detail + * + *-----------------------------------------------------------------*/ +int32 CF_ForEachChannel(CF_Engine_t *engine_ptr, CF_ChannelFunc_t fn, void *arg) +{ + int32 Result; + int32 i; + + Result = CFE_SUCCESS; + for (i = 0; i < CF_NUM_CHANNELS && Result == CFE_SUCCESS; ++i) + { + Result = fn(engine_ptr, &engine_ptr->channels[i], arg); + } + + return Result; +} diff --git a/fsw/src/cf_utils.h b/fsw/src/cf_utils.h index 937353d4..a2e8c8e7 100644 --- a/fsw/src/cf_utils.h +++ b/fsw/src/cf_utils.h @@ -110,6 +110,28 @@ typedef struct CF_Traverse_PriorityArg uint8 priority; /**< \brief seeking this priority */ } CF_Traverse_PriorityArg_t; +/** @brief Function declaration to use with CF_ForEachChannel() + * + * @returns CFE_SUCCESS if completed successfully, otherwise error code + */ +typedef int32 (*CF_ChannelFunc_t)(CF_Engine_t *, CF_Channel_t *, void *); + +/************************************************************************/ +/** @brief Gets the associated channel struct from a transaction + * + * @par Assumptions, External Events, and Notes: + * txn must not be null, and the chan_num must be set + * + * @param txn Transaction + * + * @returns Pointer to CF_Channel_t struct associated with the transaction + * @retval NULL if reference is invalid + */ +static inline CF_Channel_t *CF_GetChannelFromTxn(const CF_Transaction_t *txn) +{ + return txn->chan_ptr; +} + /* free a transaction from the queue it's on. * NOTE: this leaves the transaction in a bad state, * so it must be followed by placing the transaction on @@ -121,41 +143,46 @@ typedef struct CF_Traverse_PriorityArg * pointing to an invalid node */ static inline void CF_DequeueTransaction(CF_Transaction_t *txn) { - CF_Assert(txn && (txn->chan_num < CF_NUM_CHANNELS)); - CF_CList_Remove(&CF_AppData.engine.channels[txn->chan_num].qs[txn->flags.com.q_index], &txn->cl_node); - CF_Assert(CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index]); /* sanity check */ - --CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index]; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + + CF_Assert(chan->stat.q_size[txn->flags.com.q_index]); /* sanity check */ + + CF_CList_Remove(&chan->qs[txn->flags.com.q_index], &txn->cl_node); + --chan->stat.q_size[txn->flags.com.q_index]; } static inline void CF_MoveTransaction(CF_Transaction_t *txn, CF_QueueIdx_t queue) { - CF_Assert(txn && (txn->chan_num < CF_NUM_CHANNELS)); - CF_CList_Remove(&CF_AppData.engine.channels[txn->chan_num].qs[txn->flags.com.q_index], &txn->cl_node); - CF_Assert(CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index]); /* sanity check */ - --CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index]; - CF_CList_InsertBack(&CF_AppData.engine.channels[txn->chan_num].qs[queue], &txn->cl_node); + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + + CF_Assert(chan->stat.q_size[txn->flags.com.q_index]); /* sanity check */ + + CF_CList_Remove(&chan->qs[txn->flags.com.q_index], &txn->cl_node); + --chan->stat.q_size[txn->flags.com.q_index]; + CF_CList_InsertBack(&chan->qs[queue], &txn->cl_node); txn->flags.com.q_index = queue; - ++CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index]; + ++chan->stat.q_size[txn->flags.com.q_index]; } static inline void CF_CList_Remove_Ex(CF_Channel_t *chan, CF_QueueIdx_t queueidx, CF_CListNode_t *node) { + CF_Assert(chan->stat.q_size[queueidx]); /* sanity check */ + CF_CList_Remove(&chan->qs[queueidx], node); - CF_Assert(CF_AppData.hk.Payload.channel_hk[chan - CF_AppData.engine.channels].q_size[queueidx]); /* sanity check */ - --CF_AppData.hk.Payload.channel_hk[chan - CF_AppData.engine.channels].q_size[queueidx]; + --chan->stat.q_size[queueidx]; } static inline void CF_CList_InsertAfter_Ex(CF_Channel_t *chan, CF_QueueIdx_t queueidx, CF_CListNode_t *start, CF_CListNode_t *after) { CF_CList_InsertAfter(&chan->qs[queueidx], start, after); - ++CF_AppData.hk.Payload.channel_hk[chan - CF_AppData.engine.channels].q_size[queueidx]; + ++chan->stat.q_size[queueidx]; } static inline void CF_CList_InsertBack_Ex(CF_Channel_t *chan, CF_QueueIdx_t queueidx, CF_CListNode_t *node) { CF_CList_InsertBack(&chan->qs[queueidx], node); - ++CF_AppData.hk.Payload.channel_hk[chan - CF_AppData.engine.channels].q_size[queueidx]; + ++chan->stat.q_size[queueidx]; } /************************************************************************/ @@ -194,9 +221,8 @@ void CF_ResetHistory(CF_Channel_t *chan, CF_History_t *history); * txn must not be NULL. * * @param txn Pointer to the transaction object - * @param chan The channel number which this transaction is associated with */ -void CF_FreeTransaction(CF_Transaction_t *txn, uint8 chan); +void CF_FreeTransaction(CF_Transaction_t *txn); /************************************************************************/ /** @brief Finds an active transaction by sequence number. @@ -526,19 +552,6 @@ static inline bool CF_TxnStatus_IsError(CF_TxnStatus_t txn_stat) return (txn_stat > CF_TxnStatus_NO_ERROR); } -/************************************************************************/ -/** @brief Gets the associated channel struct from a transaction - * - * @par Assumptions, External Events, and Notes: - * txn must not be null, and the chan_num must be set - * - * @param txn Transaction - * - * @returns Pointer to CF_Channel_t struct associated with the transaction - * @retval NULL if checks failed - */ -CF_Channel_t *CF_GetChannelFromTxn(CF_Transaction_t *txn); - /************************************************************************/ /** @brief Gets the head of the chunk list for the given channel + direction * @@ -565,4 +578,17 @@ CF_CListNode_t **CF_GetChunkListHead(CF_Channel_t *chan, uint8 direction); */ CF_CFDP_AckTxnStatus_t CF_CFDP_GetAckTxnStatus(CF_Transaction_t *txn); +/************************************************************************/ +/** @brief Invokes the given function on every channel in the engine + * + * Loops through all channels and calls the function. Stops when any + * of the function calls return non-CFE_SUCCESS. + * + * @param engine_ptr Engine pointer + * @param fn Function to call + * @param arg Opaque arg passed to function + * @returns CFE_SUCCESS if completed successfully, otherwise error code + */ +int32 CF_ForEachChannel(CF_Engine_t *engine_ptr, CF_ChannelFunc_t fn, void *arg); + #endif /* !CF_UTILS_H */ diff --git a/fsw/tables/cf_def_config.c b/fsw/tables/cf_def_config.c index 91d75f06..828d4544 100644 --- a/fsw/tables/cf_def_config.c +++ b/fsw/tables/cf_def_config.c @@ -48,7 +48,7 @@ CF_ConfigTable_t CF_config_table = { /* polling directory 0 */ 5, /* interval seconds */ 25, /* priority */ - CF_CFDP_CLASS_2, /* class to send */ + CF_CFDP_Class_2, /* class to send */ 23, /* destination entity id */ "/cf/poll_dir", /* source directory */ "./poll_dir", /* destination directory */ diff --git a/unit-test/cf_app_tests.c b/unit-test/cf_app_tests.c index 8ba105fa..ae0a12a0 100644 --- a/unit-test/cf_app_tests.c +++ b/unit-test/cf_app_tests.c @@ -69,20 +69,26 @@ void UT_UpdatedDefaultHandler_CFE_SB_ReceiveBuffer(void *UserO void Test_CF_CheckTables_DoNotReleaseAddressBecauseEngineIsEnabled(void) { + CF_Engine_t *engine_ptr = CF_GetEngine(); + /* Arrange */ - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; /* Act */ CF_CheckTables(); /* Assert */ - UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 0); + UtAssert_STUB_COUNT(CFE_TBL_Manage, 0); } void Test_CF_CheckTables_CallTo_CFE_TBL_ReleaseAddress_ReturnsNot_CFE_SUCCESS_SendEvent(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_TBL_INFO_UPDATED); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); @@ -90,35 +96,42 @@ void Test_CF_CheckTables_CallTo_CFE_TBL_ReleaseAddress_ReturnsNot_CFE_SUCCESS_Se CF_CheckTables(); /* Assert */ + UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); + UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } void Test_CF_CheckTables_CallTo_CFE_TBL_Manage_ReturnsNot_CFE_SUCCESS_SendEvent(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); - UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); + UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); /* Act */ CF_CheckTables(); /* Assert */ - UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1); + UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 0); + UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 0); UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_ReturnsNot_CFE_SUCCESS_Or_CFE_TBL_INFO_UPDATED_SendEvent(void) { + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_TBL_INFO_UPDATED); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); /* Act */ CF_CheckTables(); /* Assert */ - UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1); + UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 0); UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -126,8 +139,12 @@ void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_ReturnsNot_CFE_SUCCESS_Or_CFE void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_SUCCESS(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_TBL_INFO_UPDATED); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); /* Act */ @@ -142,8 +159,11 @@ void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_SUCCESS(void) void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + memset(&ut_config, 0, sizeof(ut_config)); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_TBL_INFO_UPDATED); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_INFO_UPDATED); @@ -154,6 +174,7 @@ void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED( UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1); UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); + UtAssert_STUB_COUNT(CF_ForEachChannel, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } @@ -338,7 +359,10 @@ void Test_CF_TableInit_FailBecause_CFE_TBL_GetAddress_DidNotReturnSuccess(void) void Test_CF_TableInit_When_CFE_TBL_GetAddress_Returns_CFE_SUCCESS_SuccessAndDoNotSendEvent(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); @@ -351,7 +375,10 @@ void Test_CF_TableInit_When_CFE_TBL_GetAddress_Returns_CFE_SUCCESS_SuccessAndDoN void Test_CF_TableInit_When_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED_SuccessAndDoNotSendEvent(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); /* Arrange */ @@ -380,7 +407,6 @@ void Test_CF_AppInit_CallTo_CFE_EVS_Register_ReturnsNot_CFE_SUCCESS_Call_CFE_ES_ UtAssert_INT32_EQ(CF_AppInit(), result); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); UtAssert_STUB_COUNT(CFE_EVS_Register, 1); UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 1); } @@ -396,7 +422,6 @@ void Test_CF_AppInit_CallTo_CFE_SB_CreatePipe_ReturnsNot_CFE_SUCCESS_Return_Pipe UtAssert_INT32_EQ(CF_AppInit(), result); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); UtAssert_STUB_COUNT(CFE_EVS_Register, 1); UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1); UT_CF_AssertEventID(CF_CR_PIPE_ERR_EID); @@ -414,7 +439,6 @@ void Test_CF_AppInit_FirstCallTo_CFE_SB_Subscribe_ReturnsNot_CFE_SUCCESS_Call_CF UtAssert_INT32_EQ(CF_AppInit(), result); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); UtAssert_STUB_COUNT(CFE_EVS_Register, 1); UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1); UtAssert_STUB_COUNT(CFE_SB_Subscribe, 1); @@ -435,7 +459,6 @@ void Test_CF_AppInit_CallTo_CF_TableInit_ReturnsNot_CFE_SUCCESS_ReturnErrorStatu UtAssert_INT32_EQ(CF_AppInit(), result); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); UtAssert_STUB_COUNT(CFE_EVS_Register, 1); UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1); UtAssert_STUB_COUNT(CFE_SB_Subscribe, 3); @@ -445,8 +468,11 @@ void Test_CF_AppInit_CallTo_CF_TableInit_ReturnsNot_CFE_SUCCESS_ReturnErrorStatu void Test_CF_AppInit_CallTo_CF_CFDP_InitEngine_ReturnsNot_CFE_SUCCESS_ReturnErrorStatus(void) { /* Arrange */ - int32 result = -1; - void *TablePtr = NULL; + int32 result = -1; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), result); @@ -455,7 +481,6 @@ void Test_CF_AppInit_CallTo_CF_CFDP_InitEngine_ReturnsNot_CFE_SUCCESS_ReturnErro UtAssert_INT32_EQ(CF_AppInit(), result); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); UtAssert_STUB_COUNT(CFE_EVS_Register, 1); UtAssert_STUB_COUNT(CFE_SB_CreatePipe, 1); UtAssert_STUB_COUNT(CFE_SB_Subscribe, 3); @@ -464,7 +489,10 @@ void Test_CF_AppInit_CallTo_CF_CFDP_InitEngine_ReturnsNot_CFE_SUCCESS_ReturnErro void Test_CF_AppInit_Success(void) { - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); @@ -472,7 +500,7 @@ void Test_CF_AppInit_Success(void) UtAssert_INT32_EQ(CF_AppInit(), CFE_SUCCESS); /* Assert */ - UtAssert_STUB_COUNT(CFE_MSG_Init, 1); + UtAssert_STUB_COUNT(CF_CFDP_InitEngine, 1); } /******************************************************************************* @@ -503,8 +531,10 @@ void Test_CF_AppMain_CFE_SB_ReceiveBuffer_Cases(void) { CFE_SB_Buffer_t sbbuf; CFE_SB_Buffer_t *sbbufptr; - void *TablePtr = NULL; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + memset(&ut_config, 0, sizeof(ut_config)); memset(&sbbuf, 0, sizeof(sbbuf)); /* Run loop once */ @@ -553,8 +583,11 @@ void Test_CF_AppMain_RunLoopCallTo_CFE_SB_ReceiveBuffer_Returns_CFE_SUCCESS_AndV /* Arrange */ CFE_SB_MsgId_t forced_MsgID = CFE_SB_INVALID_MSG_ID; CFE_SB_Buffer_t fake_msg; - CFE_SB_Buffer_t *BufPtr = &fake_msg; - void *TablePtr = NULL; + CFE_SB_Buffer_t *BufPtr = &fake_msg; + CF_ConfigTable_t ut_config; + void *TablePtr = &ut_config; + + memset(&ut_config, 0, sizeof(ut_config)); UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); diff --git a/unit-test/cf_cfdp_dispatch_tests.c b/unit-test/cf_cfdp_dispatch_tests.c index 86ff6dd8..9f49941e 100644 --- a/unit-test/cf_cfdp_dispatch_tests.c +++ b/unit-test/cf_cfdp_dispatch_tests.c @@ -33,7 +33,7 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, CF_Channel_t **channel_p, CF_History_t **history_p, CF_Transaction_t **txn_p, - CF_ConfigTable_t **config_table_p) + CF_EngineConfig_t **config_table_p) { /* * fake objects used to pass into CF app during unit tests. @@ -42,7 +42,9 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Logical_PduBuffer_t ut_pdu_buffer; static CF_History_t ut_history; static CF_Transaction_t ut_transaction; - static CF_ConfigTable_t ut_config_table; + + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; /* * always clear all objects, regardless of what was asked for. @@ -52,12 +54,11 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, memset(&ut_pdu_buffer, 0, sizeof(ut_pdu_buffer)); memset(&ut_history, 0, sizeof(ut_history)); memset(&ut_transaction, 0, sizeof(ut_transaction)); - memset(&ut_config_table, 0, sizeof(ut_config_table)); /* certain pointers should be connected even if they were not asked for, * as internal code may assume these are set (test cases may un-set) */ ut_transaction.history = &ut_history; - CF_AppData.config_table = &ut_config_table; + ut_transaction.chan_ptr = local_channel_p; if (pdu_buffer_p) { @@ -81,7 +82,7 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, * a member of that array, so for now it must be so. * This always uses the same channel for now. */ - *channel_p = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + *channel_p = local_channel_p; } if (history_p) { @@ -93,7 +94,7 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, } if (config_table_p) { - *config_table_p = &ut_config_table; + *config_table_p = &engine_ptr->config; } /* reset the event ID capture between each sub-case */ @@ -135,6 +136,7 @@ void Test_CF_CFDP_R_DispatchRecv(void) CF_Logical_PduBuffer_t *ph; CF_CFDP_R_SubstateDispatchTable_t dispatch; CF_CFDP_FileDirectiveDispatchTable_t fddt; + CF_Channel_t *chan; memset(&dispatch, 0, sizeof(dispatch)); memset(&fddt, 0, sizeof(fddt)); @@ -146,38 +148,38 @@ void Test_CF_CFDP_R_DispatchRecv(void) dispatch.state[CF_RxSubState_DATA_EOF] = &fddt; /* nominal (file directive) */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.pdu_type = 0; UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, NULL)); /* nominal (file data) */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.pdu_type = 1; UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, NULL)); /* directive code beyond range */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->fdirective.directive_code = CF_CFDP_FileDirective_INVALID_MAX; UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, NULL)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.spurious, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.spurious, 1); UT_CF_AssertEventID(CF_CFDP_R_DC_INV_ERR_EID); /* file data with error */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.pdu_type = 1; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_TxnIsOK), 1, false); UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, NULL)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.dropped, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.dropped, 1); /* test actual dispatch */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->fdirective.directive_code = CF_CFDP_FileDirective_METADATA; txn->state_data.sub_state = CF_RxSubState_DATA_EOF; UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, CF_CFDP_R2_Recv)); UtAssert_STUB_COUNT(CF_CFDP_R1_Recv, 1); UtAssert_STUB_COUNT(CF_CFDP_R2_Recv, 0); - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.pdu_type = 1; txn->state_data.sub_state = CF_RxSubState_DATA_EOF; UtAssert_VOIDCALL(CF_CFDP_R_DispatchRecv(txn, ph, &dispatch, CF_CFDP_R2_Recv)); @@ -195,6 +197,7 @@ void Test_CF_CFDP_S_DispatchRecv(void) CF_Logical_PduBuffer_t *ph; CF_CFDP_S_SubstateRecvDispatchTable_t dispatch; CF_CFDP_FileDirectiveDispatchTable_t fddt; + CF_Channel_t *chan; memset(&dispatch, 0, sizeof(dispatch)); memset(&fddt, 0, sizeof(fddt)); @@ -204,23 +207,23 @@ void Test_CF_CFDP_S_DispatchRecv(void) dispatch.substate[CF_TxSubState_DATA_EOF] = &fddt; /* nominal, no handler */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); UtAssert_VOIDCALL(CF_CFDP_S_DispatchRecv(txn, ph, &dispatch)); /* directive code beyond range */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->fdirective.directive_code = CF_CFDP_FileDirective_INVALID_MAX; UtAssert_VOIDCALL(CF_CFDP_S_DispatchRecv(txn, ph, &dispatch)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.spurious, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.spurious, 1); UT_CF_AssertEventID(CF_CFDP_S_DC_INV_ERR_EID); /* file data PDU, not expected in this type of txn */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.pdu_type = 1; UtAssert_VOIDCALL(CF_CFDP_S_DispatchRecv(txn, ph, &dispatch)); /* test actual dispatch */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->fdirective.directive_code = CF_CFDP_FileDirective_METADATA; txn->state_data.sub_state = CF_TxSubState_DATA_EOF; UtAssert_VOIDCALL(CF_CFDP_S_DispatchRecv(txn, ph, &dispatch)); @@ -236,6 +239,7 @@ void Test_CF_CFDP_RxStateDispatch(void) CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; CF_CFDP_TxnRecvDispatchTable_t dispatch; + CF_Channel_t *chan; memset(&dispatch, 0, sizeof(dispatch)); @@ -243,14 +247,14 @@ void Test_CF_CFDP_RxStateDispatch(void) dispatch.rx[CF_TxnState_DROP] = CF_CFDP_RecvDrop; /* nominal, no handler */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.txm_mode = 1; txn->state = CF_TxnState_INIT; txn->reliable_mode = false; UtAssert_VOIDCALL(CF_CFDP_RxStateDispatch(txn, ph, &dispatch)); /* nominal, with handler */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.txm_mode = 1; txn->state = CF_TxnState_R1; txn->reliable_mode = false; @@ -258,14 +262,14 @@ void Test_CF_CFDP_RxStateDispatch(void) UtAssert_STUB_COUNT(CF_CFDP_R1_Recv, 1); /* Got txm_mode = 0 in an R1 */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.txm_mode = 0; txn->reliable_mode = false; UtAssert_VOIDCALL(CF_CFDP_RxStateDispatch(txn, ph, &dispatch)); UtAssert_STUB_COUNT(CF_CFDP_RecvDrop, 1); /* Got txm_mode = 1 in an R2 */ - UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->pdu_header.txm_mode = 1; txn->reliable_mode = true; UtAssert_VOIDCALL(CF_CFDP_RxStateDispatch(txn, ph, &dispatch)); diff --git a/unit-test/cf_cfdp_r_tests.c b/unit-test/cf_cfdp_r_tests.c index d4e8a2fd..49b2e1f5 100644 --- a/unit-test/cf_cfdp_r_tests.c +++ b/unit-test/cf_cfdp_r_tests.c @@ -43,7 +43,7 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, CF_Channel_t **channel_p, CF_History_t **history_p, CF_Transaction_t **txn_p, - CF_ConfigTable_t **config_table_p) + CF_EngineConfig_t **config_table_p) { /* * fake objects used to pass into CF app during unit tests. @@ -52,7 +52,9 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Logical_PduBuffer_t ut_pdu_buffer; static CF_History_t ut_history; static CF_Transaction_t ut_transaction; - static CF_ConfigTable_t ut_config_table; + + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; /* * always clear all objects, regardless of what was asked for. @@ -62,12 +64,11 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, memset(&ut_pdu_buffer, 0, sizeof(ut_pdu_buffer)); memset(&ut_history, 0, sizeof(ut_history)); memset(&ut_transaction, 0, sizeof(ut_transaction)); - memset(&ut_config_table, 0, sizeof(ut_config_table)); /* certain pointers should be connected even if they were not asked for, * as internal code may assume these are set (test cases may un-set) */ ut_transaction.history = &ut_history; - CF_AppData.config_table = &ut_config_table; + ut_transaction.chan_ptr = local_channel_p; if (pdu_buffer_p) { @@ -91,7 +92,7 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, * a member of that array, so for now it must be so. * This always uses the same channel for now. */ - *channel_p = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + *channel_p = local_channel_p; } if (history_p) { @@ -103,7 +104,7 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, } if (config_table_p) { - *config_table_p = &ut_config_table; + *config_table_p = &engine_ptr->config; } if (setup == UT_CF_Setup_TX) @@ -372,9 +373,10 @@ void Test_CF_CFDP_R_Init(void) * void CF_CFDP_R_Init(CF_Transaction_t *txn); */ CF_Transaction_t *txn; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); txn->state_data.fin_dc = -1; txn->state_data.fin_fs = -1; UtAssert_VOIDCALL(CF_CFDP_R_Init(txn)); @@ -382,26 +384,26 @@ void Test_CF_CFDP_R_Init(void) UtAssert_UINT8_EQ(txn->state_data.fin_fs, CF_CFDP_FinFileStatus_INVALID); /* nominal, R2 state, creates tempfile */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = true; UtAssert_VOIDCALL(CF_CFDP_R_Init(txn)); UT_CF_AssertEventID(CF_CFDP_R_TEMP_FILE_INF_EID); /* failure of file open, class 1 */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_WrappedOpenCreate), 1, -1); txn->reliable_mode = false; UtAssert_VOIDCALL(CF_CFDP_R_Init(txn)); UT_CF_AssertEventID(CF_CFDP_R_CREAT_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_open, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_open, 1); /* failure of file open, class 2 */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_WrappedOpenCreate), 1, -1); txn->reliable_mode = true; UtAssert_VOIDCALL(CF_CFDP_R_Init(txn)); UT_CF_AssertEventID(CF_CFDP_R_CREAT_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_open, 2); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_open, 2); UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_FILESTORE_REJECTION); } @@ -411,27 +413,28 @@ void Test_CF_CFDP_R_CheckCrc(void) * int CF_CFDP_R_CheckCrc(CF_Transaction_t *txn, uint32 expected_crc); */ CF_Transaction_t *txn; + CF_Channel_t *chan; /* CRC mismatch, class 1 */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = false; txn->crc.result = 0xdeadbeef; txn->state_data.eof_crc = 0x1badc0de; UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn), CF_ERROR); UT_CF_AssertEventID(CF_CFDP_R_CRC_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.crc_mismatch, 1); /* CRC mismatch, class 2 */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = true; txn->crc.result = 0xdeadbeef; txn->state_data.eof_crc = 0x2badc0de; UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn), CF_ERROR); UT_CF_AssertEventID(CF_CFDP_R_CRC_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.crc_mismatch, 2); + UtAssert_UINT32_EQ(chan->stat.counters.fault.crc_mismatch, 2); /* CRC match */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, NULL, &chan, NULL, &txn, NULL); txn->crc.result = 0xc0ffee; txn->state_data.eof_crc = 0xc0ffee; UtAssert_INT32_EQ(CF_CFDP_R_CheckCrc(txn), CFE_SUCCESS); @@ -446,33 +449,34 @@ void Test_CF_CFDP_R_ProcessFd(void) CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; CF_Logical_PduFileDataHeader_t *fd; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); fd = &ph->int_header.fd; fd->data_len = 100; UT_SetDefaultReturnValue(UT_KEY(CF_WrappedWrite), fd->data_len); UtAssert_INT32_EQ(CF_CFDP_R_ProcessFd(txn, ph), 0); UtAssert_UINT32_EQ(txn->state_data.cached_pos, 100); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.file_data_bytes, 100); + UtAssert_UINT32_EQ(chan->stat.counters.recv.file_data_bytes, 100); UtAssert_STUB_COUNT(CF_WrappedLseek, 0); UtAssert_STUB_COUNT(CF_WrappedWrite, 1); /* call again, but for something at a different offset */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); fd = &ph->int_header.fd; fd->data_len = 100; fd->offset = 200; UT_SetDefaultReturnValue(UT_KEY(CF_WrappedLseek), fd->offset); UtAssert_INT32_EQ(CF_CFDP_R_ProcessFd(txn, ph), 0); UtAssert_UINT32_EQ(txn->state_data.cached_pos, 300); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.file_data_bytes, 200); + UtAssert_UINT32_EQ(chan->stat.counters.recv.file_data_bytes, 200); UtAssert_STUB_COUNT(CF_WrappedLseek, 1); UtAssert_STUB_COUNT(CF_WrappedWrite, 2); UtAssert_UINT32_EQ(txn->state_data.cached_pos, 300); /* call again, but with a failed write */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); fd = &ph->int_header.fd; fd->data_len = 100; fd->offset = 300; @@ -484,7 +488,7 @@ void Test_CF_CFDP_R_ProcessFd(void) UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_FILESTORE_REJECTION); /* call again, but with a failed lseek */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); fd = &ph->int_header.fd; fd->data_len = 100; fd->offset = 200; @@ -496,8 +500,8 @@ void Test_CF_CFDP_R_ProcessFd(void) UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_FILE_SIZE_ERROR); /* these stats should have been updated during the course of this test */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].counters.fault.file_write, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].counters.fault.file_seek, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_write, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_seek, 1); } void Test_CF_CFDP_R_SubstateRecvEof(void) @@ -507,11 +511,12 @@ void Test_CF_CFDP_R_SubstateRecvEof(void) */ CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; + CF_Channel_t *chan; UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_CheckAckNakCount), true); /* nominal, accept EOF */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); txn->flags.rx.eof_count = 0; txn->state_data.eof_size = 0; ph->int_header.eof.size = 10; @@ -520,7 +525,7 @@ void Test_CF_CFDP_R_SubstateRecvEof(void) UtAssert_EQ(CF_FileSize_t, txn->state_data.eof_size, 10); /* repeat EOF */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); txn->flags.rx.eof_count = 1; txn->state_data.eof_size = 10; ph->int_header.eof.size = 20; @@ -535,13 +540,13 @@ void Test_CF_CFDP_R_SubstateRecvEof(void) UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_POS_ACK_LIMIT_REACHED); /* with failure of CF_CFDP_RecvEof() */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_RecvEof), -1); UtAssert_VOIDCALL(CF_CFDP_R_SubstateRecvEof(txn, ph)); UT_CF_AssertEventID(CF_CFDP_R_PDU_EOF_ERR_EID); /* these counters should have been updated during the test */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].counters.recv.error, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 1); } void Test_CF_CFDP_R_SubstateRecvFileData(void) @@ -660,17 +665,18 @@ void Test_CF_CFDP_R_CalcCrcChunk(void) /* Test case for: * int CF_CFDP_R_CalcCrcChunk(CF_Transaction_t *txn); */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; + CF_Channel_t *chan; /* nominal with zero size file */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->flags.com.crc_complete = false; UtAssert_VOIDCALL(CF_CFDP_R_CalcCrcChunk(txn)); UtAssert_BOOL_TRUE(txn->flags.com.crc_complete); /* nominal with non zero size file, runs the loop */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); txn->flags.com.crc_complete = false; config->rx_crc_calc_bytes_per_wakeup = 100; txn->fsize = 70; @@ -679,7 +685,7 @@ void Test_CF_CFDP_R_CalcCrcChunk(void) UtAssert_BOOL_TRUE(txn->flags.com.crc_complete); /* nominal with file larger than rx_crc_calc_bytes_per_wakeup */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = CF_R2_CRC_CHUNK_SIZE; txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, CF_R2_CRC_CHUNK_SIZE); @@ -687,7 +693,7 @@ void Test_CF_CFDP_R_CalcCrcChunk(void) UtAssert_BOOL_FALSE(txn->flags.com.crc_complete); /* nominal with file size larger than CF_R2_CRC_CHUNK_SIZE (this will do 2 reads) */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = CF_R2_CRC_CHUNK_SIZE * 2; txn->fsize = CF_R2_CRC_CHUNK_SIZE + 100; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, CF_R2_CRC_CHUNK_SIZE); @@ -696,7 +702,7 @@ void Test_CF_CFDP_R_CalcCrcChunk(void) UtAssert_BOOL_TRUE(txn->flags.com.crc_complete); /* failure of read */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); config->rx_crc_calc_bytes_per_wakeup = 100; txn->fsize = 50; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, -1); @@ -704,7 +710,7 @@ void Test_CF_CFDP_R_CalcCrcChunk(void) UT_CF_AssertEventID(CF_CFDP_R_READ_ERR_EID); UtAssert_BOOL_TRUE(txn->flags.com.crc_complete); UtAssert_INT32_EQ(txn->history->txn_stat, CF_TxnStatus_FILE_SIZE_ERROR); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_read, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_read, 1); } void Test_CF_CFDP_R2_Recv_fin_ack(void) @@ -714,25 +720,26 @@ void Test_CF_CFDP_R2_Recv_fin_ack(void) */ CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->int_header.ack.ack_directive_code = CF_CFDP_FileDirective_FIN; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvFinAck(txn, ph)); UtAssert_BOOL_TRUE(txn->flags.rx.finack_recv); - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); txn->flags.rx.finack_recv = false; ph->int_header.ack.ack_directive_code = -1; UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvFinAck(txn, ph)); UtAssert_BOOL_FALSE(txn->flags.rx.finack_recv); /* failure in CF_CFDP_RecvAck */ - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_RecvAck), 1, -1); UtAssert_VOIDCALL(CF_CFDP_R2_SubstateRecvFinAck(txn, ph)); UT_CF_AssertEventID(CF_CFDP_R_PDU_FINACK_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error, 2); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 2); } void Test_CF_CFDP_R_CheckComplete(void) diff --git a/unit-test/cf_cfdp_s_tests.c b/unit-test/cf_cfdp_s_tests.c index 4c9f77f7..6f630301 100644 --- a/unit-test/cf_cfdp_s_tests.c +++ b/unit-test/cf_cfdp_s_tests.c @@ -66,7 +66,7 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, CF_Channel_t **channel_p, CF_History_t **history_p, CF_Transaction_t **txn_p, - CF_ConfigTable_t **config_table_p) + CF_EngineConfig_t **config_table_p) { /* * fake objects used to pass into CF app during unit tests. @@ -75,7 +75,9 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Logical_PduBuffer_t ut_pdu_buffer; static CF_History_t ut_history; static CF_Transaction_t ut_transaction; - static CF_ConfigTable_t ut_config_table; + + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; /* * always clear all objects, regardless of what was asked for. @@ -85,13 +87,12 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, memset(&ut_pdu_buffer, 0, sizeof(ut_pdu_buffer)); memset(&ut_history, 0, sizeof(ut_history)); memset(&ut_transaction, 0, sizeof(ut_transaction)); - memset(&ut_config_table, 0, sizeof(ut_config_table)); /* certain pointers should be connected even if they were not asked for, * as internal code may assume these are set (test cases may un-set) */ ut_transaction.history = &ut_history; + ut_transaction.chan_ptr = local_channel_p; ut_history.txn_stat = CF_TxnStatus_UNDEFINED; - CF_AppData.config_table = &ut_config_table; if (pdu_buffer_p) { @@ -115,7 +116,7 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, * a member of that array, so for now it must be so. * This always uses the same channel for now. */ - *channel_p = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + *channel_p = local_channel_p; } if (history_p) { @@ -127,7 +128,7 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, } if (config_table_p) { - *config_table_p = &ut_config_table; + *config_table_p = &engine_ptr->config; } if (setup == UT_CF_Setup_TX) @@ -240,9 +241,10 @@ void Test_CF_CFDP_S_Tick(void) * void CF_CFDP_S_Tick(CF_Transaction_t *txn); */ CF_Transaction_t *txn; + CF_Channel_t *chan; /* nominal, not in CF_TxSubState_DATA_NORMAL */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); txn->flags.com.inactivity_fired = false; txn->reliable_mode = false; txn->state_data.sub_state = CF_TxSubState_DATA_EOF; @@ -252,7 +254,7 @@ void Test_CF_CFDP_S_Tick(void) /* nominal, with timer expiry */ UT_ResetState(0); - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_GetAckTxnStatus), 1, CF_CFDP_AckTxnStatus_ACTIVE); txn->flags.com.inactivity_fired = false; txn->reliable_mode = false; @@ -262,11 +264,11 @@ void Test_CF_CFDP_S_Tick(void) UtAssert_BOOL_TRUE(txn->flags.com.inactivity_fired); UtAssert_STUB_COUNT(CF_CFDP_RecycleTransaction, 0); UtAssert_STUB_COUNT(CF_CFDP_CompleteTick, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.inactivity_timer, 1); + UtAssert_UINT32_EQ(chan->stat.counters.fault.inactivity_timer, 1); /* nominal, in CF_TxnState_HOLD, with timer expiry */ UT_ResetState(0); - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_GetAckTxnStatus), 1, CF_CFDP_AckTxnStatus_TERMINATED); txn->flags.com.inactivity_fired = false; txn->state = CF_TxnState_HOLD; @@ -278,7 +280,7 @@ void Test_CF_CFDP_S_Tick(void) /* nominal, in CF_TxnState_S2, with timer expiry */ UT_ResetState(0); - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_Timer_Expired), 1, 1); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_GetAckTxnStatus), 1, CF_CFDP_AckTxnStatus_ACTIVE); txn->flags.com.inactivity_fired = false; @@ -287,13 +289,13 @@ void Test_CF_CFDP_S_Tick(void) UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn)); UtAssert_STUB_COUNT(CF_Timer_Tick, 0); UT_CF_AssertEventID(CF_CFDP_S_INACT_TIMER_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.inactivity_timer, 2); + UtAssert_UINT32_EQ(chan->stat.counters.fault.inactivity_timer, 2); UtAssert_BOOL_TRUE(txn->flags.com.inactivity_fired); UtAssert_STUB_COUNT(CF_CFDP_RecycleTransaction, 0); /* nominal, active transaction */ UT_ResetState(0); - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = false; txn->state_data.sub_state = CF_TxSubState_DATA_NORMAL; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_GetAckTxnStatus), 1, CF_CFDP_AckTxnStatus_ACTIVE); @@ -303,7 +305,7 @@ void Test_CF_CFDP_S_Tick(void) /* inactive transaction */ UT_ResetState(0); - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->state = CF_TxnState_HOLD; txn->flags.com.inactivity_fired = true; UtAssert_VOIDCALL(CF_CFDP_S_Tick(txn)); @@ -382,81 +384,82 @@ void Test_CF_CFDP_S_SendFileData(void) /* Test case for: * int32 CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 bytes_to_read, uint8 calc_crc); */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; - uint32 cumulative_read; - uint32 read_size; - uint32 offset; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; + CF_Channel_t *chan; + uint32 cumulative_read; + uint32 read_size; + uint32 offset; cumulative_read = 0; offset = 0; read_size = 100; /* failure of CF_CFDP_ConstructPduHeader */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), CF_SEND_PDU_NO_BUF_AVAIL_ERROR); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); /* nominal, smaller than chunk, no CRC */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); config->outgoing_file_chunk_size = 150; txn->fsize = 300; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, false), read_size); cumulative_read += read_size; - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); /* nominal, larger than PDU, no CRC */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); config->outgoing_file_chunk_size = CF_MAX_PDU_SIZE * 2; txn->fsize = CF_MAX_PDU_SIZE * 2; read_size = CF_MAX_PDU_SIZE; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size * 2, false), read_size); cumulative_read += read_size; - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); UtAssert_STUB_COUNT(CF_CRC_Digest, 0); /* nominal, larger than chunk, with CRC */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); config->outgoing_file_chunk_size = 50; read_size = 100; txn->fsize = 300; UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, config->outgoing_file_chunk_size); UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), config->outgoing_file_chunk_size); cumulative_read += config->outgoing_file_chunk_size; - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); UtAssert_STUB_COUNT(CF_CRC_Digest, 1); /* read w/failure */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, -1); config->outgoing_file_chunk_size = read_size; txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), -1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_read, 1); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_read, 1); UT_CF_AssertEventID(CF_CFDP_S_READ_ERR_EID); /* require lseek */ offset = 25; - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, offset); UT_SetDeferredRetcode(UT_KEY(CF_WrappedRead), 1, read_size); config->outgoing_file_chunk_size = read_size; txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), read_size); cumulative_read += read_size; - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); /* lseek w/failure */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); UT_SetDeferredRetcode(UT_KEY(CF_WrappedLseek), 1, -1); config->outgoing_file_chunk_size = read_size; txn->fsize = 300; UtAssert_INT32_EQ(CF_CFDP_S_SendFileData(txn, offset, read_size, true), -1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.sent.file_data_bytes, cumulative_read); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.fault.file_seek, 1); + UtAssert_UINT32_EQ(chan->stat.counters.sent.file_data_bytes, cumulative_read); + UtAssert_UINT32_EQ(chan->stat.counters.fault.file_seek, 1); UT_CF_AssertEventID(CF_CFDP_S_SEEK_FD_ERR_EID); } @@ -465,8 +468,8 @@ void Test_CF_CFDP_S_SubstateSendFileData(void) /* Test case for: * void CF_CFDP_S_SubstateSendFileData(CF_Transaction_t *txn); */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; /* nominal, zero bytes processed */ UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); @@ -568,35 +571,36 @@ void Test_CF_CFDP_S2_SubstateNak(void) CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; CF_Logical_PduNak_t *nak; + CF_Channel_t *chan; /* no segments */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_RecvNak), 1, CF_ERROR); UtAssert_VOIDCALL(CF_CFDP_S2_SubstateNak(txn, ph)); UT_CF_AssertEventID(CF_CFDP_S_PDU_NAK_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 1); /* nominal, re-send md request (0,0) */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); nak = &ph->int_header.nak; nak->segment_list.num_segments = 1; nak->segment_list.segments[0] = (CF_Logical_SegmentRequest_t) { 0, 0 }; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateNak(txn, ph)); UtAssert_BOOL_TRUE(txn->flags.tx.send_md); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.nak_segment_requests, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.nak_segment_requests, 1); /* nominal, nonzero offsets */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); nak = &ph->int_header.nak; nak->segment_list.num_segments = 2; nak->segment_list.segments[0] = (CF_Logical_SegmentRequest_t) { 0, 200 }; nak->segment_list.segments[1] = (CF_Logical_SegmentRequest_t) { 200, 300 }; txn->fsize = 300; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateNak(txn, ph)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.nak_segment_requests, 3); + UtAssert_UINT32_EQ(chan->stat.counters.recv.nak_segment_requests, 3); /* bad segments */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); nak = &ph->int_header.nak; nak->segment_list.num_segments = 3; nak->segment_list.segments[0] = (CF_Logical_SegmentRequest_t) { 200, 100 }; @@ -604,16 +608,16 @@ void Test_CF_CFDP_S2_SubstateNak(void) nak->segment_list.segments[2] = (CF_Logical_SegmentRequest_t) { 400, 0 }; txn->fsize = 300; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateNak(txn, ph)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.nak_segment_requests, 6); + UtAssert_UINT32_EQ(chan->stat.counters.recv.nak_segment_requests, 6); UT_CF_AssertEventID(CF_CFDP_S_INVALID_SR_ERR_EID); /* bad decode */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_RecvNak), 1, -1); nak = &ph->int_header.nak; nak->segment_list.num_segments = 1; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateNak(txn, ph)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error, 2); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 2); UT_CF_AssertEventID(CF_CFDP_S_PDU_NAK_ERR_EID); } @@ -624,9 +628,10 @@ void Test_CF_CFDP_S2_SubstateEofAck(void) */ CF_Transaction_t *txn; CF_Logical_PduBuffer_t *ph; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); txn->flags.tx.eof_ack_recv = false; ph->int_header.ack.ack_directive_code = CF_CFDP_FileDirective_EOF; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateEofAck(txn, ph)); @@ -634,20 +639,20 @@ void Test_CF_CFDP_S2_SubstateEofAck(void) UtAssert_BOOL_FALSE(txn->flags.com.ack_timer_armed); /* failure of CF_CFDP_RecvAck */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->int_header.ack.ack_directive_code = CF_CFDP_FileDirective_EOF; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_RecvAck), 1, -1); UtAssert_VOIDCALL(CF_CFDP_S2_SubstateEofAck(txn, ph)); UT_CF_AssertEventID(CF_CFDP_S_PDU_EOF_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 1); /* Ack not for EOF */ - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, &txn, NULL); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_RX, &ph, &chan, NULL, &txn, NULL); ph->int_header.ack.ack_directive_code = CF_CFDP_FileDirective_FIN; txn->flags.tx.eof_ack_recv = false; UtAssert_VOIDCALL(CF_CFDP_S2_SubstateEofAck(txn, ph)); UT_CF_AssertEventID(CF_CFDP_S_PDU_EOF_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[txn->chan_num].counters.recv.error, 2); + UtAssert_UINT32_EQ(chan->stat.counters.recv.error, 2); } /* Hook function to set FD output on opencreate call */ @@ -1109,9 +1114,9 @@ void Test_CF_CFDP_S_Tick_Nak(void) /* Test Case For: * void CF_CFDP_S_Tick_Nak(CF_Transaction_t *txn) */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; - CF_Chunk_t chunk; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; + CF_Chunk_t chunk; memset(&chunk, 0, sizeof(chunk)); chunk.size = 100; diff --git a/unit-test/cf_cfdp_sbintf_tests.c b/unit-test/cf_cfdp_sbintf_tests.c index 06099a51..a7a2e0d5 100644 --- a/unit-test/cf_cfdp_sbintf_tests.c +++ b/unit-test/cf_cfdp_sbintf_tests.c @@ -101,7 +101,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, CF_Channel_t **channel_p, CF_History_t **history_p, CF_Transaction_t **txn_p, - CF_ConfigTable_t **config_table_p) + CF_EngineConfig_t **config_table_p) { /* * fake objects used to pass into CF app during unit tests. @@ -109,7 +109,9 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, */ static CF_History_t ut_history; static CF_Transaction_t ut_transaction; - static CF_ConfigTable_t ut_config_table; + + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; /* * always clear all objects, regardless of what was asked for. @@ -118,22 +120,25 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, */ memset(&ut_history, 0, sizeof(ut_history)); memset(&ut_transaction, 0, sizeof(ut_transaction)); - memset(&ut_config_table, 0, sizeof(ut_config_table)); /* certain pointers should be connected even if they were not asked for, * as internal code may assume these are set (test cases may un-set) */ ut_transaction.history = &ut_history; - CF_AppData.config_table = &ut_config_table; + ut_transaction.chan_ptr = local_channel_p; + + local_channel_p->outgoing_counter = 0; + local_channel_p->num_cmd_tx = 0; + local_channel_p->tx_blocked = 0; if (pdu_buffer_p) { if (setup == UT_CF_Setup_TX) { - *pdu_buffer_p = &CF_AppData.engine.out.tx_pdudata; + *pdu_buffer_p = &engine_ptr->out.tx_pdudata; } else if (setup == UT_CF_Setup_RX) { - *pdu_buffer_p = &CF_AppData.engine.in.rx_pdudata; + *pdu_buffer_p = &engine_ptr->in.rx_pdudata; } else { @@ -151,7 +156,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, * a member of that array, so for now it must be so. * This always uses the same channel for now. */ - *channel_p = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + *channel_p = local_channel_p; } if (history_p) { @@ -163,25 +168,22 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, } if (config_table_p) { - *config_table_p = &ut_config_table; + *config_table_p = &engine_ptr->config; } if (setup == UT_CF_Setup_TX) { /* transmit is likely to invoke CF_CFDP_ConstructPduHeader() which in turn requires MsgOutGet to work */ - UT_CFDP_SetupBasicTxState(&CF_AppData.engine.out.tx_pdudata); + UT_CFDP_SetupBasicTxState(&engine_ptr->out.tx_pdudata); } else if (setup == UT_CF_Setup_RX) { /* most calls on the RX side will do some sort of decode, so set up for that. */ - UT_CFDP_SetupBasicRxState(&CF_AppData.engine.in.rx_pdudata); - ut_config_table.chan[UT_CFDP_CHANNEL].rx_max_messages_per_wakeup = 1; + UT_CFDP_SetupBasicRxState(&engine_ptr->in.rx_pdudata); + local_channel_p->config.rx_max_messages_per_wakeup = 1; } - UT_SetDefaultReturnValue(UT_KEY(CF_GetChannelFromTxn), - (UT_IntReturn_t)&CF_AppData.engine.channels[UT_CFDP_CHANNEL]); - /* reset the event ID capture between each sub-case */ UT_CF_ResetEventCapture(); } @@ -219,11 +221,11 @@ void Test_CF_CFDP_ReceiveMessage(void) /* Test case for: * void CF_CFDP_ReceiveMessage(CF_Channel_t *chan); */ - CF_Channel_t *chan; - CF_ConfigTable_t *config; - CF_Transaction_t *txn; - CFE_MSG_Type_t msg_type; - CFE_MSG_Size_t msg_size_buf; + CF_Channel_t *chan; + CF_EngineConfig_t *config; + CF_Transaction_t *txn; + CFE_MSG_Type_t msg_type; + CFE_MSG_Size_t msg_size_buf; /* no-config - the max per wakeup will be 0, and this is a noop */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, NULL); @@ -231,7 +233,7 @@ void Test_CF_CFDP_ReceiveMessage(void) /* failure in CFE_SB_ReceiveBuffer */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); - config->chan[UT_CFDP_CHANNEL].rx_max_messages_per_wakeup = 1; + chan->config.rx_max_messages_per_wakeup = 1; UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 1, CFE_SB_NO_MESSAGE); UtAssert_VOIDCALL(CF_CFDP_ReceiveMessage(chan)); @@ -256,14 +258,15 @@ void Test_CF_CFDP_ReceiveMessage(void) void Test_CF_CFDP_Send(void) { /* Test case for: - * void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph) + * void CF_CFDP_Send(CF_Channel_t *chan_ptr, const CF_Logical_PduBuffer_t *ph) */ CF_Logical_PduBuffer_t *ph; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, NULL, NULL); - UtAssert_VOIDCALL(CF_CFDP_Send(UT_CFDP_CHANNEL, ph)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].counters.sent.pdu, 1); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, &chan, NULL, NULL, NULL); + UtAssert_VOIDCALL(CF_CFDP_Send(chan, ph)); + UtAssert_UINT32_EQ(chan->stat.counters.sent.pdu, 1); UtAssert_STUB_COUNT(CFE_MSG_SetSize, 1); UtAssert_STUB_COUNT(CFE_SB_TransmitBuffer, 1); } @@ -273,27 +276,30 @@ void Test_CF_CFDP_MsgOutGet(void) /* Test case for: CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool silent) */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; - CF_Channel_t *chan; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; + CF_Channel_t *chan; /* nominal */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); UtAssert_NOT_NULL(CF_CFDP_MsgOutGet(txn, false)); UtAssert_STUB_COUNT(CFE_SB_ReleaseMessageBuffer, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* This should discard the old message, and get a new one */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); UtAssert_NOT_NULL(CF_CFDP_MsgOutGet(txn, false)); UtAssert_STUB_COUNT(CFE_SB_ReleaseMessageBuffer, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* test the various throttling mechanisms */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, &config); - config->chan[UT_CFDP_CHANNEL].max_outgoing_messages_per_wakeup = 3; + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); + chan->config.max_outgoing_messages_per_wakeup = 3; + chan->outgoing_counter = 2; UtAssert_NOT_NULL(CF_CFDP_MsgOutGet(txn, false)); + UtAssert_BOOL_FALSE(chan->tx_blocked); UtAssert_NULL(CF_CFDP_MsgOutGet(txn, false)); + UtAssert_BOOL_TRUE(chan->tx_blocked); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); @@ -304,25 +310,25 @@ void Test_CF_CFDP_MsgOutGet(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* transaction is suspended */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->flags.com.suspended = true; UtAssert_NULL(CF_CFDP_MsgOutGet(txn, false)); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* channel is frozen */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].frozen = 1; + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); + chan->stat.frozen = 1; UtAssert_NULL(CF_CFDP_MsgOutGet(txn, false)); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].frozen = 0; + chan->stat.frozen = 0; /* no msg available from SB */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); UtAssert_NULL(CF_CFDP_MsgOutGet(txn, false)); UT_CF_AssertEventID(CF_CFDP_NO_MSG_ERR_EID); /* same, but the silent flag should suppress the event */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); UtAssert_NULL(CF_CFDP_MsgOutGet(txn, true)); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 6383e3ee..c39560d3 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -69,7 +69,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, CF_Channel_t **channel_p, CF_History_t **history_p, CF_Transaction_t **txn_p, - CF_ConfigTable_t **config_table_p) + CF_EngineConfig_t **config_table_p) { /* * fake objects used to pass into CF app during unit tests. @@ -78,7 +78,9 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Logical_PduBuffer_t ut_pdu_buffer; static CF_History_t ut_history; static CF_Transaction_t ut_transaction; - static CF_ConfigTable_t ut_config_table; + + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; /* * always clear all objects, regardless of what was asked for. @@ -88,12 +90,11 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, memset(&ut_pdu_buffer, 0, sizeof(ut_pdu_buffer)); memset(&ut_history, 0, sizeof(ut_history)); memset(&ut_transaction, 0, sizeof(ut_transaction)); - memset(&ut_config_table, 0, sizeof(ut_config_table)); /* certain pointers should be connected even if they were not asked for, * as internal code may assume these are set (test cases may un-set) */ ut_transaction.history = &ut_history; - CF_AppData.config_table = &ut_config_table; + ut_transaction.chan_ptr = local_channel_p; if (pdu_buffer_p) { @@ -117,7 +118,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, * a member of that array, so for now it must be so. * This always uses the same channel for now. */ - *channel_p = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + *channel_p = local_channel_p; } if (history_p) { @@ -129,7 +130,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, } if (config_table_p) { - *config_table_p = &ut_config_table; + *config_table_p = &engine_ptr->config; } if (setup == UT_CF_Setup_TX) @@ -146,10 +147,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, UT_CFDP_SetupBasicRxState(&ut_pdu_buffer); } - UT_SetDefaultReturnValue(UT_KEY(CF_GetChannelFromTxn), - (UT_IntReturn_t)&CF_AppData.engine.channels[UT_CFDP_CHANNEL]); - UT_SetDefaultReturnValue(UT_KEY(CF_GetChunkListHead), - (UT_IntReturn_t)&CF_AppData.engine.channels[UT_CFDP_CHANNEL].cs[ut_history.dir]); + UT_SetDefaultReturnValue(UT_KEY(CF_GetChunkListHead), (UT_IntReturn_t)&local_channel_p->cs[ut_history.dir]); /* reset the event ID capture between each sub-case */ UT_CF_ResetEventCapture(); @@ -252,8 +250,8 @@ void Test_CF_CFDP_ArmAckTimer(void) /* Test case for: * void CF_CFDP_ArmAckTimer(CF_Transaction_t *txn) */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); @@ -264,35 +262,35 @@ void Test_CF_CFDP_ArmAckTimer(void) void Test_CF_CFDP_RecvPh(void) { /* Test case for: - * int CF_CFDP_RecvPh(uint8 chan_num, const CFE_SB_Buffer_t *msgbuf, CF_Logical_PduBuffer_t **pph) + * int CF_CFDP_RecvPh(CF_Channel_t *chan_ptr, const CFE_SB_Buffer_t *msgbuf, CF_Logical_PduBuffer_t **pph) */ CF_Logical_PduBuffer_t *ph; /* nominal, file directive */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL); - UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), 0); + UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL_PTR, ph), 0); /* nominal, file data */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL); ph->pdu_header.pdu_type = 1; - UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), 0); + UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL_PTR, ph), 0); /* decode error, fixed part */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL); CF_CODEC_SET_DONE(ph->pdec); - UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), CF_SHORT_PDU_ERROR); + UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL_PTR, ph), CF_SHORT_PDU_ERROR); UT_CF_AssertEventID(CF_PDU_SHORT_HEADER_ERR_EID); /* decode error, large file bit set */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL); ph->pdu_header.large_flag = true; - UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), CF_ERROR); + UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL_PTR, ph), CF_ERROR); UT_CF_AssertEventID(CF_PDU_LARGE_FILE_ERR_EID); /* decode error, insufficient storage for EID or seq num */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, &ph, NULL, NULL, NULL, NULL); UT_SetDeferredRetcode(UT_KEY(CF_CFDP_DecodeHeader), 1, CF_ERROR); - UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL, ph), CF_ERROR); + UtAssert_INT32_EQ(CF_CFDP_RecvPh(UT_CFDP_CHANNEL_PTR, ph), CF_ERROR); UT_CF_AssertEventID(CF_PDU_TRUNCATION_ERR_EID); } @@ -820,7 +818,7 @@ void Test_CF_CFDP_AppendTlv(void) This helper is used by EOF and FIN to set TLV values */ CF_Logical_PduBuffer_t *ph; - CF_ConfigTable_t *config; + CF_EngineConfig_t *config; CF_Logical_TlvList_t *tlv_list; UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, &ph, NULL, NULL, NULL, &config); @@ -847,56 +845,64 @@ void Test_CF_CFDP_InitEngine(void) /* Test case for: * int32 CF_CFDP_InitEngine(void) */ - CF_ConfigTable_t *config; + CF_EngineConfig_t *config; + CF_Channel_t *chan; + CF_Engine_t *engine_ptr = CF_GetEngine(); /* nominal call, no sem */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), 0); - UtAssert_BOOL_TRUE(CF_AppData.engine.enabled); - UtAssert_STUB_COUNT(CF_FreeTransaction, CF_NUM_TRANSACTIONS_PER_CHANNEL * CF_NUM_CHANNELS); + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), 0); + UtAssert_BOOL_TRUE(engine_ptr->enabled); /* nominal call, with sem */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); - config->chan[0].sem_name[0] = 'u'; - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), 0); - UtAssert_BOOL_TRUE(CF_AppData.engine.enabled); + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); + chan->config.sem_name[0] = 'u'; + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), 0); + UtAssert_BOOL_TRUE(engine_ptr->enabled); /* failure of OS_CountSemGetIdByName for non-name reason */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); - config->chan[0].sem_name[0] = 'u'; + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); + chan->config.sem_name[0] = 'u'; UT_SetDefaultReturnValue(UT_KEY(OS_CountSemGetIdByName), OS_ERROR); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), OS_ERROR); - UtAssert_BOOL_FALSE(CF_AppData.engine.enabled); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), OS_ERROR); + UtAssert_BOOL_FALSE(engine_ptr->enabled); UT_CF_AssertEventID(CF_INIT_SEM_ERR_EID); /* Max retries of OS_CountSemGetIdByName - sem was never created at all */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); - config->chan[0].sem_name[0] = 'u'; + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); + chan->config.sem_name[0] = 'u'; UT_SetDefaultReturnValue(UT_KEY(OS_CountSemGetIdByName), OS_ERR_NAME_NOT_FOUND); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), OS_ERR_NAME_NOT_FOUND); - UtAssert_BOOL_FALSE(CF_AppData.engine.enabled); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), OS_ERR_NAME_NOT_FOUND); + UtAssert_BOOL_FALSE(engine_ptr->enabled); UT_CF_AssertEventID(CF_INIT_SEM_ERR_EID); /* Retry of OS_CountSemGetIdByName, when sem was created late, and thus * got return OS_ERR_NAME_NOT_FOUND followed by OS_SUCCESS */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); - config->chan[0].sem_name[0] = 'u'; + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); + chan->config.sem_name[0] = 'u'; UT_SetDefaultReturnValue(UT_KEY(OS_CountSemGetIdByName), OS_SUCCESS); UT_SetDeferredRetcode(UT_KEY(OS_CountSemGetIdByName), 1, OS_ERR_NAME_NOT_FOUND); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), 0); - UtAssert_BOOL_TRUE(CF_AppData.engine.enabled); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), 0); + UtAssert_BOOL_TRUE(engine_ptr->enabled); /* failure of CFE_SB_CreatePipe */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, CFE_STATUS_EXTERNAL_RESOURCE_FAIL); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); - UtAssert_BOOL_FALSE(CF_AppData.engine.enabled); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); + UtAssert_BOOL_FALSE(engine_ptr->enabled); /* failure of CFE_SB_SubscribeLocal */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, NULL, &config); + memset(engine_ptr, 0, sizeof(*engine_ptr)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, &config); UT_SetDeferredRetcode(UT_KEY(CFE_SB_SubscribeLocal), 1, CFE_STATUS_EXTERNAL_RESOURCE_FAIL); - UtAssert_INT32_EQ(CF_CFDP_InitEngine(), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); - UtAssert_BOOL_FALSE(CF_AppData.engine.enabled); + UtAssert_INT32_EQ(CF_CFDP_InitEngine(engine_ptr), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); + UtAssert_BOOL_FALSE(engine_ptr->enabled); } void Test_CF_CFDP_TxFile(void) @@ -922,7 +928,7 @@ void Test_CF_CFDP_TxFile(void) UT_SetHandlerFunction(UT_KEY(CF_FindUnusedTransaction), UT_AltHandler_GenericPointerReturn, txn); UT_SetHandlerFunction(UT_KEY(CF_CList_Pop), UT_AltHandler_GenericPointerReturn, &chunk_wrap.cl_node); chan->cs[CF_Direction_TX] = &chunk_wrap.cl_node; - UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_CLASS_1, 1, UT_CFDP_CHANNEL, 0, 1), 0); + UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_1, 1, UT_CFDP_CHANNEL_PTR, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); UtAssert_UINT32_EQ(chan->num_cmd_tx, 1); @@ -933,7 +939,7 @@ void Test_CF_CFDP_TxFile(void) UT_SetHandlerFunction(UT_KEY(CF_FindUnusedTransaction), UT_AltHandler_GenericPointerReturn, txn); UT_SetHandlerFunction(UT_KEY(CF_CList_Pop), UT_AltHandler_GenericPointerReturn, &chunk_wrap.cl_node); chan->cs[CF_Direction_TX] = &chunk_wrap.cl_node; - UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_CLASS_2, 1, UT_CFDP_CHANNEL, 0, 1), 0); + UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_2, 1, UT_CFDP_CHANNEL_PTR, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); UtAssert_UINT32_EQ(chan->num_cmd_tx, 2); @@ -942,29 +948,30 @@ void Test_CF_CFDP_TxFile(void) /* max TX */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, &history, &txn, NULL); chan->num_cmd_tx = CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN; - UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_CLASS_1, 1, UT_CFDP_CHANNEL, 0, 1), -1); + UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_1, 1, UT_CFDP_CHANNEL_PTR, 0, 1), -1); UT_CF_AssertEventID(CF_CFDP_MAX_CMD_TX_ERR_EID); } void Test_CF_CFDP_StartRxTransaction(void) { /* Test case for: - * CF_Transaction_t *CF_CFDP_StartRxTransaction(uint8 chan_num); + * CF_Transaction_t *CF_CFDP_StartRxTransaction(CF_Channel_t *chan_ptr); */ CF_Transaction_t *txn; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; /* Reject at limit */ - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_RX] = CF_MAX_SIMULTANEOUS_RX; - UtAssert_NULL(CF_CFDP_StartRxTransaction(UT_CFDP_CHANNEL)); + chan->stat.q_size[CF_QueueIdx_RX] = CF_MAX_SIMULTANEOUS_RX; + UtAssert_NULL(CF_CFDP_StartRxTransaction(chan)); /* Under limit but FindUnusedTransaction still fails */ - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_RX] = CF_MAX_SIMULTANEOUS_RX - 1; - UtAssert_NULL(CF_CFDP_StartRxTransaction(UT_CFDP_CHANNEL)); + chan->stat.q_size[CF_QueueIdx_RX] = CF_MAX_SIMULTANEOUS_RX - 1; + UtAssert_NULL(CF_CFDP_StartRxTransaction(chan)); /* Set so FindUnusedTransaction returns non-null (nominal) */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); UT_SetHandlerFunction(UT_KEY(CF_FindUnusedTransaction), UT_AltHandler_GenericPointerReturn, txn); - UtAssert_ADDRESS_EQ(CF_CFDP_StartRxTransaction(UT_CFDP_CHANNEL), txn); + UtAssert_ADDRESS_EQ(CF_CFDP_StartRxTransaction(chan), txn); UtAssert_UINT8_EQ(txn->flags.com.q_index, CF_QueueIdx_RX); } @@ -985,7 +992,7 @@ void Test_CF_CFDP_PlaybackDir(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, NULL); pb = &chan->playback[0]; memset(pb, 0, sizeof(*pb)); - UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_CLASS_1, 1, UT_CFDP_CHANNEL, 0, 1), 0); + UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_Class_1, 1, chan, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, pb->fnames.dst_filename, sizeof(pb->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, pb->fnames.src_filename, sizeof(pb->fnames.src_filename)); UtAssert_BOOL_TRUE(pb->diropen); @@ -994,7 +1001,7 @@ void Test_CF_CFDP_PlaybackDir(void) /* OS_DirectoryOpen fail */ memset(pb, 0, sizeof(*pb)); UT_SetDeferredRetcode(UT_KEY(OS_DirectoryOpen), 1, OS_ERROR); - UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_CLASS_1, 1, UT_CFDP_CHANNEL, 0, 1), -1); + UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_Class_1, 1, chan, 0, 1), -1); UT_CF_AssertEventID(CF_CFDP_OPENDIR_ERR_EID); /* no non-busy entries */ @@ -1004,16 +1011,18 @@ void Test_CF_CFDP_PlaybackDir(void) pb = &chan->playback[i]; pb->busy = true; } - UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_CLASS_1, 1, UT_CFDP_CHANNEL, 0, 1), -1); + UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_Class_1, 1, chan, 0, 1), -1); UT_CF_AssertEventID(CF_CFDP_DIR_SLOT_ERR_EID); } static int32 Ut_Hook_StateHandler_SetCount(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context) { + CF_Channel_t *chan = UserObj; + if (CallCount < 3) { - ++CF_AppData.engine.channels[UT_CFDP_CHANNEL].outgoing_counter; + ++chan->outgoing_counter; } return StubRetcode; } @@ -1027,12 +1036,12 @@ void Test_CF_CFDP_S_Tick_NewData(void) CF_Channel_t *chan; /* suspended (do nothing) */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); txn->flags.com.suspended = true; UtAssert_VOIDCALL(CF_CFDP_S_Tick_NewData(txn)); /* nominal, not in normal data state (do nothing) */ - UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); txn->flags.com.suspended = false; txn->state_data.sub_state = CF_TxSubState_DATA_EOF; UtAssert_VOIDCALL(CF_CFDP_S_Tick_NewData(txn)); @@ -1041,13 +1050,15 @@ void Test_CF_CFDP_S_Tick_NewData(void) UT_SetHandlerFunction(UT_KEY(CF_GetChannelFromTxn), UT_AltHandler_GenericPointerReturn, chan); txn->flags.com.suspended = false; txn->state_data.sub_state = CF_TxSubState_DATA_NORMAL; - UT_SetHookFunction(UT_KEY(CF_CFDP_S_SubstateSendFileData), Ut_Hook_StateHandler_SetCount, NULL); + UT_SetHookFunction(UT_KEY(CF_CFDP_S_SubstateSendFileData), Ut_Hook_StateHandler_SetCount, chan); UtAssert_VOIDCALL(CF_CFDP_S_Tick_NewData(txn)); } static void DoTickFnSetBlocked(CF_Transaction_t *txn) { - CF_AppData.engine.channels[txn->chan_num].tx_blocked = true; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + + chan->tx_blocked = true; } static void DoTickNoop(CF_Transaction_t *txn) @@ -1099,25 +1110,25 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) /* Test case for: * void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) */ - CF_Channel_t *chan; - CF_ConfigTable_t *config; - CF_PollDir_t *pdcfg; - CF_Poll_t *poll; + CF_Channel_t *chan; + CF_EngineConfig_t *config; + CF_LocalPdConfig_t *pdcfg; + CF_Poll_t *poll; UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, NULL, &config); - pdcfg = &config->chan[UT_CFDP_CHANNEL].polldir[0]; + pdcfg = &chan->config.polldir[0]; poll = &chan->poll[0]; /* nominal call, polldir disabled (noop) */ UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].poll_counter, 0); + UtAssert_UINT32_EQ(chan->stat.poll_counter, 0); /* nominal call, polldir enabled but interval_sec == 0 */ /* Will tick because CF_Timer_Expired stub returns 0 by default (not expired) */ pdcfg->enabled = 1; UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); UtAssert_BOOL_FALSE(poll->timer_set); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1); + UtAssert_UINT32_EQ(chan->stat.poll_counter, 1); UtAssert_STUB_COUNT(CF_Timer_Tick, 1); /* with interval_sec nonzero the timer should get set, but not tick */ @@ -1125,7 +1136,7 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); UtAssert_BOOL_TRUE(poll->timer_set); UtAssert_STUB_COUNT(CF_Timer_Tick, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1); + UtAssert_UINT32_EQ(chan->stat.poll_counter, 1); /* call again should tick */ UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); @@ -1137,7 +1148,7 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); UtAssert_BOOL_FALSE(poll->timer_set); UtAssert_BOOL_TRUE(poll->pb.busy); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].poll_counter, 1); + UtAssert_UINT32_EQ(chan->stat.poll_counter, 1); /* make an error occur in CF_CFDP_PlaybackDir_Initiate() */ poll->pb.busy = false; /* above would have set it true */ @@ -1167,7 +1178,7 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) /* test that call to CF_CFDP_UpdatePollPbCounted will decrement back to 0 again */ pdcfg->enabled = 0; UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].poll_counter, 0); + UtAssert_UINT32_EQ(chan->stat.poll_counter, 0); } void Test_CF_CFDP_ProcessPlaybackDirectory(void) @@ -1175,19 +1186,20 @@ void Test_CF_CFDP_ProcessPlaybackDirectory(void) /* Test case for: * void CF_CFDP_ProcessPlaybackDirectory(CF_Channel_t *chan, CF_Playback_t *pb) */ - CF_Transaction_t *txn; - CF_History_t *history; - CF_Channel_t *chan; - CF_ConfigTable_t *config; - CF_Playback_t pb; - os_dirent_t dirent[3]; - CF_ChunkWrapper_t chunk_wrap; + CF_Transaction_t *txn; + CF_History_t *history; + CF_Channel_t *chan; + CF_EngineConfig_t *config; + CF_Playback_t pb; + os_dirent_t dirent[3]; + CF_ChunkWrapper_t chunk_wrap; + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&chunk_wrap, 0, sizeof(chunk_wrap)); memset(&pb, 0, sizeof(pb)); memset(dirent, 0, sizeof(dirent)); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, &history, &txn, &config); - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; /* diropen is true but num_ts is high so operations are restricted */ pb.busy = true; @@ -1262,9 +1274,11 @@ static int32 Ut_Hook_TickTransactions_UpdateCount(void *UserOb uint32 CallCount, const UT_StubContext_t *Context) { + CF_Channel_t *chan = UserObj; + if (CallCount < 5) { - ++CF_AppData.engine.channels[UT_CFDP_CHANNEL].outgoing_counter; + ++chan->outgoing_counter; } return StubRetcode; @@ -1283,12 +1297,12 @@ void Test_CF_CFDP_TickTransactions(void) UtAssert_STUB_COUNT(CF_CList_Traverse, 4); UT_ResetState(UT_KEY(CF_CList_Traverse)); - UT_SetHookFunction(UT_KEY(CF_CList_Traverse), Ut_Hook_TickTransactions_SetBlocked, NULL); + UT_SetHookFunction(UT_KEY(CF_CList_Traverse), Ut_Hook_TickTransactions_SetBlocked, chan); UtAssert_VOIDCALL(CF_CFDP_TickTransactions(chan)); UtAssert_STUB_COUNT(CF_CList_Traverse, 2); UT_ResetState(UT_KEY(CF_CList_Traverse)); - UT_SetHookFunction(UT_KEY(CF_CList_Traverse), Ut_Hook_TickTransactions_UpdateCount, NULL); + UT_SetHookFunction(UT_KEY(CF_CList_Traverse), Ut_Hook_TickTransactions_UpdateCount, chan); chan->tx_blocked = false; UtAssert_VOIDCALL(CF_CFDP_TickTransactions(chan)); UtAssert_STUB_COUNT(CF_CList_Traverse, 7); /* because NAK is repeated several times */ @@ -1299,6 +1313,7 @@ void Test_CF_CFDP_CycleEngine(void) /* Test case for: * void CF_CFDP_CycleEngine(void) */ + CF_Engine_t *engine_ptr = CF_GetEngine(); CF_Channel_t *chan; /* nominal with engine disabled, noop */ @@ -1306,11 +1321,11 @@ void Test_CF_CFDP_CycleEngine(void) UtAssert_VOIDCALL(CF_CFDP_CycleEngine()); /* enabled but frozen */ - CF_AppData.engine.enabled = true; - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].frozen = 1; + engine_ptr->enabled = true; + chan->stat.frozen = 1; UtAssert_VOIDCALL(CF_CFDP_CycleEngine()); - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].frozen = 0; + chan->stat.frozen = 0; UtAssert_VOIDCALL(CF_CFDP_CycleEngine()); } @@ -1322,12 +1337,12 @@ void Test_CF_CFDP_FinishTransaction(void) CF_Transaction_t *txn; CF_History_t *history; - CF_Channel_t *chan; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; CF_Playback_t pb; memset(&pb, 0, sizeof(pb)); - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_TX] = 10; + chan->stat.q_size[CF_QueueIdx_TX] = 10; /* Attempt to reset a transaction that has already been freed*/ UT_CFDP_SetupBasicTestState(UT_CF_Setup_RX, NULL, NULL, NULL, &txn, NULL); @@ -1398,8 +1413,9 @@ void Test_CF_CFDP_RecycleTransaction(void) */ CF_Transaction_t *txn; CF_ChunkWrapper_t cl; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_TX] = 10; + chan->stat.q_size[CF_QueueIdx_TX] = 10; /* nominal */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, NULL, NULL, &txn, NULL); @@ -1436,7 +1452,7 @@ void Test_CF_CFDP_RecycleTransaction(void) UtAssert_VOIDCALL(CF_CFDP_RecycleTransaction(txn)); /* Invalid - channel not known */ - UT_ResetState(UT_KEY(CF_GetChannelFromTxn)); + txn->chan_ptr = NULL; UtAssert_VOIDCALL(CF_CFDP_RecycleTransaction(txn)); } @@ -1502,18 +1518,20 @@ void Test_CF_CFDP_DisableEngine(void) /* Test case for: * void CF_CFDP_DisableEngine(void) */ + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; /* nominal call */ - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; UtAssert_VOIDCALL(CF_CFDP_DisableEngine()); - UtAssert_STUB_COUNT(CFE_SB_DeletePipe, CF_NUM_CHANNELS); - UtAssert_BOOL_FALSE(CF_AppData.engine.enabled); + UtAssert_STUB_COUNT(CFE_SB_DeletePipe, 1); + UtAssert_BOOL_FALSE(engine_ptr->enabled); /* nominal call with playbacks and polls active */ - CF_AppData.engine.channels[UT_CFDP_CHANNEL].playback[0].busy = true; - OS_DirectoryOpen(&CF_AppData.engine.channels[UT_CFDP_CHANNEL].playback[0].dir_id, "ut"); - CF_AppData.engine.channels[UT_CFDP_CHANNEL].poll[0].pb.busy = true; - OS_DirectoryOpen(&CF_AppData.engine.channels[UT_CFDP_CHANNEL].poll[0].pb.dir_id, "ut"); + chan->playback[0].busy = true; + OS_DirectoryOpen(&chan->playback[0].dir_id, "ut"); + chan->poll[0].pb.busy = true; + OS_DirectoryOpen(&chan->poll[0].pb.dir_id, "ut"); UtAssert_VOIDCALL(CF_CFDP_DisableEngine()); UtAssert_STUB_COUNT(OS_DirectoryClose, 2); } @@ -1581,29 +1599,30 @@ void Test_CF_CFDP_CheckAckNakCount(void) /* Test Case For: * bool CF_CFDP_CheckAckNakCount(CF_Transaction_t *txn, uint8 *counter) */ - CF_Transaction_t *txn; - CF_ConfigTable_t *config; - uint8 counter; + CF_Transaction_t *txn; + CF_EngineConfig_t *config; + CF_Channel_t *chan; + uint8 counter; - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); - config->chan[txn->chan_num].ack_limit = 10; + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); + chan->config.ack_limit = 10; counter = 9; UtAssert_BOOL_TRUE(CF_CFDP_CheckAckNakCount(txn, &counter)); UtAssert_UINT8_EQ(counter, 10); - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); - counter = config->chan[txn->chan_num].ack_limit; + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); + counter = chan->config.ack_limit; txn->history->dir = CF_Direction_RX; UtAssert_BOOL_FALSE(CF_CFDP_CheckAckNakCount(txn, &counter)); - UtAssert_UINT8_EQ(counter, config->chan[txn->chan_num].ack_limit); + UtAssert_UINT8_EQ(counter, chan->config.ack_limit); UT_CF_AssertEventID(CF_CFDP_R_ACK_LIMIT_ERR_EID); - UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, &config); - counter = config->chan[txn->chan_num].ack_limit; + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, &config); + counter = chan->config.ack_limit; txn->history->dir = CF_Direction_TX; UtAssert_BOOL_FALSE(CF_CFDP_CheckAckNakCount(txn, &counter)); - UtAssert_UINT8_EQ(counter, config->chan[txn->chan_num].ack_limit); + UtAssert_UINT8_EQ(counter, chan->config.ack_limit); UT_CF_AssertEventID(CF_CFDP_S_ACK_LIMIT_ERR_EID); } @@ -1653,32 +1672,32 @@ void Test_CF_CFDP_SetupTxTransaction(void) */ CF_Transaction_t txn; CF_History_t hist; - CF_ConfigTable_t config; CF_CListNode_t *list_ptr; CF_ChunkWrapper_t chunks; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - memset(&config, 0, sizeof(config)); memset(&chunks, 0, sizeof(chunks)); - CF_AppData.config_table = &config; - list_ptr = NULL; + list_ptr = NULL; UT_SetHandlerFunction(UT_KEY(CF_GetChunkListHead), UT_AltHandler_GenericPointerReturn, &list_ptr); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); - txn.history = &hist; + txn.history = &hist; + txn.chan_ptr = chan; CF_CFDP_SetTxnStatus(&txn, CF_TxnStatus_PROTOCOL_ERROR); - CF_AppData.hk.Payload.channel_hk[txn.chan_num].q_size[txn.flags.com.q_index] = 1; + chan->stat.q_size[txn.flags.com.q_index] = 1; UtAssert_VOIDCALL(CF_CFDP_SetupTxTransaction(&txn)); UtAssert_STUB_COUNT(CF_CFDP_S_Init, 0); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); - txn.chunks = &chunks; - txn.history = &hist; + txn.chunks = &chunks; + txn.history = &hist; + txn.chan_ptr = chan; - CF_AppData.hk.Payload.channel_hk[txn.chan_num].q_size[txn.flags.com.q_index] = 1; + chan->stat.q_size[txn.flags.com.q_index] = 1; UtAssert_VOIDCALL(CF_CFDP_SetupTxTransaction(&txn)); UtAssert_STUB_COUNT(CF_CFDP_S_Init, 1); } @@ -1689,6 +1708,7 @@ void Test_CF_CFDP_TxnStatus(void) /* Check that it is safe to call these routines on a wiped txn */ memset(&txn, 0, sizeof(txn)); + txn.chan_ptr = UT_CFDP_CHANNEL_PTR; UtAssert_VOIDCALL(CF_CFDP_GetTxnStatus(&txn)); UtAssert_VOIDCALL(CF_CFDP_SetTxnStatus(&txn, CF_TxnStatus_ACK_LIMIT_NO_EOF)); } @@ -1702,46 +1722,47 @@ void Test_CF_CFDP_SetupRxTransaction(void) CF_Logical_PduBuffer_t ph; CF_History_t hist; CF_ChunkWrapper_t chunks; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - CF_ConfigTable_t config; - CF_CListNode_t *list_ptr; + CF_CListNode_t *list_ptr; - memset(&config, 0, sizeof(config)); memset(&ph, 0, sizeof(ph)); memset(&chunks, 0, sizeof(chunks)); - CF_AppData.config_table = &config; - list_ptr = NULL; + list_ptr = NULL; UT_SetHandlerFunction(UT_KEY(CF_GetChunkListHead), UT_AltHandler_GenericPointerReturn, &list_ptr); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); - txn.history = &hist; + txn.history = &hist; + txn.chan_ptr = chan; CF_CFDP_SetTxnStatus(&txn, CF_TxnStatus_PROTOCOL_ERROR); - CF_AppData.hk.Payload.channel_hk[txn.chan_num].q_size[txn.flags.com.q_index] = 1; + chan->stat.q_size[txn.flags.com.q_index] = 1; UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_NULL(txn.chunks); UtAssert_UINT32_EQ(txn.state, CF_TxnState_HOLD); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); - txn.history = &hist; - txn.chunks = &chunks; + txn.history = &hist; + txn.chunks = &chunks; + txn.chan_ptr = chan; - CF_AppData.hk.Payload.channel_hk[txn.chan_num].q_size[txn.flags.com.q_index] = 1; - ph.pdu_header.txm_mode = 1; + chan->stat.q_size[txn.flags.com.q_index] = 1; + ph.pdu_header.txm_mode = 1; UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_UINT32_EQ(txn.state, CF_TxnState_R1); UtAssert_STUB_COUNT(CF_CFDP_R_Init, 1); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); - txn.history = &hist; - txn.chunks = &chunks; + txn.history = &hist; + txn.chunks = &chunks; + txn.chan_ptr = chan; - CF_AppData.hk.Payload.channel_hk[txn.chan_num].q_size[txn.flags.com.q_index] = 1; - ph.pdu_header.txm_mode = 0; + chan->stat.q_size[txn.flags.com.q_index] = 1; + ph.pdu_header.txm_mode = 0; UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_UINT32_EQ(txn.state, CF_TxnState_R2); UtAssert_STUB_COUNT(CF_CFDP_R_Init, 2); @@ -1755,7 +1776,7 @@ void Test_CF_CFDP_ReceivePdu(void) CF_Channel_t *chan; CF_Logical_PduBuffer_t *ph; CF_Transaction_t *txn; - CF_ConfigTable_t *config; + CF_EngineConfig_t *config; CF_ChunkWrapper_t chunk_wrap; memset(&chunk_wrap, 0, sizeof(chunk_wrap)); @@ -1823,7 +1844,7 @@ void Test_CF_CFDP_StartFirstPending(void) chan->qs[CF_QueueIdx_PEND] = &txn->cl_node; /* this dequeues */ - CF_AppData.hk.Payload.channel_hk[txn->chan_num].q_size[txn->flags.com.q_index] = 1; + chan->stat.q_size[txn->flags.com.q_index] = 1; UtAssert_BOOL_TRUE(CF_CFDP_StartFirstPending(chan)); } @@ -1838,28 +1859,25 @@ void Test_CF_CFDP_CompleteTick(void) CF_Channel_t *chan; UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - UT_SetHandlerFunction(UT_KEY(CF_GetChannelFromTxn), UT_AltHandler_GenericPointerReturn, chan); chan->tx_blocked = true; chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_ADDRESS_EQ(chan->tick_resume, txn); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - UT_SetHandlerFunction(UT_KEY(CF_GetChannelFromTxn), UT_AltHandler_GenericPointerReturn, chan); chan->tx_blocked = true; chan->tick_resume = &txn2; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_ADDRESS_EQ(chan->tick_resume, &txn2); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - UT_SetHandlerFunction(UT_KEY(CF_GetChannelFromTxn), UT_AltHandler_GenericPointerReturn, chan); chan->tx_blocked = false; chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_NULL(chan->tick_resume); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - UT_ResetState(UT_KEY(CF_GetChannelFromTxn)); + txn->chan_ptr = NULL; chan->tx_blocked = false; chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); @@ -1871,18 +1889,16 @@ void Test_CF_CFDP_GetTempName(void) /* Test Case For: * void CF_CFDP_GetTempName(const CF_History_t *hist, char *FileNameBuf, size_t FileNameSize) */ - CF_History_t hist; - CF_ConfigTable_t config; - char FileNameBuf[12]; + CF_History_t *hist; + CF_EngineConfig_t *config; + char FileNameBuf[12]; - memset(&hist, 0, sizeof(hist)); - memset(&config, 0, sizeof(config)); + UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, &hist, NULL, &config); - CF_AppData.config_table = &config; - strcpy(config.tmp_dir, "ut"); - hist.src_eid = 3; - hist.seq_num = 4; - UtAssert_VOIDCALL(CF_CFDP_GetTempName(&hist, FileNameBuf, sizeof(FileNameBuf))); + strcpy(config->tmp_dir, "ut"); + hist->src_eid = 3; + hist->seq_num = 4; + UtAssert_VOIDCALL(CF_CFDP_GetTempName(hist, FileNameBuf, sizeof(FileNameBuf))); UtAssert_STRINGBUF_EQ(FileNameBuf, sizeof(FileNameBuf), "ut/3_4.tmp", -1); } diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index fc06f8e2..60b49486 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -50,14 +50,8 @@ CF_EntityId_t Any_CF_EntityId_t(void) return (CF_EntityId_t)Any_uint8(); } -/* uint8 used for Any_cf_channel likely there will never be that many channels */ -uint8 Any_cf_channel(void) -{ - return Any_uint8_LessThan(CF_NUM_CHANNELS); -} - /* uint8 used for Any_cf_polldir likely there will never be that many polldirs */ -uint8 Any_cf_polldir(void) +CF_PollIdxSelect_t Any_cf_polldir(void) { return Any_uint8_LessThan(CF_MAX_POLLING_DIR_PER_CHAN); } @@ -68,7 +62,7 @@ uint8 Any_bool_arg_t_barg(void) return AnyCoinFlip(); } -uint8 Any_queue_Except_q_pend(void) +CF_QueueSelect_Enum_t Any_queue_Except_q_pend(void) { /* q_pend = 0, q_active = 1, q_history = 2, q_all = 3 */ return (rand() % 2) + 1; /* 0-2, + 1 -> 1-3 */ @@ -91,7 +85,7 @@ typedef struct void *context; } CF_TsnChanAction_fn_t_context_t; -CF_ChanAction_Status_t Chan_action_fn_t(uint8 chan_num, void *context) +CF_ChanAction_Status_t Chan_action_fn_t(CF_Channel_t *chan_ptr, void *context) { /* This one does not need to save its context, just call default so count works */ return UT_DEFAULT_IMPL(Chan_action_fn_t); @@ -125,7 +119,7 @@ void Test_CF_NoopCmd_SendNoopEventAndAcceptCommand(void) uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_NoopCmd(&utbuf); @@ -134,7 +128,7 @@ void Test_CF_NoopCmd_SendNoopEventAndAcceptCommand(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_NOOP_INF_EID); /* Assert to show counter incremented */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } /******************************************************************************* @@ -146,15 +140,15 @@ void Test_CF_NoopCmd_SendNoopEventAndAcceptCommand(void) void Test_CF_ResetCountersCmd_tests_WhenCommandByteIsEqTo_5_SendEventAndRejectCommand(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = 5; /* 5 is size of 'names' */ + data->ResetType = 5; /* 5 is size of 'names' */ - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_ResetCountersCmd(&utbuf); @@ -163,21 +157,21 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIsEqTo_5_SendEventAndRejectCo UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_RESET_INVALID_ERR_EID); /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_ResetCountersCmd_tests_WhenCommandByteIsGreaterThan_5_SendEventAndRejectCommand(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = Any_uint8_GreaterThan(5); /* 5 is size of 'names' */ + data->ResetType = Any_uint8_GreaterThan(5); /* 5 is size of 'names' */ - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_ResetCountersCmd(&utbuf); @@ -186,20 +180,20 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIsGreaterThan_5_SendEventAndR UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_RESET_INVALID_ERR_EID); /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_command_AndResetHkCmdAndErrCountSendEvent(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = CF_Reset_command; - CF_AppData.hk.Payload.counters.cmd = Any_uint16_Except(0); - CF_AppData.hk.Payload.counters.err = Any_uint16_Except(0); + data->ResetType = CF_Reset_command; + CF_AppData.counters.cmd = Any_uint16_Except(0); + CF_AppData.counters.err = Any_uint16_Except(0); /* Act */ CF_ResetCountersCmd(&utbuf); @@ -207,240 +201,202 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_command_AndResetHkCmdAndEr /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_RESET_INF_EID); - UtAssert_ZERO(CF_AppData.hk.Payload.counters.cmd); - UtAssert_ZERO(CF_AppData.hk.Payload.counters.err); + UtAssert_ZERO(CF_AppData.counters.cmd); + UtAssert_ZERO(CF_AppData.counters.err); } void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_fault_ResetAllHkFaultCountSendEventAndAcceptCommand(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - int i = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = CF_Reset_fault; + data->ResetType = CF_Reset_fault; - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_open = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_read = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_seek = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_write = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_rename = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.directory_read = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.crc_mismatch = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_size_mismatch = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer = Any_uint16_Except(0); - } + chan->stat.counters.fault.file_open = Any_uint16_Except(0); + chan->stat.counters.fault.file_read = Any_uint16_Except(0); + chan->stat.counters.fault.file_seek = Any_uint16_Except(0); + chan->stat.counters.fault.file_write = Any_uint16_Except(0); + chan->stat.counters.fault.file_rename = Any_uint16_Except(0); + chan->stat.counters.fault.directory_read = Any_uint16_Except(0); + chan->stat.counters.fault.crc_mismatch = Any_uint16_Except(0); + chan->stat.counters.fault.file_size_mismatch = Any_uint16_Except(0); + chan->stat.counters.fault.nak_limit = Any_uint16_Except(0); + chan->stat.counters.fault.ack_limit = Any_uint16_Except(0); + chan->stat.counters.fault.inactivity_timer = Any_uint16_Except(0); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_ResetCountersCmd(&utbuf); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CF_ForEachChannel, 1); UT_CF_AssertEventID(CF_RESET_INF_EID); - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_open); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_read); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_seek); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_write); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_rename); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.directory_read); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.crc_mismatch); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_size_mismatch); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer); - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.fault, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.fault), - "fault channel %d was completely cleared to 0", - i); - } + UtAssert_ZERO(chan->stat.counters.fault.file_open); + UtAssert_ZERO(chan->stat.counters.fault.file_read); + UtAssert_ZERO(chan->stat.counters.fault.file_seek); + UtAssert_ZERO(chan->stat.counters.fault.file_write); + UtAssert_ZERO(chan->stat.counters.fault.file_rename); + UtAssert_ZERO(chan->stat.counters.fault.directory_read); + UtAssert_ZERO(chan->stat.counters.fault.crc_mismatch); + UtAssert_ZERO(chan->stat.counters.fault.file_size_mismatch); + UtAssert_ZERO(chan->stat.counters.fault.nak_limit); + UtAssert_ZERO(chan->stat.counters.fault.ack_limit); + UtAssert_ZERO(chan->stat.counters.fault.inactivity_timer); + UtAssert_MemCmpValue(&chan->stat.counters.fault, + 0, + sizeof(&chan->stat.counters.fault), + "fault channel was completely cleared to 0"); /* Assert to show counter incremented */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_up_AndResetAllHkRecvCountSendEventAndAcceptCommand(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - int i = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = CF_Reset_up; + data->ResetType = CF_Reset_up; - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.recv.file_data_bytes = Any_uint64_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.pdu = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.error = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.spurious = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.dropped = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.nak_segment_requests = Any_uint32_Except(0); - } + chan->stat.counters.recv.file_data_bytes = Any_uint64_Except(0); + chan->stat.counters.recv.pdu = Any_uint32_Except(0); + chan->stat.counters.recv.error = Any_uint32_Except(0); + chan->stat.counters.recv.spurious = Any_uint16_Except(0); + chan->stat.counters.recv.dropped = Any_uint16_Except(0); + chan->stat.counters.recv.nak_segment_requests = Any_uint32_Except(0); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_ResetCountersCmd(&utbuf); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CF_ForEachChannel, 1); UT_CF_AssertEventID(CF_RESET_INF_EID); - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.file_data_bytes); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.pdu); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.error); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.spurious); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.pdu); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.recv.nak_segment_requests); - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.recv, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.recv), - "recv channel %d was completely cleared to 0", - i); - } + UtAssert_ZERO(chan->stat.counters.recv.file_data_bytes); + UtAssert_ZERO(chan->stat.counters.recv.pdu); + UtAssert_ZERO(chan->stat.counters.recv.error); + UtAssert_ZERO(chan->stat.counters.recv.spurious); + UtAssert_ZERO(chan->stat.counters.recv.pdu); + UtAssert_ZERO(chan->stat.counters.recv.nak_segment_requests); + UtAssert_MemCmpValue(&chan->stat.counters.recv, + 0, + sizeof(&chan->stat.counters.recv), + "recv channel was completely cleared to 0"); /* Assert to show counter incremented */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_ResetCountersCmd_tests_SWhenCommandByteIs_down_AndResetAllHkSentCountendEventAcceptCommand(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint8 i = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = CF_Reset_down; + data->ResetType = CF_Reset_down; - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.sent.file_data_bytes = Any_uint64_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.sent.nak_segment_requests = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.sent.pdu = Any_uint32_Except(0); - } + chan->stat.counters.sent.file_data_bytes = Any_uint64_Except(0); + chan->stat.counters.sent.nak_segment_requests = Any_uint32_Except(0); + chan->stat.counters.sent.pdu = Any_uint32_Except(0); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_ResetCountersCmd(&utbuf); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CF_ForEachChannel, 1); UT_CF_AssertEventID(CF_RESET_INF_EID); - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.sent.file_data_bytes); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.sent.nak_segment_requests); - UtAssert_ZERO(CF_AppData.hk.Payload.channel_hk[i].counters.sent.pdu); - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.sent, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.sent), - "sent channel %d was completely cleared to 0", - i); - } + UtAssert_ZERO(chan->stat.counters.sent.file_data_bytes); + UtAssert_ZERO(chan->stat.counters.sent.nak_segment_requests); + UtAssert_ZERO(chan->stat.counters.sent.pdu); + UtAssert_MemCmpValue(&chan->stat.counters.sent, + 0, + sizeof(&chan->stat.counters.sent), + "sent channel was completely cleared to 0"); /* Assert to show counter incremented */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_all_AndResetAllMemValuesSendEvent(void) { /* Arrange */ - CF_ResetCountersCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - int i = 0; + CF_ResetCountersCmd_t utbuf; + CF_ResetCountersCmd_Payload_t *data = &utbuf.Payload; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; memset(&utbuf, 0, sizeof(utbuf)); - data->byte[0] = CF_Reset_all; - - CF_AppData.hk.Payload.counters.cmd = Any_uint16_Except(0); - CF_AppData.hk.Payload.counters.err = Any_uint16_Except(0); - - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_open = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_read = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_seek = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_write = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_rename = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.directory_read = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.crc_mismatch = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.file_size_mismatch = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.nak_limit = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.ack_limit = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.fault.inactivity_timer = Any_uint16_Except(0); - } - - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.recv.file_data_bytes = Any_uint64_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.pdu = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.error = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.spurious = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.dropped = Any_uint16_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.recv.nak_segment_requests = Any_uint32_Except(0); - } - - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - CF_AppData.hk.Payload.channel_hk[i].counters.sent.file_data_bytes = Any_uint64_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.sent.nak_segment_requests = Any_uint32_Except(0); - CF_AppData.hk.Payload.channel_hk[i].counters.sent.pdu = Any_uint32_Except(0); - } + data->ResetType = CF_Reset_all; + + CF_AppData.counters.cmd = Any_uint16_Except(0); + CF_AppData.counters.err = Any_uint16_Except(0); + + chan->stat.counters.fault.file_open = Any_uint16_Except(0); + chan->stat.counters.fault.file_read = Any_uint16_Except(0); + chan->stat.counters.fault.file_seek = Any_uint16_Except(0); + chan->stat.counters.fault.file_write = Any_uint16_Except(0); + chan->stat.counters.fault.file_rename = Any_uint16_Except(0); + chan->stat.counters.fault.directory_read = Any_uint16_Except(0); + chan->stat.counters.fault.crc_mismatch = Any_uint16_Except(0); + chan->stat.counters.fault.file_size_mismatch = Any_uint16_Except(0); + chan->stat.counters.fault.nak_limit = Any_uint16_Except(0); + chan->stat.counters.fault.ack_limit = Any_uint16_Except(0); + chan->stat.counters.fault.inactivity_timer = Any_uint16_Except(0); + + chan->stat.counters.recv.file_data_bytes = Any_uint64_Except(0); + chan->stat.counters.recv.pdu = Any_uint32_Except(0); + chan->stat.counters.recv.error = Any_uint32_Except(0); + chan->stat.counters.recv.spurious = Any_uint16_Except(0); + chan->stat.counters.recv.dropped = Any_uint16_Except(0); + chan->stat.counters.recv.nak_segment_requests = Any_uint32_Except(0); + + chan->stat.counters.sent.file_data_bytes = Any_uint64_Except(0); + chan->stat.counters.sent.nak_segment_requests = Any_uint32_Except(0); + chan->stat.counters.sent.pdu = Any_uint32_Except(0); /* Act */ CF_ResetCountersCmd(&utbuf); /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UtAssert_STUB_COUNT(CF_ForEachChannel, 3); UT_CF_AssertEventID(CF_RESET_INF_EID); - UtAssert_ZERO(CF_AppData.hk.Payload.counters.cmd); - UtAssert_ZERO(CF_AppData.hk.Payload.counters.err); - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.fault, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.fault), - "fault channel %d was completely cleared to 0", - i); - } - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.recv, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.recv), - "recv channel %d was completely cleared to 0", - i); - } - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - UtAssert_MemCmpValue(&CF_AppData.hk.Payload.channel_hk[i].counters.sent, - 0, - sizeof(&CF_AppData.hk.Payload.channel_hk[i].counters.sent), - "sent channel %d was completely cleared to 0", - i); - } + UtAssert_ZERO(CF_AppData.counters.cmd); + UtAssert_ZERO(CF_AppData.counters.err); + UtAssert_MemCmpValue(&chan->stat.counters.fault, + 0, + sizeof(&chan->stat.counters.fault), + "fault channel was completely cleared to 0"); + UtAssert_MemCmpValue(&chan->stat.counters.recv, + 0, + sizeof(&chan->stat.counters.recv), + "recv channel was completely cleared to 0"); + UtAssert_MemCmpValue(&chan->stat.counters.sent, + 0, + sizeof(&chan->stat.counters.sent), + "sent channel was completely cleared to 0"); } /******************************************************************************* @@ -457,21 +413,21 @@ void Test_CF_TxFileCmd(void) CF_TxFileCmd_t utbuf; CF_TxFile_Payload_t *msg = &utbuf.Payload; - memset(&CF_AppData.hk.Payload.counters, 0, sizeof(CF_AppData.hk.Payload.counters)); + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); /* nominal, all zero should pass checks, just calls CF_CFDP_TxFile */ memset(msg, 0, sizeof(*msg)); - msg->cfdp_class = CF_CFDP_CLASS_1; + msg->cfdp_class = CF_CFDP_Class_1; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_TX_FILE_INF_EID); UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); - msg->cfdp_class = CF_CFDP_CLASS_2; + msg->cfdp_class = CF_CFDP_Class_2; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_TX_FILE_INF_EID); @@ -481,14 +437,14 @@ void Test_CF_TxFileCmd(void) msg->cfdp_class = 10; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); msg->cfdp_class = -10; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); /* out of range arguments: bad channel */ UT_CF_ResetEventCapture(); @@ -496,7 +452,7 @@ void Test_CF_TxFileCmd(void) msg->chan_num = CF_NUM_CHANNELS; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 3); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); /* out of range arguments: bad keep */ UT_CF_ResetEventCapture(); @@ -504,7 +460,7 @@ void Test_CF_TxFileCmd(void) msg->keep = 15; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 4); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 4); /* CF_CFDP_TxFile fails*/ UT_CF_ResetEventCapture(); @@ -512,7 +468,7 @@ void Test_CF_TxFileCmd(void) memset(msg, 0, sizeof(*msg)); UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_TX_FILE_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 5); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 5); } /******************************************************************************* @@ -529,32 +485,32 @@ void Test_CF_PlaybackDirCmd(void) CF_PlaybackDirCmd_t utbuf; CF_TxFile_Payload_t *msg = &utbuf.Payload; - memset(&CF_AppData.hk.Payload.counters, 0, sizeof(CF_AppData.hk.Payload.counters)); + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); /* nominal, all zero should pass checks, just calls CF_CFDP_PlaybackDir */ memset(msg, 0, sizeof(*msg)); - msg->cfdp_class = CF_CFDP_CLASS_1; + msg->cfdp_class = CF_CFDP_Class_1; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); memset(msg, 0, sizeof(*msg)); - msg->cfdp_class = CF_CFDP_CLASS_2; + msg->cfdp_class = CF_CFDP_Class_2; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); /* out of range arguments: bad class */ memset(msg, 0, sizeof(*msg)); msg->cfdp_class = 10; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); msg->cfdp_class = -10; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); /* out of range arguments: bad channel */ UT_CF_ResetEventCapture(); @@ -562,7 +518,7 @@ void Test_CF_PlaybackDirCmd(void) msg->chan_num = CF_NUM_CHANNELS; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 3); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); /* out of range arguments: bad keep */ UT_CF_ResetEventCapture(); @@ -570,7 +526,7 @@ void Test_CF_PlaybackDirCmd(void) msg->keep = 15; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 4); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 4); /* CF_CFDP_PlaybackDir fails*/ UT_CF_ResetEventCapture(); @@ -578,7 +534,7 @@ void Test_CF_PlaybackDirCmd(void) memset(msg, 0, sizeof(*msg)); UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_PLAYBACK_DIR_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 5); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 5); } /******************************************************************************* @@ -590,29 +546,22 @@ void Test_CF_PlaybackDirCmd(void) void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - uint8 random_fn_call = Any_uint8_LessThan(CF_NUM_CHANNELS) + 1; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = CF_ALL_CHANNELS; + data = CF_ALL_CHANNELS; - UT_SetDeferredRetcode(UT_KEY(Chan_action_fn_t), random_fn_call, 1); + UT_SetDeferredRetcode(UT_KEY(Chan_action_fn_t), 1, 1); /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, CF_NUM_CHANNELS); + UtAssert_STUB_COUNT(Chan_action_fn_t, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS | 1); } @@ -620,28 +569,22 @@ void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1(void) void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAll_fn_return_1_Return_1(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = CF_ALL_CHANNELS; + data = CF_ALL_CHANNELS; UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 1); /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, CF_NUM_CHANNELS); + UtAssert_STUB_COUNT(Chan_action_fn_t, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS | 1); } @@ -649,28 +592,22 @@ void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAll_fn_return_1_Return_1(void) void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = CF_ALL_CHANNELS; + data = CF_ALL_CHANNELS; UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 0); /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, CF_NUM_CHANNELS); + UtAssert_STUB_COUNT(Chan_action_fn_t, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); } @@ -678,26 +615,20 @@ void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0(void) void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = Any_cf_channel(); + data = Any_cf_chan_num(); UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 1); /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ UtAssert_STUB_COUNT(Chan_action_fn_t, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -707,26 +638,20 @@ void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1(void) void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = Any_cf_channel(); + data = Any_cf_chan_num(); UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 0); /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ UtAssert_STUB_COUNT(Chan_action_fn_t, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -736,24 +661,18 @@ void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1(void) void Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendEvent_(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; - data->byte[0] = CF_NUM_CHANNELS; + data = CF_NUM_CHANNELS; /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ UtAssert_STUB_COUNT(Chan_action_fn_t, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -765,39 +684,19 @@ void Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendE void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - int catastrophe_count = 0; - - memset(&utbuf, 0, sizeof(utbuf)); + CF_ChannelSelect_t data; + const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; + CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; + int context; + void *arg_context = &context; + CF_ChanAction_Status_t local_result; /* force CF_ALL_CHANNELS to not be a selection possibility */ - data->byte[0] = CF_ALL_CHANNELS; - while (data->byte[0] == CF_ALL_CHANNELS) - { - if (catastrophe_count == 10) /* 10 is arbitrary */ - { - UtAssert_Message(UTASSERT_CASETYPE_ABORT, - __FILE__, - __LINE__, - "CANNOT make data->byte[0] != CF_ALL_CHANNELS in 10 tries"); - } - - data->byte[0] = Any_uint8_GreaterThan_or_EqualTo(CF_NUM_CHANNELS); - ++catastrophe_count; - } + data = CF_ALL_CHANNELS - 2; /* Act */ local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - UT_GetStubCount(UT_KEY(Chan_action_fn_t)); - UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); - /* Assert */ UtAssert_STUB_COUNT(Chan_action_fn_t, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); @@ -815,7 +714,7 @@ void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; CF_ChanAction_BoolArg_t context; CF_ChanAction_Status_t local_result; @@ -823,15 +722,15 @@ void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) /* set frozen to opposite to ensure change was done - not required for test, * but it is helpful for verification that the function did the change */ - CF_AppData.hk.Payload.channel_hk[arg_chan_num].frozen = !context.barg; + chan->stat.frozen = !context.barg; /* Act */ - local_result = CF_DoFreezeThaw(arg_chan_num, &context); + local_result = CF_DoFreezeThaw(chan, &context); /* Assert */ - UtAssert_True(CF_AppData.hk.Payload.channel_hk[arg_chan_num].frozen == context.barg, + UtAssert_True(chan->stat.frozen == context.barg, "CF_DoFreezeThaw set frozen to %d and should be %d (context->barg))", - CF_AppData.hk.Payload.channel_hk[arg_chan_num].frozen, + chan->stat.frozen, context.barg); UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); } @@ -845,31 +744,31 @@ void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) void Test_CF_FreezeCmd_Set_frozen_To_1_AndAcceptCommand(void) { /* Arrange */ - CF_FreezeCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); - - /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ - uint8 chan_num = Any_cf_channel(); + CF_FreezeCmd_t utbuf; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan; memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = chan_num; + data->ChannelSelect = Any_cf_chan_num(); + chan = CF_GetChannelPtr(data->ChannelSelect); + chan->stat.frozen = false; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_FreezeCmd(&utbuf); /* Assert */ /* Assert for CF_DoFreezeThaw */ - UtAssert_True(CF_AppData.hk.Payload.channel_hk[chan_num].frozen == 1, + UtAssert_True(chan->stat.frozen == 1, "CF_DoFreezeThaw set frozen to %d and should be 1 (freeze = 1))", - CF_AppData.hk.Payload.channel_hk[chan_num].frozen); - UtAssert_True(CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.cmd, + chan->stat.frozen); + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, initial_hk_cmd_counter); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_FREEZE_INF_EID); @@ -878,23 +777,23 @@ void Test_CF_FreezeCmd_Set_frozen_To_1_AndAcceptCommand(void) void Test_CF_FreezeCmd_Set_frozen_To_1_AndRejectCommand(void) { /* Arrange */ - CF_FreezeCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; + CF_FreezeCmd_t utbuf; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = CF_NUM_CHANNELS + 1; + data->ChannelSelect = CF_NUM_CHANNELS + 1; - CF_AppData.hk.Payload.counters.cmd = 0; + CF_AppData.counters.cmd = 0; /* Act */ CF_FreezeCmd(&utbuf); /* Assert */ /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_FREEZE_ERR_EID); } @@ -907,31 +806,32 @@ void Test_CF_FreezeCmd_Set_frozen_To_1_AndRejectCommand(void) void Test_CF_ThawCmd_Set_frozen_To_0_AndAcceptCommand(void) { /* Arrange */ - CF_ThawCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ThawCmd_t utbuf; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ - uint8 chan_num = Any_cf_channel(); + CF_Channel_t *chan; memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = chan_num; + data->ChannelSelect = Any_cf_chan_num(); + chan = CF_GetChannelPtr(data->ChannelSelect); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_ThawCmd(&utbuf); /* Assert */ /* Assert for CF_DoFreezeThaw */ - UtAssert_True(CF_AppData.hk.Payload.channel_hk[chan_num].frozen == 0, + UtAssert_True(chan->stat.frozen == 0, "CF_DoFreezeThaw set frozen to %d and should be 0 (thaw = 0))", - CF_AppData.hk.Payload.channel_hk[chan_num].frozen); - UtAssert_True(CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.cmd, + chan->stat.frozen); + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, initial_hk_cmd_counter); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_THAW_INF_EID); @@ -940,23 +840,23 @@ void Test_CF_ThawCmd_Set_frozen_To_0_AndAcceptCommand(void) void Test_CF_ThawCmd_Set_frozen_To_0_AndRejectCommand(void) { /* Arrange */ - CF_ThawCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; + CF_ThawCmd_t utbuf; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; /* Arrange unstubbable: CF_DoFreezeThaw via CF_DoChanAction */ memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = CF_NUM_CHANNELS + 1; + data->ChannelSelect = CF_NUM_CHANNELS + 1; - CF_AppData.hk.Payload.counters.cmd = 0; + CF_AppData.counters.cmd = 0; /* Act */ CF_ThawCmd(&utbuf); /* Assert */ /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_THAW_ERR_EID); } @@ -973,6 +873,7 @@ void Test_CF_FindTransactionBySequenceNumberAllChannels_WhenNoTransactionFoundRe CF_EntityId_t arg_eid = Any_CF_EntityId_t(); CF_Transaction_t *local_result; CF_Transaction_t *expected_result = NULL; + CF_Engine_t *engine_ptr = CF_GetEngine(); CF_FindTransactionBySequenceNumber_context_t context_CF_CFDP_FTBSN; @@ -986,11 +887,9 @@ void Test_CF_FindTransactionBySequenceNumberAllChannels_WhenNoTransactionFoundRe /* Act */ local_result = CF_FindTransactionBySequenceNumberAllChannels(arg_ts, arg_eid); - UT_GetStubCount(UT_KEY(CF_FindTransactionBySequenceNumber)); - /* Assert */ UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, CF_NUM_CHANNELS); - UtAssert_ADDRESS_EQ(context_CF_CFDP_FTBSN.chan, CF_AppData.engine.channels); + UtAssert_ADDRESS_EQ(context_CF_CFDP_FTBSN.chan, engine_ptr->channels); UtAssert_UINT32_EQ(context_CF_CFDP_FTBSN.transaction_sequence_number, arg_ts); UtAssert_UINT32_EQ(context_CF_CFDP_FTBSN.src_eid, arg_eid); UtAssert_ADDRESS_EQ(local_result, expected_result); @@ -1025,17 +924,15 @@ void Test_CF_FindTransactionBySequenceNumberAllChannels_Return_TransactionFound( /* Act */ local_result = CF_FindTransactionBySequenceNumberAllChannels(arg_ts, arg_eid); - UT_GetStubCount(UT_KEY(CF_FindTransactionBySequenceNumber)); - /* Assert */ UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, number_transaction_match + 1); for (i = 0; i < number_transaction_match; ++i) { - UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_AppData.engine.channels + i); + UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_GetChannelPtr(CF_ChannelSelect_FromInt(i))); UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].transaction_sequence_number, arg_ts); UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].src_eid, arg_eid); } - UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_AppData.engine.channels + i); + UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_GetChannelPtr(CF_ChannelSelect_FromInt(i))); UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].transaction_sequence_number, arg_ts); UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].src_eid, arg_eid); UtAssert_ADDRESS_EQ(local_result, expected_result); @@ -1065,7 +962,7 @@ void Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotF AnyRandomStringOfLettersOfLengthCopy(cmdstr, 10); memcpy((char *)arg_cmdstr, &cmdstr, 10); - arg_cmd->chan = CF_COMPOUND_KEY; + arg_cmd->chan_num = CF_COMPOUND_KEY; /* Arrange unstubbable: CF_FindTransactionBySequenceNumberAllChannels */ /* set non-matching transactions */ @@ -1082,8 +979,6 @@ void Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotF /* Act */ UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), -1); - UT_GetStubCount(UT_KEY(Dummy_CF_TsnChanAction_fn_t)); - /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_TRANS_NOT_FOUND_ERR_EID); @@ -1108,7 +1003,7 @@ void Test_CF_TsnChanAction_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionFoundRun_fn_An AnyRandomStringOfLettersOfLengthCopy(cmdstr, 10); memcpy((char *)arg_cmdstr, &cmdstr, 10); - arg_cmd->chan = CF_COMPOUND_KEY; + arg_cmd->chan_num = CF_COMPOUND_KEY; UT_SetDataBuffer(UT_KEY(Dummy_CF_TsnChanAction_fn_t), &context_CF_TsnChanAction_fn_t, @@ -1129,8 +1024,6 @@ void Test_CF_TsnChanAction_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionFoundRun_fn_An /* Act */ UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), 1); - UT_GetStubCount(UT_KEY(Dummy_CF_TsnChanAction_fn_t)); - /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_STUB_COUNT(Dummy_CF_TsnChanAction_fn_t, 1); @@ -1157,7 +1050,7 @@ void Test_CF_TsnChanAction_cmd_chan_Eq_CF_ALL_CHANNELS_Return_CF_TraverseAllTran context_CF_TATAC.forced_return = expected_result; - arg_cmd->chan = CF_ALL_CHANNELS; + arg_cmd->chan_num = CF_ALL_CHANNELS; UT_SetDataBuffer(UT_KEY(CF_TraverseAllTransactions_All_Channels), &context_CF_TATAC, @@ -1200,7 +1093,7 @@ void Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid(void) void *arg_context = &context; memset(&utbuf, 0, sizeof(utbuf)); - arg_cmd->chan = Any_uint8_BetweenExcludeMax(CF_NUM_CHANNELS, CF_COMPOUND_KEY); + arg_cmd->chan_num = CF_NUM_CHANNELS + 1; /* Act */ UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), -1); @@ -1296,7 +1189,7 @@ void Test_CF_DoSuspRes(void) CF_Transaction_Payload_t *cmd = &utbuf; CF_ChanAction_SuspResArg_t utargs; - memset(&CF_AppData.hk.Payload.counters, 0, sizeof(CF_AppData.hk.Payload.counters)); + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); memset(&utargs, 0, sizeof(utargs)); memset(cmd, 0, sizeof(*cmd)); @@ -1304,7 +1197,7 @@ void Test_CF_DoSuspRes(void) /* With no setup, CF_TsnChanAction() invokes CF_TraverseAllTransactions stub, which returns 0 */ /* this should increment the reject counter because it did not match any transactions */ UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 0)); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); /* set up to match 1 transaction, should be accepted, but should not generate an event */ UT_CF_ResetEventCapture(); @@ -1312,7 +1205,7 @@ void Test_CF_DoSuspRes(void) UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 1)); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_SUSPRES_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); /* Output the CF_ChanAction_SuspResArg_t back to the caller, to set the "same" flag to 1 */ /* this gets the case where it attempts to set to the same value, and is rejected due to that */ @@ -1324,7 +1217,7 @@ void Test_CF_DoSuspRes(void) &utargs); UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 0)); UT_CF_AssertEventID(CF_CMD_SUSPRES_SAME_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); /* Output the CF_ChanAction_SuspResArg_t back to the caller, to set the "same" flag to 1 */ /* however this time CF_TraverseAllTransactions reports it matched multiple transactions, so it should NOT reject it @@ -1334,7 +1227,7 @@ void Test_CF_DoSuspRes(void) UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 1)); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_SUSPRES_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 3); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 3); } /******************************************************************************* @@ -1352,7 +1245,7 @@ void Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1(void) memset(&utbuf, 0, sizeof(utbuf)); /* Set to invalid channel */ - utbuf.Payload.chan = CF_NUM_CHANNELS; + utbuf.Payload.chan_num = CF_NUM_CHANNELS; /* Act */ CF_SuspendCmd(&utbuf); @@ -1363,7 +1256,7 @@ void Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1(void) UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[1], CF_CMD_SUSPRES_CHAN_ERR_EID); /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } /******************************************************************************* @@ -1380,7 +1273,7 @@ void Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0(void) memset(&utbuf, 0, sizeof(utbuf)); /* Invalid channel */ - utbuf.Payload.chan = CF_NUM_CHANNELS; + utbuf.Payload.chan_num = CF_NUM_CHANNELS; /* Act */ CF_ResumeCmd(&utbuf); @@ -1391,7 +1284,7 @@ void Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0(void) UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[1], CF_CMD_SUSPRES_CHAN_ERR_EID); /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } /******************************************************************************* @@ -1440,7 +1333,7 @@ void Test_CF_CancelCmd_Success(void) /* Assert */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_CANCEL_INF_EID); } @@ -1459,7 +1352,7 @@ void Test_CF_CancelCmd_Failure(void) /* Assert */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_CANCEL_CHAN_ERR_EID); } @@ -1503,7 +1396,7 @@ void Test_CF_AbandonCmd_Success(void) /* Assert */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ABANDON_INF_EID); } @@ -1522,7 +1415,7 @@ void Test_CF_AbandonCmd_Failure(void) /* Assert */ UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_ABANDON_CHAN_ERR_EID); } @@ -1535,24 +1428,21 @@ void Test_CF_AbandonCmd_Failure(void) void Test_CF_DoEnableDisableDequeue_Set_chan_num_EnabledFlagTo_context_barg(void) { /* Arrange */ - CF_ConfigTable_t config_table; - uint8 arg_chan_num = Any_cf_channel(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); CF_ChanAction_BoolArg_t context; CF_ChanAction_BoolArg_t *arg_context = &context; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_AppData.config_table = &config_table; - context.barg = Any_bool_arg_t_barg(); - - memset(&config_table, 0, sizeof(config_table)); + context.barg = Any_bool_arg_t_barg(); /* Act */ - CF_DoEnableDisableDequeue(arg_chan_num, arg_context); + CF_DoEnableDisableDequeue(chan, arg_context); /* Assert */ - UtAssert_True(CF_AppData.config_table->chan[arg_chan_num].dequeue_enabled == context.barg, + UtAssert_True(chan->config.dequeue_enabled == context.barg, "Channel %u dequeue_enabled is %u and should be %u (context->barg)", - arg_chan_num, - CF_AppData.config_table->chan[arg_chan_num].dequeue_enabled, + CF_ChannelSelect_AsInt(chan_num), + chan->config.dequeue_enabled, context.barg); } @@ -1567,38 +1457,34 @@ void Test_CF_EnableDequeueCmd_Success(void) CF_EnableDequeueCmd_t utbuf; /* Arrange */ - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ - CF_ConfigTable_t config_table; - uint8 chan_num = Any_cf_channel(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = chan_num; + data->ChannelSelect = chan_num; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_EnableDequeueCmd(&utbuf); /* Assert */ /* Assert for CF_DoFreezeThaw */ - UtAssert_True(CF_AppData.config_table->chan[chan_num].dequeue_enabled == 1, + UtAssert_True(chan->config.dequeue_enabled == 1, "CF_EnableDequeueCmd set dequeue_enabled to %d and should be 1 (barg = 1))", - CF_AppData.config_table->chan[chan_num].dequeue_enabled); + chan->config.dequeue_enabled); /* Assert for incremented counter */ - UtAssert_True( - CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d\nACCEPTANCE OF COMMAND (+1) SHOULD BE " - "THE BEHAVIOR BUT IT IS NOT", - CF_AppData.hk.Payload.counters.cmd, - initial_hk_cmd_counter); + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d\nACCEPTANCE OF COMMAND (+1) SHOULD BE " + "THE BEHAVIOR BUT IT IS NOT", + CF_AppData.counters.cmd, + initial_hk_cmd_counter); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ENABLE_DEQUEUE_INF_EID); } @@ -1608,27 +1494,21 @@ void Test_CF_EnableDequeueCmd_Failure(void) /* Arrange */ CF_EnableDequeueCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - - /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ - CF_ConfigTable_t config_table; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = CF_NUM_CHANNELS + 1; + data->ChannelSelect = CF_NUM_CHANNELS + 1; - CF_AppData.hk.Payload.counters.err = 0; + CF_AppData.counters.err = 0; /* Act */ CF_EnableDequeueCmd(&utbuf); /* Assert */ /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_ENABLE_DEQUEUE_ERR_EID); } @@ -1642,35 +1522,31 @@ void Test_CF_DisableDequeueCmd_Success(void) { CF_DisableDequeueCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); - /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ - CF_ConfigTable_t config_table; - uint8 chan_num = Any_cf_channel(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = chan_num; + data->ChannelSelect = chan_num; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_DisableDequeueCmd(&utbuf); /* Assert */ /* Assert for CF_DoFreezeThaw */ - UtAssert_True(CF_AppData.config_table->chan[chan_num].dequeue_enabled == 0, + UtAssert_True(chan->config.dequeue_enabled == 0, "CF_EnableDequeueCmd set dequeue_enabled to %d and should be 0 (barg = 0))", - CF_AppData.config_table->chan[chan_num].dequeue_enabled); + chan->config.dequeue_enabled); /* Assert for incremented counter */ - UtAssert_True(CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.cmd, + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, initial_hk_cmd_counter); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_DISABLE_DEQUEUE_INF_EID); @@ -1681,27 +1557,21 @@ void Test_CF_DisableDequeueCmd_Failure(void) /* Arrange */ CF_DisableDequeueCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - - /* Arrange unstubbable: CF_DoEnableDisableDequeue via CF_DoChanAction */ - CF_ConfigTable_t config_table; + CF_ChannelSelect_Payload_t *data = &utbuf.Payload; memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = CF_NUM_CHANNELS + 1; + data->ChannelSelect = CF_NUM_CHANNELS + 1; - CF_AppData.hk.Payload.counters.err = 0; + CF_AppData.counters.err = 0; /* Act */ CF_DisableDequeueCmd(&utbuf); /* Assert */ /* Assert for CF_DoFreezeThaw */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UT_CF_AssertEventID(CF_CMD_DISABLE_DEQUEUE_ERR_EID); } @@ -1714,38 +1584,35 @@ void Test_CF_DisableDequeueCmd_Failure(void) void Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannelEnabledTo_context_barg(void) { /* Arrange */ - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_PollDirSelect_Payload_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf; CF_ChanAction_BoolMsgArg_t context; CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ConfigTable_t config_table; - uint8 arg_chan_num = Any_cf_channel(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); uint8 expected_enabled; uint8 current_polldir = 0; CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - CF_AppData.config_table = &config_table; + data->PollDirIndx = CF_ALL_POLLDIRS; - data->byte[1] = CF_ALL_CHANNELS; - - context.data = data; - context.barg = Any_bool_arg_t_barg(); - expected_enabled = context.barg; + context.opaque_data = data; + context.barg = Any_bool_arg_t_barg(); + expected_enabled = context.barg; /* Act */ - local_result = CF_DoEnableDisablePolldir(arg_chan_num, arg_context); + local_result = CF_DoEnableDisablePolldir(chan, arg_context); /* Assert */ for (current_polldir = 0; current_polldir < CF_MAX_POLLING_DIR_PER_CHAN; ++current_polldir) { - UtAssert_True(CF_AppData.config_table->chan[arg_chan_num].polldir[current_polldir].enabled == expected_enabled, + UtAssert_True(chan->config.polldir[current_polldir].enabled == expected_enabled, "Channel %u Polldir %u set to %u and should be %u (context->barg)", - arg_chan_num, + CF_ChannelSelect_AsInt(chan_num), current_polldir, - CF_AppData.config_table->chan[arg_chan_num].polldir[current_polldir].enabled, + chan->config.polldir[current_polldir].enabled, expected_enabled); } UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); @@ -1755,36 +1622,33 @@ void Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannel void Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_context_ChannelEnabledTo_context_barg(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - uint8 polldir = Any_cf_polldir(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 polldir = Any_cf_polldir(); + CF_PollDirSelect_Payload_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf; CF_ChanAction_BoolMsgArg_t context; CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ConfigTable_t config_table; uint8 expected_enabled; CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; - data->byte[1] = polldir; + data->PollDirIndx = polldir; - context.data = data; - context.barg = Any_bool_arg_t_barg(); - expected_enabled = context.barg; + context.opaque_data = data; + context.barg = Any_bool_arg_t_barg(); + expected_enabled = context.barg; /* Act */ - local_result = CF_DoEnableDisablePolldir(arg_chan_num, arg_context); + local_result = CF_DoEnableDisablePolldir(chan, arg_context); /* Assert */ - UtAssert_True(CF_AppData.config_table->chan[arg_chan_num].polldir[polldir].enabled == expected_enabled, + UtAssert_True(chan->config.polldir[polldir].enabled == expected_enabled, "Channel %u Polldir %u set to %u and should be %u (context->barg)", - arg_chan_num, + CF_ChannelSelect_AsInt(chan_num), polldir, - CF_AppData.config_table->chan[arg_chan_num].polldir[polldir].enabled, + chan->config.polldir[polldir].enabled, expected_enabled); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); @@ -1793,25 +1657,23 @@ void Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_conte void Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_AndSendEvent(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_PollDirSelect_Payload_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf; CF_ChanAction_BoolMsgArg_t context; CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ConfigTable_t config_table; CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.config_table = &config_table; + data->PollDirIndx = CF_MAX_POLLING_DIR_PER_CHAN; - data->byte[1] = CF_MAX_POLLING_DIR_PER_CHAN; - - context.data = data; - context.barg = Any_bool_arg_t_barg(); + context.opaque_data = data; + context.barg = Any_bool_arg_t_barg(); /* Act */ - local_result = CF_DoEnableDisablePolldir(arg_chan_num, arg_context); + local_result = CF_DoEnableDisablePolldir(chan, arg_context); /* Assert */ UT_CF_AssertEventID(CF_CMD_POLLDIR_INVALID_ERR_EID); @@ -1822,25 +1684,23 @@ void Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_An void Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_PollDirSelect_Payload_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf; CF_ChanAction_BoolMsgArg_t context; CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ConfigTable_t config_table; CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.config_table = &config_table; + data->PollDirIndx = CF_MAX_POLLING_DIR_PER_CHAN; - data->byte[1] = CF_MAX_POLLING_DIR_PER_CHAN; - - context.data = data; - context.barg = Any_bool_arg_t_barg(); + context.opaque_data = data; + context.barg = Any_bool_arg_t_barg(); /* Act */ - local_result = CF_DoEnableDisablePolldir(arg_chan_num, arg_context); + local_result = CF_DoEnableDisablePolldir(chan, arg_context); /* Assert */ UT_CF_AssertEventID(CF_CMD_POLLDIR_INVALID_ERR_EID); @@ -1857,42 +1717,39 @@ void Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent(void) void Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess(void) { /* Arrange */ - CF_ConfigTable_t config_table; - uint8 channel = Any_cf_channel(); - uint8 polldir = Any_cf_polldir(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 polldir = Any_cf_polldir(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); CF_EnableDirPollingCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->byte[1] = polldir; + data->PollDirIndx = polldir; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_EnableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ - UtAssert_True(CF_AppData.config_table->chan[channel].polldir[polldir].enabled == 1, + UtAssert_True(chan->config.polldir[polldir].enabled == 1, "Channel %u Polldir %u set to %u and should be 1 (context->barg)", - channel, + CF_ChannelSelect_AsInt(chan_num), polldir, - CF_AppData.config_table->chan[channel].polldir[polldir].enabled); + chan->config.polldir[polldir].enabled); /* Assert for incremented counter */ - UtAssert_True(CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.cmd, + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, initial_hk_cmd_counter); UT_CF_AssertEventID(CF_CMD_ENABLE_POLLDIR_INF_EID); } @@ -1900,21 +1757,22 @@ void Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess(void) void Test_CF_EnablePolldirCmd_FailWhenActionFail(void) { /* Arrange */ - uint8 channel = Any_cf_channel(); - uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); - CF_EnableDirPollingCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); + CF_EnableDirPollingCmd_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->byte[1] = error_polldir; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + data->PollDirIndx = error_polldir; + + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_EnableDirPollingCmd(&utbuf); @@ -1922,9 +1780,9 @@ void Test_CF_EnablePolldirCmd_FailWhenActionFail(void) /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ /* Assert for incremented counter */ - UtAssert_True(CF_AppData.hk.Payload.counters.err == (uint16)(initial_hk_err_counter + 1), - "CF_AppData.hk.Payload.counters.err is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.err, + UtAssert_True(CF_AppData.counters.err == (uint16)(initial_hk_err_counter + 1), + "CF_AppData.counters.err is %d and should be 1 more than %d", + CF_AppData.counters.err, initial_hk_err_counter); UT_CF_AssertEventID(CF_CMD_ENABLE_POLLDIR_ERR_EID); } @@ -1938,41 +1796,38 @@ void Test_CF_EnablePolldirCmd_FailWhenActionFail(void) void Test_CF_DisablePolldirCmd_SuccessWhenActionSuccess(void) { /* Arrange */ - CF_ConfigTable_t config_table; - uint8 channel = Any_cf_channel(); - uint8 polldir = Any_cf_polldir(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 polldir = Any_cf_polldir(); - CF_DisableDirPollingCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); + CF_DisableDirPollingCmd_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); - - CF_AppData.config_table = &config_table; /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->byte[1] = polldir; + data->PollDirIndx = polldir; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_DisableDirPollingCmd(&utbuf); /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ - UtAssert_True(CF_AppData.config_table->chan[channel].polldir[polldir].enabled == 0, + UtAssert_True(chan->config.polldir[polldir].enabled == 0, "Channel %u Polldir %u set to %u and should be 0 (context->barg)", - channel, + CF_ChannelSelect_AsInt(chan_num), polldir, - CF_AppData.config_table->chan[channel].polldir[polldir].enabled); + chan->config.polldir[polldir].enabled); /* Assert for incremented counter */ - UtAssert_True(CF_AppData.hk.Payload.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.hk.Payload.counters.cmd is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.cmd, + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, initial_hk_cmd_counter); UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_INF_EID); } @@ -1980,22 +1835,22 @@ void Test_CF_DisablePolldirCmd_SuccessWhenActionSuccess(void) void Test_CF_DisablePolldirCmd_FailWhenActionFail(void) { /* Arrange */ - uint8 channel = Any_cf_channel(); - uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); - CF_DisableDirPollingCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); + CF_DisableDirPollingCmd_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->byte[1] = error_polldir; + data->PollDirIndx = error_polldir; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_DisableDirPollingCmd(&utbuf); @@ -2003,9 +1858,9 @@ void Test_CF_DisablePolldirCmd_FailWhenActionFail(void) /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ /* Assert for incremented counter*/ - UtAssert_True(CF_AppData.hk.Payload.counters.err == (uint16)(initial_hk_err_counter + 1), - "CF_AppData.hk.Payload.counters.err is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.err, + UtAssert_True(CF_AppData.counters.err == (uint16)(initial_hk_err_counter + 1), + "CF_AppData.counters.err is %d and should be 1 more than %d", + CF_AppData.counters.err, initial_hk_err_counter); UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_ERR_EID); } @@ -2073,11 +1928,11 @@ void Test_CF_PurgeTransaction_Call_CF_CFDP_ResetTransaction_AndReturn_CLIST_CONT void Test_CF_DoPurgeQueue_PendOnly(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_QueueSelect_Payload_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf; CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); CF_CListNode_t start; CF_CListNode_t *expected_start = &start; CF_ChanAction_Status_t local_result; @@ -2085,18 +1940,16 @@ void Test_CF_DoPurgeQueue_PendOnly(void) memset(&utbuf, 0, sizeof(utbuf)); - data->byte[1] = 0; /* pend */ + data->ChannelSelect = chan_num; + data->QueueSelect = CF_QueueSelect_Pending; /* pend */ UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_POINTER, &context_CF_CList_Traverse); - chan = &CF_AppData.engine.channels[arg_chan_num]; chan->qs[CF_QueueIdx_PEND] = expected_start; /* Act */ - local_result = CF_DoPurgeQueue(arg_chan_num, &msgarg); - - UT_GetStubCount(UT_KEY(CF_CList_Traverse)); + local_result = CF_DoPurgeQueue(chan, &msgarg); /* Assert */ UtAssert_STUB_COUNT(CF_CList_Traverse, 1); @@ -2110,11 +1963,11 @@ void Test_CF_DoPurgeQueue_PendOnly(void) void Test_CF_DoPurgeQueue_HistoryOnly(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_QueueSelect_Payload_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf; CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); CF_CListNode_t start; CF_CListNode_t *expected_start = &start; CF_ChanAction_Status_t local_result; @@ -2122,20 +1975,18 @@ void Test_CF_DoPurgeQueue_HistoryOnly(void) memset(&utbuf, 0, sizeof(utbuf)); - data->byte[1] = 1; /* history */ + data->ChannelSelect = chan_num; + data->QueueSelect = CF_QueueSelect_History; /* history */ /* set correct context type for CF_CList_Traverse stub */ UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_POINTER, &context_CF_CList_Traverse); - chan = &CF_AppData.engine.channels[arg_chan_num]; chan->qs[CF_QueueIdx_HIST] = expected_start; /* Act */ - local_result = CF_DoPurgeQueue(arg_chan_num, &msgarg); - - UT_GetStubCount(UT_KEY(CF_CList_Traverse)); + local_result = CF_DoPurgeQueue(chan, &msgarg); /* Assert */ UtAssert_STUB_COUNT(CF_CList_Traverse, 1); @@ -2149,11 +2000,11 @@ void Test_CF_DoPurgeQueue_HistoryOnly(void) void Test_CF_DoPurgeQueue_Both(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_QueueSelect_Payload_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf; CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); CF_CListNode_t pend_start; CF_CListNode_t *expected_pend_start = &pend_start; CF_CListNode_t history_start; @@ -2163,21 +2014,19 @@ void Test_CF_DoPurgeQueue_Both(void) memset(&utbuf, 0, sizeof(utbuf)); - data->byte[1] = 2; /* both */ + data->ChannelSelect = chan_num; + data->QueueSelect = CF_QueueSelect_All; /* both */ /* set correct context type for CF_CList_Traverse stub */ /* this must use data buffer hack to pass multiple contexts */ UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_POINTER, NULL); UT_SetDataBuffer(UT_KEY(CF_CList_Traverse), context_CF_CList_Traverse, sizeof(context_CF_CList_Traverse), false); - chan = &CF_AppData.engine.channels[arg_chan_num]; chan->qs[CF_QueueIdx_PEND] = expected_pend_start; chan->qs[CF_QueueIdx_HIST] = expected_history_start; /* Act */ - local_result = CF_DoPurgeQueue(arg_chan_num, &msgarg); - - UT_GetStubCount(UT_KEY(CF_CList_Traverse)); + local_result = CF_DoPurgeQueue(chan, &msgarg); /* Assert */ UtAssert_STUB_COUNT(CF_CList_Traverse, 2); @@ -2195,20 +2044,20 @@ void Test_CF_DoPurgeQueue_Both(void) void Test_CF_DoPurgeQueue_GivenBad_data_byte_1_SendEventAndReturn_neg1(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_ChanAction_Status_t local_result; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_QueueSelect_Payload_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf; + CF_ChanAction_MsgArg_t msgarg = { data }; + CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - data->byte[1] = 3; /* 3 is first default value */ + data->ChannelSelect = chan_num; + data->QueueSelect = 10; /* Invalid */ /* Act */ - local_result = CF_DoPurgeQueue(arg_chan_num, &msgarg); - - UT_GetStubCount(UT_KEY(CF_CList_Traverse)); + local_result = CF_DoPurgeQueue(chan, &msgarg); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); @@ -2220,20 +2069,20 @@ void Test_CF_DoPurgeQueue_GivenBad_data_byte_1_SendEventAndReturn_neg1(void) void Test_CF_DoPurgeQueue_AnyGivenBad_data_byte_1_SendEventAndReturn_neg1(void) { /* Arrange */ - uint8 arg_chan_num = Any_cf_channel(); - CF_UnionArgs_Payload_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_ChanAction_Status_t local_result; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_QueueSelect_Payload_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf; + CF_ChanAction_MsgArg_t msgarg = { data }; + CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); - data->byte[1] = Any_uint8_GreaterThan_or_EqualTo(3); + data->ChannelSelect = chan_num; + data->QueueSelect = Any_uint8_GreaterThan(CF_QueueSelect_All); /* Act */ - local_result = CF_DoPurgeQueue(arg_chan_num, &msgarg); - - UT_GetStubCount(UT_KEY(CF_CList_Traverse)); + local_result = CF_DoPurgeQueue(chan, &msgarg); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); @@ -2251,21 +2100,21 @@ void Test_CF_DoPurgeQueue_AnyGivenBad_data_byte_1_SendEventAndReturn_neg1(void) void Test_CF_PurgeQueueCmd_FailWhenActionFail(void) { /* Arrange */ - uint8 channel = Any_cf_channel(); - uint8 error_purge = 3; /* Shortest return from CF_DoPurgeQueue */ - CF_PurgeQueueCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 error_purge = CF_QueueSelect_All + 1; /* Shortest return from CF_DoPurgeQueue */ + CF_PurgeQueueCmd_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; /* Arrange unstubbable: CF_DoPurgeQueue */ - data->byte[1] = error_purge; + data->QueueSelect = error_purge; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_PurgeQueueCmd(&utbuf); @@ -2273,9 +2122,9 @@ void Test_CF_PurgeQueueCmd_FailWhenActionFail(void) /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ /* Assert for incremented counter */ - UtAssert_True(CF_AppData.hk.Payload.counters.err == (uint16)(initial_hk_err_counter + 1), - "CF_AppData.hk.Payload.counters.err is %d and should be 1 more than %d", - CF_AppData.hk.Payload.counters.err, + UtAssert_True(CF_AppData.counters.err == (uint16)(initial_hk_err_counter + 1), + "CF_AppData.counters.err is %d and should be 1 more than %d", + CF_AppData.counters.err, initial_hk_err_counter); UT_CF_AssertEventID(CF_CMD_PURGE_QUEUE_ERR_EID); } @@ -2283,16 +2132,16 @@ void Test_CF_PurgeQueueCmd_FailWhenActionFail(void) void Test_CF_PurgeQueueCmd_SuccessWhenActionSuccess(void) { /* Arrange */ - uint8 channel = Any_cf_channel(); - CF_PurgeQueueCmd_t utbuf; - CF_UnionArgs_Payload_t *data = &utbuf.Payload; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_PurgeQueueCmd_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf.Payload; memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->byte[0] = channel; + data->ChannelSelect = chan_num; - CF_AppData.hk.Payload.counters.cmd = 0; + CF_AppData.counters.cmd = 0; /* Act */ CF_PurgeQueueCmd(&utbuf); @@ -2300,7 +2149,7 @@ void Test_CF_PurgeQueueCmd_SuccessWhenActionSuccess(void) /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_PURGE_QUEUE_INF_EID); } @@ -2323,7 +2172,7 @@ void Test_CF_WriteQueueCmd_When_chan_Eq_CF_NUM_CAHNNELS_SendEventAndRejectComman /* invalid channel */ wq->chan = CF_NUM_CHANNELS; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2332,7 +2181,7 @@ void Test_CF_WriteQueueCmd_When_chan_Eq_CF_NUM_CAHNNELS_SendEventAndRejectComman UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_CHAN_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRejectCommand(void) @@ -2345,9 +2194,9 @@ void Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRej memset(&utbuf, 0, sizeof(utbuf)); /* invalid channel */ - wq->chan = Any_uint8_GreaterThan(CF_NUM_CHANNELS); + wq->chan = CF_NUM_CHANNELS + 1; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2357,7 +2206,7 @@ void Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRej UT_CF_AssertEventID(CF_CMD_WQ_CHAN_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_WhenUpAndPendingQueueSendEventAndRejectCommand(void) @@ -2370,13 +2219,13 @@ void Test_CF_WriteQueueCmd_WhenUpAndPendingQueueSendEventAndRejectCommand(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* invalid combination up direction, pending queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_pend; + wq->queue = CF_QueueSelect_Pending; - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2386,7 +2235,7 @@ void Test_CF_WriteQueueCmd_WhenUpAndPendingQueueSendEventAndRejectCommand(void) UT_CF_AssertEventID(CF_CMD_WQ_ARGS_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_IsNot_q_pend_SendEventAndRejectCommand( @@ -2401,7 +2250,7 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination up direction, NOT pending queue */ wq->type = CF_Type_up; @@ -2417,7 +2266,7 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ sizeof(context_CF_WrappedOpenCreate), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2429,7 +2278,7 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ UT_CF_AssertEventID(CF_CMD_WQ_OPEN_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_queue_Is_q_pend_SendEventAndRejectCommand( @@ -2444,11 +2293,11 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination down direction, pending queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_pend; + wq->queue = CF_QueueSelect_Pending; /* invalid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2460,7 +2309,7 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que sizeof(context_CF_WrappedOpenCreate), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2472,7 +2321,7 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que UT_CF_AssertEventID(CF_CMD_WQ_OPEN_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedClose_SendEventCloseAndRejectCommandWhen_CF_WriteTxnQueueDataToFile_Fails( @@ -2490,11 +2339,11 @@ void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_all; - wq->queue = CF_Queue_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2513,7 +2362,7 @@ void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC false); UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2524,7 +2373,7 @@ void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC UT_CF_AssertEventID(CF_CMD_WQ_WRITEQ_RX_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_queue_IsActive_fd_IsPositive_Call_CF_WrappedClose_SendEventClosesAndRejectCommand( @@ -2543,11 +2392,11 @@ void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_active; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2568,7 +2417,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2579,7 +2428,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q UT_CF_AssertEventID(CF_CMD_WQ_WRITEQ_RX_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpAnd_queue_IsHistory_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( @@ -2598,11 +2447,11 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_history; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2623,7 +2472,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2634,7 +2483,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA UT_CF_AssertEventID(CF_CMD_WQ_WRITEHIST_RX_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq_IsDownAnd_queue_IsActive_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( @@ -2653,11 +2502,11 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_active; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2678,7 +2527,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2689,7 +2538,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq UT_CF_AssertEventID(CF_CMD_WQ_WRITEQ_TX_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDownAnd_queue_IsPend_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( @@ -2708,11 +2557,11 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_pend; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2733,7 +2582,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2744,7 +2593,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow UT_CF_AssertEventID(CF_CMD_WQ_WRITEQ_PEND_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDownAnd_queue_IsHistory_fd_IsPositive_Call_CF_WrappedClose_SendEventCloseAndRejectCommand( @@ -2763,11 +2612,11 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_history; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2788,7 +2637,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow UT_SetDataBuffer(UT_KEY(CF_WrappedClose), &context_CF_WrappedClose_fd, sizeof(context_CF_WrappedClose_fd), false); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2799,7 +2648,7 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow UT_CF_AssertEventID(CF_CMD_WQ_WRITEHIST_TX_ERR_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) @@ -2816,11 +2665,11 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_all; - wq->queue = CF_Queue_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2838,7 +2687,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2850,7 +2699,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) @@ -2866,11 +2715,11 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_all; - wq->queue = CF_Queue_history; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2885,7 +2734,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2897,7 +2746,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) @@ -2913,11 +2762,11 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_all; - wq->queue = CF_Queue_active; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2932,7 +2781,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2944,7 +2793,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) @@ -2960,11 +2809,11 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_all; - wq->queue = CF_Queue_pend; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2979,7 +2828,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -2991,7 +2840,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) @@ -3008,11 +2857,11 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3030,7 +2879,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3042,7 +2891,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) @@ -3058,11 +2907,11 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_history; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3077,7 +2926,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3089,7 +2938,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) @@ -3105,11 +2954,11 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_up; - wq->queue = CF_Queue_active; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3124,7 +2973,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3136,7 +2985,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } /* Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Pend IS an error and is handled by a previous test */ @@ -3154,11 +3003,11 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_All(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3173,7 +3022,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_All(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3185,7 +3034,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_All(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) @@ -3201,11 +3050,11 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_history; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3220,7 +3069,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3232,7 +3081,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) @@ -3248,11 +3097,11 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_active; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3267,7 +3116,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3279,7 +3128,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) @@ -3295,11 +3144,11 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_uint8_LessThan(CF_NUM_CHANNELS); + wq->chan = Any_cf_chan_num(); /* valid combination all direction, all queue */ wq->type = CF_Type_down; - wq->queue = CF_Queue_pend; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -3314,7 +3163,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_WriteQueueCmd(&utbuf); @@ -3326,7 +3175,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); UtAssert_STUB_COUNT(CF_WrappedClose, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } /******************************************************************************* @@ -3338,12 +3187,11 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) void Test_CF_ValidateChunkSizeCmd_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1(void) { /* Arrange */ - uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */ - size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t) + 1; + size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t) + 1; CF_ChanAction_Status_t local_result; /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, arg_chan_num); + local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); @@ -3352,12 +3200,11 @@ void Test_CF_ValidateChunkSizeCmd_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1( void Test_CF_ValidateChunkSizeCmd_Any_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1(void) { /* Arrange */ - uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */ - uint32 arg_val = Any_uint32_GreaterThan(sizeof(CF_CFDP_PduFileDataContent_t)); + uint32 arg_val = Any_uint32_GreaterThan(sizeof(CF_CFDP_PduFileDataContent_t)); CF_ChanAction_Status_t local_result; /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, arg_chan_num); + local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); @@ -3366,12 +3213,11 @@ void Test_CF_ValidateChunkSizeCmd_Any_val_GreaterThan_pdu_fd_data_t_FailAndRetur void Test_CF_ValidateChunkSizeCmd_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0(void) { /* Arrange */ - uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */ - size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t); + size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t); CF_ChanAction_Status_t local_result; /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, arg_chan_num); + local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); @@ -3380,12 +3226,11 @@ void Test_CF_ValidateChunkSizeCmd_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0(vo void Test_CF_ValidateChunkSizeCmd_val_LessThanOrEqSizeOf_pdu_fd_data_t_SuccessAndReturn_0(void) { /* Arrange */ - uint8 arg_chan_num = Any_uint8(); /* value labeled as 'ignored' in func def */ - uint32 arg_val = Any_uint32_LessThan_or_EqualTo(sizeof(CF_CFDP_PduFileDataContent_t)); + uint32 arg_val = Any_uint32_LessThan_or_EqualTo(sizeof(CF_CFDP_PduFileDataContent_t)); CF_ChanAction_Status_t local_result; /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, arg_chan_num); + local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); @@ -3400,12 +3245,11 @@ void Test_CF_ValidateChunkSizeCmd_val_LessThanOrEqSizeOf_pdu_fd_data_t_SuccessAn void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_IsNot_0_Return_0_Success(void) { /* Arrange */ - uint32 arg_val = Any_uint32_Except(0); - uint8 arg_chan_num = Any_uint8(); /* Any_uint8() used here because it shows value does not matter in this test */ + uint32 arg_val = Any_uint32_Except(0); CF_ChanAction_Status_t local_result; /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, arg_chan_num); + local_result = CF_ValidateMaxOutgoingCmd(arg_val, NULL); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); @@ -3414,16 +3258,15 @@ void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_IsNot_0_Return_0_Success(void) void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_But_sem_name_IsNot_NULL_Return_0_Success(void) { /* Arrange */ - uint32 arg_val = 0; - uint8 arg_chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ - CF_ConfigTable_t config_table; + uint32 arg_val = 0; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_AppData.config_table = &config_table; - memset(CF_AppData.config_table->chan[arg_chan_num].sem_name, (char)Any_uint8_Except(0), 1); + memset(chan->config.sem_name, (char)Any_uint8_Except(0), 1); /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, arg_chan_num); + local_result = CF_ValidateMaxOutgoingCmd(arg_val, chan); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); @@ -3432,16 +3275,15 @@ void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_But_sem_name_IsNot_NULL_R void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Return_1_Fail(void) { /* Arrange */ - uint32 arg_val = 0; - uint8 arg_chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ - CF_ConfigTable_t config_table; + uint32 arg_val = 0; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ CF_ChanAction_Status_t local_result; + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_AppData.config_table = &config_table; - memset(CF_AppData.config_table->chan[arg_chan_num].sem_name, (char)0, 1); + memset(chan->config.sem_name, (char)0, 1); /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, arg_chan_num); + local_result = CF_ValidateMaxOutgoingCmd(arg_val, chan); /* Assert */ UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); @@ -3456,18 +3298,17 @@ void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Retu void Test_CF_GetSetParamCmd(void) { /* Test cases for: - * void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num); + * void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_Channel_t *chan_ptr); */ /* Arrange */ - CF_ConfigTable_t ut_config_table; CF_GetSet_ValueID_t param_id; uint16 expected_count; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - memset(&ut_config_table, 0, sizeof(ut_config_table)); - memset(&CF_AppData.hk.Payload.counters, 0, sizeof(CF_AppData.hk.Payload.counters)); - CF_AppData.config_table = &ut_config_table; - expected_count = 0; + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); + expected_count = 0; /* Nominal: "set" for each parameter */ for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id) @@ -3475,20 +3316,20 @@ void Test_CF_GetSetParamCmd(void) UT_CF_ResetEventCapture(); UtAssert_VOIDCALL(CF_GetSetParamCmd(true, param_id, 1 + param_id, UT_CFDP_CHANNEL)); UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, ++expected_count); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, ++expected_count); } /* each of the config parameters should have actually been set to a different value */ - UtAssert_UINT32_EQ(ut_config_table.ticks_per_second, 1); - UtAssert_UINT32_EQ(ut_config_table.rx_crc_calc_bytes_per_wakeup, 2); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].ack_timer_s, 3); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].nak_timer_s, 4); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].inactivity_timer_s, 5); - UtAssert_UINT32_EQ(ut_config_table.outgoing_file_chunk_size, 6); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].ack_limit, 7); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].nak_limit, 8); - UtAssert_UINT32_EQ(ut_config_table.local_eid, 9); - UtAssert_UINT32_EQ(ut_config_table.chan[UT_CFDP_CHANNEL].max_outgoing_messages_per_wakeup, 10); + UtAssert_UINT32_EQ(engine_ptr->config.ticks_per_second, 1); + UtAssert_UINT32_EQ(engine_ptr->config.rx_crc_calc_bytes_per_wakeup, 2); + UtAssert_UINT32_EQ(chan->config.ack_timer_s, 3); + UtAssert_UINT32_EQ(chan->config.nak_timer_s, 4); + UtAssert_UINT32_EQ(chan->config.inactivity_timer_s, 5); + UtAssert_UINT32_EQ(engine_ptr->config.outgoing_file_chunk_size, 6); + UtAssert_UINT32_EQ(chan->config.ack_limit, 7); + UtAssert_UINT32_EQ(chan->config.nak_limit, 8); + UtAssert_UINT32_EQ(engine_ptr->config.local_eid, 9); + UtAssert_UINT32_EQ(chan->config.max_outgoing_messages_per_wakeup, 10); /* Nominal: "get" for each parameter */ for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id) @@ -3496,20 +3337,20 @@ void Test_CF_GetSetParamCmd(void) UT_CF_ResetEventCapture(); UtAssert_VOIDCALL(CF_GetSetParamCmd(false, param_id, 1, UT_CFDP_CHANNEL)); UT_CF_AssertEventID(CF_CMD_GETSET2_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, ++expected_count); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, ++expected_count); } /* Bad param ID */ UT_CF_ResetEventCapture(); UtAssert_VOIDCALL(CF_GetSetParamCmd(false, CF_GetSet_ValueID_MAX, 0, UT_CFDP_CHANNEL)); UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); /* Bad channel ID */ UT_CF_ResetEventCapture(); UtAssert_VOIDCALL(CF_GetSetParamCmd(false, 0, 0, CF_NUM_CHANNELS + 1)); UT_CF_AssertEventID(CF_CMD_GETSET_CHAN_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); /* Validation fail */ UT_CF_ResetEventCapture(); @@ -3518,7 +3359,7 @@ void Test_CF_GetSetParamCmd(void) 100 + sizeof(CF_CFDP_PduFileDataContent_t), UT_CFDP_CHANNEL)); UT_CF_AssertEventID(CF_CMD_GETSET_VALIDATE_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 3); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); } /******************************************************************************* @@ -3531,26 +3372,23 @@ void Test_CF_SetParamCmd_Call_CF_GetSetParamCmd_With_cmd_key_And_cmd_value(void) { /* Arrange */ CF_SetParamCmd_t utbuf; - CF_ConfigTable_t config_table; + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); utbuf.Payload.key = CF_GetSet_ValueID_ticks_per_second; utbuf.Payload.value = 1; - utbuf.Payload.chan_num = 0; - - CF_AppData.config_table = &config_table; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; /* Act */ CF_SetParamCmd(&utbuf); /* Assert */ - UtAssert_UINT32_EQ(CF_AppData.config_table->ticks_per_second, utbuf.Payload.value); + UtAssert_UINT32_EQ(engine_ptr->config.ticks_per_second, utbuf.Payload.value); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_GETSET1_INF_EID); /* Assert for incremented counter() */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); } /******************************************************************************* @@ -3563,15 +3401,11 @@ void Test_CF_GetParamCmd_Call_CF_GetSetParamCmd_With_cmd_data_byte_0_AndConstant { /* Arrange */ CF_GetParamCmd_t utbuf; - CF_ConfigTable_t config_table; memset(&utbuf, 0, sizeof(utbuf)); - memset(&config_table, 0, sizeof(config_table)); utbuf.Payload.key = CF_GetSet_ValueID_ticks_per_second; - utbuf.Payload.chan_num = 0; - - CF_AppData.config_table = &config_table; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; /* Act */ CF_GetParamCmd(&utbuf); @@ -3581,7 +3415,7 @@ void Test_CF_GetParamCmd_Call_CF_GetSetParamCmd_With_cmd_data_byte_0_AndConstant UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_GETSET2_INF_EID); /* Assert for incremented counter() */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); } /******************************************************************************* @@ -3596,26 +3430,25 @@ void Test_CF_EnableEngineCmd_WithEngineNotEnableInitSuccessAndIncrementCmdCounte CF_EnableEngineCmd_t utbuf; uint32 forced_return_CF_CFDP_InitEngine = CFE_SUCCESS; uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.engine.enabled = false; + engine_ptr->enabled = false; UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), forced_return_CF_CFDP_InitEngine); - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_EnableEngineCmd(&utbuf); - UT_GetStubCount(UT_KEY(CF_CFDP_InitEngine)); - /* Assert */ UtAssert_STUB_COUNT(CF_CFDP_InitEngine, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ENABLE_ENGINE_INF_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_EnableEngineCmd_WithEngineNotEnableFailsInitSendEventAndIncrementErrCounter(void) @@ -3624,26 +3457,25 @@ void Test_CF_EnableEngineCmd_WithEngineNotEnableFailsInitSendEventAndIncrementEr CF_EnableEngineCmd_t utbuf; uint32 forced_return_CF_CFDP_InitEngine = Any_uint32_Except(CF_ChanAction_Status_SUCCESS); uint16 initial_hk_err_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.engine.enabled = false; + engine_ptr->enabled = false; UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), forced_return_CF_CFDP_InitEngine); - CF_AppData.hk.Payload.counters.err = initial_hk_err_counter; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ CF_EnableEngineCmd(&utbuf); - UT_GetStubCount(UT_KEY(CF_CFDP_InitEngine)); - /* Assert */ UtAssert_STUB_COUNT(CF_CFDP_InitEngine, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ENABLE_ENGINE_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } void Test_CF_EnableEngineCmd_WithEngineEnableFailsSendEventAndIncrementCmdCounter(void) @@ -3651,24 +3483,23 @@ void Test_CF_EnableEngineCmd_WithEngineEnableFailsSendEventAndIncrementCmdCounte /* Arrange */ CF_EnableEngineCmd_t utbuf; uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_EnableEngineCmd(&utbuf); - UT_GetStubCount(UT_KEY(CF_CFDP_InitEngine)); - /* Assert */ UtAssert_STUB_COUNT(CF_CFDP_InitEngine, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ENG_ALREADY_ENA_INF_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } /******************************************************************************* @@ -3682,12 +3513,13 @@ void Test_CF_DisableEngineCmd_SuccessWhenEngineEnabledAndIncrementCmdCounter(voi /* Arrange */ CF_DisableEngineCmd_t utbuf; uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.engine.enabled = true; + engine_ptr->enabled = true; - CF_AppData.hk.Payload.counters.cmd = initial_hk_cmd_counter; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ CF_DisableEngineCmd(&utbuf); @@ -3698,7 +3530,7 @@ void Test_CF_DisableEngineCmd_SuccessWhenEngineEnabledAndIncrementCmdCounter(voi UT_CF_AssertEventID(CF_CMD_DISABLE_ENGINE_INF_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } void Test_CF_DisableEngineCmd_WhenEngineDisabledAndIncrementCmdCounter(void) @@ -3706,12 +3538,13 @@ void Test_CF_DisableEngineCmd_WhenEngineDisabledAndIncrementCmdCounter(void) /* Arrange */ CF_DisableEngineCmd_t utbuf; uint16 initial_hk_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); - CF_AppData.engine.enabled = false; + engine_ptr->enabled = false; - CF_AppData.hk.Payload.counters.cmd = initial_hk_counter; + CF_AppData.counters.cmd = initial_hk_counter; /* Act */ CF_DisableEngineCmd(&utbuf); @@ -3721,7 +3554,7 @@ void Test_CF_DisableEngineCmd_WhenEngineDisabledAndIncrementCmdCounter(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_ENG_ALREADY_DIS_INF_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, (initial_hk_counter + 1) & 0xFFFF); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_counter + 1) & 0xFFFF); } /******************************************************************************* @@ -3730,14 +3563,40 @@ void Test_CF_DisableEngineCmd_WhenEngineDisabledAndIncrementCmdCounter(void) ** *******************************************************************************/ -void Test_CF_SendHkCmd(void) +void Test_CF_SendHkCmd_Nominal(void) { + union + { + CFE_SB_Buffer_t sb; + CF_HkPacket_t hk; + } buf; + CFE_SB_Buffer_t *sb_buf = &buf.sb; + + memset(&buf, 0xFF, sizeof(buf)); + CF_AppData.counters.cmd = 10; + CF_AppData.counters.err = 20; + UT_SetDataBuffer(UT_KEY(CFE_SB_AllocateMessageBuffer), &sb_buf, sizeof(sb_buf), false); + + /* Act */ + CF_SendHkCmd(NULL); + + /* Assert */ + UtAssert_STUB_COUNT(CFE_MSG_Init, 1); + UtAssert_STUB_COUNT(CFE_SB_TransmitBuffer, 1); + UtAssert_UINT8_EQ(buf.hk.Payload.counters.cmd, CF_AppData.counters.cmd); + UtAssert_UINT8_EQ(buf.hk.Payload.counters.err, CF_AppData.counters.err); +} + +void Test_CF_SendHkCmd_NoBuffers(void) +{ + UT_SetDefaultReturnValue(UT_KEY(CFE_SB_AllocateMessageBuffer), -1); + /* Act */ CF_SendHkCmd(NULL); /* Assert */ - UtAssert_STUB_COUNT(CFE_SB_TimeStampMsg, 1); - UtAssert_STUB_COUNT(CFE_SB_TransmitMsg, 1); + UtAssert_STUB_COUNT(CFE_MSG_Init, 0); + UtAssert_STUB_COUNT(CFE_SB_TransmitBuffer, 0); } /******************************************************************************* @@ -4298,7 +4157,8 @@ void add_CF_DisableEngineCmd_tests(void) void add_CF_SendHkCmd_tests(void) { - UtTest_Add(Test_CF_SendHkCmd, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SendHkCmd"); + UtTest_Add(Test_CF_SendHkCmd_Nominal, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SendHkCmd_Nominal"); + UtTest_Add(Test_CF_SendHkCmd_NoBuffers, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SendHkCmd_NoBuffers"); } void add_CF_WakeupCmd_tests(void) diff --git a/unit-test/cf_dispatch_tests.c b/unit-test/cf_dispatch_tests.c index 97d9fc7c..0c3c8e26 100644 --- a/unit-test/cf_dispatch_tests.c +++ b/unit-test/cf_dispatch_tests.c @@ -74,7 +74,7 @@ void Test_CF_ProcessGroundCommand_When_cmd_EqTo_CF_NUM_COMMANDS_FailAndSendEvent UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CC_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } void Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSendEvent(void) @@ -100,7 +100,7 @@ void Test_CF_ProcessGroundCommand_When_cmd_GreaterThan_CF_NUM_COMMANDS_FailAndSe UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CC_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } void Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForThatCommandSendEventAndFailure(void) @@ -130,7 +130,7 @@ void Test_CF_ProcessGroundCommand_Receives_cmd_AndLengthDoesNotMatchExpectedForT UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_LEN_ERR_EID); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x00_AndCall_CF_NoopCmd_With_msg(void) @@ -186,8 +186,8 @@ void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_1 UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 0); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 0); } /******************************************************************************* @@ -227,8 +227,8 @@ void Test_CF_AppPipe_ProcessGroundCommand(void) UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.cmd, 0); - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } void Test_CF_AppPipe_WakeUp(void) @@ -280,7 +280,7 @@ void Test_CF_AppPipe_UnrecognizedCommandEnterDefaultPath(void) CF_AppPipe(arg_msg); /* Assert */ - UtAssert_UINT32_EQ(CF_AppData.hk.Payload.counters.err, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_MID_ERR_EID); } diff --git a/unit-test/cf_timer_tests.c b/unit-test/cf_timer_tests.c index 1d31148f..3a414cec 100644 --- a/unit-test/cf_timer_tests.c +++ b/unit-test/cf_timer_tests.c @@ -48,10 +48,9 @@ void Test_CF_Timer_Sec2Ticks_ReturnExpectedValue(void) /* Arrange */ CF_Timer_Seconds_t arg_sec = Any_uint32(); uint32 ticks_per_second = Any_uint32(); - CF_ConfigTable_t config_table; + CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_AppData.config_table = &config_table; - CF_AppData.config_table->ticks_per_second = ticks_per_second; + engine_ptr->config.ticks_per_second = ticks_per_second; /* Act */ UtAssert_UINT32_EQ(CF_Timer_Sec2Ticks(arg_sec), arg_sec * ticks_per_second); @@ -66,16 +65,15 @@ void Test_CF_Timer_Sec2Ticks_ReturnExpectedValue(void) void Test_CF_Timer_InitRelSec_ReceiveExpectedValue(void) { /* Arrange */ - uint32 arg_rel_sec = Any_uint32(); - CF_Timer_t timer; - CF_Timer_t *arg_t = &timer; + uint32 arg_rel_sec = Any_uint32(); + CF_Timer_t timer; + CF_Timer_t *arg_t = &timer; + CF_Engine_t *engine_ptr = CF_GetEngine(); /* Arrange unstubbalbe: CF_Timer_Sec2Ticks in same file */ - uint32 ticks_per_second = Any_uint32(); - CF_ConfigTable_t config_table; + uint32 ticks_per_second = Any_uint32(); - CF_AppData.config_table = &config_table; - CF_AppData.config_table->ticks_per_second = ticks_per_second; + engine_ptr->config.ticks_per_second = ticks_per_second; arg_t->tick = ticks_per_second; diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index 97efd604..4f37ba4e 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -113,14 +113,15 @@ void Test_CF_ResetHistory(void) /* Test case for: * void CF_ResetHistory(CF_Channel_t *chan, CF_History_t *history) */ - CF_History_t history; + CF_History_t history; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; memset(&history, 0, sizeof(history)); - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_HIST] = 4; + chan->stat.q_size[CF_QueueIdx_HIST] = 4; /* nominal call */ - UtAssert_VOIDCALL(CF_ResetHistory(&CF_AppData.engine.channels[UT_CFDP_CHANNEL], &history)); + UtAssert_VOIDCALL(CF_ResetHistory(chan, &history)); } void Test_CF_FindUnusedTransaction(void) @@ -135,10 +136,10 @@ void Test_CF_FindUnusedTransaction(void) memset(&hist, 0, sizeof(hist)); memset(&txn, 0, sizeof(txn)); memset(&CF_AppData, 0, sizeof(CF_AppData)); - chan = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_FREE] = 2; - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_HIST_FREE] = 1; - CF_AppData.hk.Payload.channel_hk[UT_CFDP_CHANNEL].q_size[CF_QueueIdx_HIST] = 1; + chan = UT_CFDP_CHANNEL_PTR; + chan->stat.q_size[CF_QueueIdx_FREE] = 2; + chan->stat.q_size[CF_QueueIdx_HIST_FREE] = 1; + chan->stat.q_size[CF_QueueIdx_HIST] = 1; UtAssert_NULL(CF_FindUnusedTransaction(chan, 0)); @@ -161,15 +162,17 @@ void Test_CF_FreeTransaction(void) * void CF_FreeTransaction(CF_Transaction_t *txn, uint8 chan) */ CF_Transaction_t *txn; + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&CF_AppData, 0, sizeof(CF_AppData)); - txn = &CF_AppData.engine.transactions[UT_CFDP_CHANNEL]; + txn = &engine_ptr->transactions[0]; txn->flags.com.q_index = CF_QueueIdx_RX; + txn->chan_ptr = UT_CFDP_CHANNEL_PTR; - UtAssert_VOIDCALL(CF_FreeTransaction(txn, UT_CFDP_CHANNEL)); + UtAssert_VOIDCALL(CF_FreeTransaction(txn)); UtAssert_UINT32_EQ(txn->state, CF_TxnState_UNDEF); - UtAssert_UINT8_EQ(txn->chan_num, UT_CFDP_CHANNEL); + UtAssert_ADDRESS_EQ(CF_GetChannelFromTxn(txn), UT_CFDP_CHANNEL_PTR); UtAssert_STUB_COUNT(CF_CList_InsertBack, 1); } @@ -186,7 +189,8 @@ void Test_CF_FindTransactionBySequenceNumber_Impl(void) memset(&hist, 0, sizeof(hist)); memset(&ctxt, 0, sizeof(ctxt)); - txn.history = &hist; + txn.history = &hist; + txn.chan_ptr = UT_CFDP_CHANNEL_PTR; /* non-matching eid and non-matching sequence */ hist.src_eid = 12; @@ -230,14 +234,15 @@ void Test_CF_FindTransactionBySequenceNumber(void) CF_Transaction_t *txn; CF_Channel_t *chan; + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&CF_AppData, 0, sizeof(CF_AppData)); - chan = &CF_AppData.engine.channels[UT_CFDP_CHANNEL]; + chan = UT_CFDP_CHANNEL_PTR; UtAssert_NULL(CF_FindTransactionBySequenceNumber(chan, 12, 34)); UtAssert_STUB_COUNT(CF_CList_Traverse, 3); /* this checks 3 different queues: RX, TX, PEND */ - txn = &CF_AppData.engine.transactions[UT_CFDP_CHANNEL]; + txn = &engine_ptr->transactions[0]; UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_SeqArg_SetTxn, txn); UtAssert_ADDRESS_EQ(CF_FindTransactionBySequenceNumber(chan, 12, 34), txn); } @@ -251,9 +256,10 @@ void Test_CF_GetChannelFromTxn(void) memset(&txn, 0, sizeof(txn)); + txn.chan_ptr = UT_CFDP_CHANNEL_PTR; UtAssert_NOT_NULL(CF_GetChannelFromTxn(&txn)); - txn.chan_num = CF_NUM_CHANNELS + 1; + txn.chan_ptr = NULL; UtAssert_NULL(CF_GetChannelFromTxn(&txn)); } @@ -262,7 +268,7 @@ void Test_CF_GetChunkListHead(void) /* Test case for: * CF_CListNode_t **CF_GetChunkListHead(CF_Channel_t *chan, uint8 direction) */ - CF_Channel_t *chan = CF_AppData.engine.channels; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; UtAssert_NULL(CF_GetChunkListHead(NULL, CF_Direction_RX)); UtAssert_NULL(CF_GetChunkListHead(chan, CF_Direction_NUM)); @@ -304,12 +310,13 @@ void Test_CF_CFDP_GetTxnStatus(void) void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) { /* Arrange */ - CF_Transaction_t arg_t; - uint8 chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); - CF_CListNode_t **expected_head; - CF_CListNode_t *expected_cl_node; - uint16 initial_q_size = Any_uint16_Except(0); /* 0 will CF_Assert */ - uint16 updated_q_size; + CF_Transaction_t arg_t; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_CListNode_t **expected_head; + CF_CListNode_t *expected_cl_node; + uint16 initial_q_size = Any_uint16_Except(0); /* 0 will CF_Assert */ + uint16 updated_q_size; CF_CList_Remove_context_t context_clist_remove; @@ -317,16 +324,16 @@ void Test_cf_dequeue_transaction_Call_CF_CList_Remove_AndDecrement_q_size(void) UT_SetDataBuffer(UT_KEY(CF_CList_Remove), &context_clist_remove, sizeof(context_clist_remove), false); - arg_t.chan_num = chan_num; - expected_head = &CF_AppData.engine.channels[arg_t.chan_num].qs[arg_t.flags.com.q_index]; + arg_t.chan_ptr = chan; + expected_head = &chan->qs[arg_t.flags.com.q_index]; expected_cl_node = &arg_t.cl_node; - CF_AppData.hk.Payload.channel_hk[arg_t.chan_num].q_size[arg_t.flags.com.q_index] = initial_q_size; + chan->stat.q_size[arg_t.flags.com.q_index] = initial_q_size; /* Act */ CF_DequeueTransaction(&arg_t); - updated_q_size = CF_AppData.hk.Payload.channel_hk[arg_t.chan_num].q_size[arg_t.flags.com.q_index]; + updated_q_size = chan->stat.q_size[arg_t.flags.com.q_index]; /* Assert */ UtAssert_ADDRESS_EQ(context_clist_remove.head, expected_head); @@ -344,7 +351,8 @@ void Test_cf_move_transaction_Call_CF_CList_InsertBack_AndSet_q_index_ToGiven_q( /* Arrange */ CF_Transaction_t txn; CF_Transaction_t *arg_t = &txn; - uint8 chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); CF_CListNode_t **expected_remove_head; CF_CListNode_t *expected_remove_node; CF_CListNode_t **expected_insert_back_head; @@ -355,20 +363,20 @@ void Test_cf_move_transaction_Call_CF_CList_InsertBack_AndSet_q_index_ToGiven_q( memset(&txn, 0, sizeof(txn)); - arg_t->chan_num = chan_num; + arg_t->chan_ptr = chan; UT_SetDataBuffer(UT_KEY(CF_CList_Remove), &context_clist_remove, sizeof(context_clist_remove), false); - expected_remove_head = &CF_AppData.engine.channels[arg_t->chan_num].qs[arg_t->flags.com.q_index]; + expected_remove_head = &chan->qs[arg_t->flags.com.q_index]; expected_remove_node = &arg_t->cl_node; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); - expected_insert_back_head = &CF_AppData.engine.channels[arg_t->chan_num].qs[arg_q]; + expected_insert_back_head = &chan->qs[arg_q]; expected_insert_back_node = &arg_t->cl_node; /* Queue size needs to be >= 1 */ - CF_AppData.hk.Payload.channel_hk[arg_t->chan_num].q_size[arg_t->flags.com.q_index] = 1; + chan->stat.q_size[arg_t->flags.com.q_index] = 1; /* Act */ CF_MoveTransaction(arg_t, arg_q); @@ -391,14 +399,15 @@ void Test_cf_move_transaction_Call_CF_CList_InsertBack_AndSet_q_index_ToGiven_q( void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) { /* Arrange */ - CF_Channel_t *arg_c = &CF_AppData.engine.channels[Any_uint32_LessThan(CF_NUM_CHANNELS)]; - CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); - CF_CListNode_t node; - CF_CListNode_t *arg_node = &node; - CF_CListNode_t **expected_remove_head; - CF_CListNode_t *expected_remove_node; - uint16 initial_q_size = Any_uint16_Except(0); - uint16 updated_q_size; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *arg_c = CF_GetChannelPtr(chan_num); + CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); + CF_CListNode_t node; + CF_CListNode_t *arg_node = &node; + CF_CListNode_t **expected_remove_head; + CF_CListNode_t *expected_remove_node; + uint16 initial_q_size = Any_uint16_Except(0); + uint16 updated_q_size; CF_CList_Remove_context_t context_clist_remove; @@ -407,12 +416,12 @@ void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) expected_remove_head = &arg_c->qs[arg_index]; expected_remove_node = arg_node; - CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index] = initial_q_size; + arg_c->stat.q_size[arg_index] = initial_q_size; /* Act */ CF_CList_Remove_Ex(arg_c, arg_index, arg_node); - updated_q_size = CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = arg_c->stat.q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_Remove, 1); @@ -429,15 +438,16 @@ void Test_CF_CList_Remove_Ex_Call_CF_CList_Remove_AndDecrement_q_size(void) void Test_CF_CList_InsertAfter_Ex_Call_CF_CList_InsertAfter_AndIncrement_q_size(void) { /* Arrange */ - CF_Channel_t *arg_c = &CF_AppData.engine.channels[Any_uint32_LessThan(CF_NUM_CHANNELS)]; - CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); - CF_CListNode_t start; - CF_CListNode_t *arg_start = &start; - CF_CListNode_t after; - CF_CListNode_t *arg_after = &after; - CF_CListNode_t **expected_insert_after_head = &arg_c->qs[arg_index]; - uint16 initial_q_size = Any_uint16(); - uint16 updated_q_size; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *arg_c = CF_GetChannelPtr(chan_num); + CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); + CF_CListNode_t start; + CF_CListNode_t *arg_start = &start; + CF_CListNode_t after; + CF_CListNode_t *arg_after = &after; + CF_CListNode_t **expected_insert_after_head = &arg_c->qs[arg_index]; + uint16 initial_q_size = Any_uint16(); + uint16 updated_q_size; CF_CList_InsertAfter_context_t context_CF_CList_InsertAfter; @@ -446,12 +456,12 @@ void Test_CF_CList_InsertAfter_Ex_Call_CF_CList_InsertAfter_AndIncrement_q_size( sizeof(context_CF_CList_InsertAfter), false); - CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index] = initial_q_size; + arg_c->stat.q_size[arg_index] = initial_q_size; /* Act */ CF_CList_InsertAfter_Ex(arg_c, arg_index, arg_start, arg_after); - updated_q_size = CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = arg_c->stat.q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_InsertAfter, 1); @@ -469,14 +479,15 @@ void Test_CF_CList_InsertAfter_Ex_Call_CF_CList_InsertAfter_AndIncrement_q_size( void Test_CF_CList_InsertBack_Ex_Call_CF_CList_InsertBack_AndIncrement_q_size(void) { /* Arrange */ - CF_Channel_t *arg_c = &CF_AppData.engine.channels[Any_uint32_LessThan(CF_NUM_CHANNELS)]; - CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); - CF_CListNode_t node; - CF_CListNode_t *arg_node = &node; - uint16 initial_q_size = Any_uint16(); - CF_CListNode_t **expected_insert_back_head; - CF_CListNode_t *expected_insert_back_node; - uint16 updated_q_size; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *arg_c = CF_GetChannelPtr(chan_num); + CF_QueueIdx_t arg_index = Any_cf_queue_index_t(); + CF_CListNode_t node; + CF_CListNode_t *arg_node = &node; + uint16 initial_q_size = Any_uint16(); + CF_CListNode_t **expected_insert_back_head; + CF_CListNode_t *expected_insert_back_node; + uint16 updated_q_size; CF_CList_InsertBack_context_t context_clist_insert_back; UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); @@ -484,12 +495,12 @@ void Test_CF_CList_InsertBack_Ex_Call_CF_CList_InsertBack_AndIncrement_q_size(vo expected_insert_back_head = &arg_c->qs[arg_index]; expected_insert_back_node = arg_node; - CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index] = initial_q_size; + arg_c->stat.q_size[arg_index] = initial_q_size; /* Act */ CF_CList_InsertBack_Ex(arg_c, arg_index, arg_node); - updated_q_size = CF_AppData.hk.Payload.channel_hk[arg_c - CF_AppData.engine.channels].q_size[arg_index]; + updated_q_size = arg_c->stat.q_size[arg_index]; /* Assert */ UtAssert_STUB_COUNT(CF_CList_InsertBack, 1); @@ -710,24 +721,24 @@ void Test_CF_PrioSearch_When_t_PrioIsLessThanContextPrio_Set_context_t_To_t_AndR void Test_CF_InsertSortPrio_Call_CF_CList_InsertBack_Ex_ListIsEmpty_AndSet_q_index_To_q(void) { /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); - CF_Channel_t *chan; - CF_CListNode_t **expected_insert_back_head; - CF_CListNode_t *expected_insert_back_node; + CF_Transaction_t txn; + CF_Transaction_t *arg_t = &txn; + CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_CListNode_t **expected_insert_back_head; + CF_CListNode_t *expected_insert_back_node; CF_CList_InsertBack_context_t context_clist_insert_back; /* txn settings to bypass CF_Assert */ - txn.chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); + txn.chan_ptr = chan; txn.state = Any_uint8_Except(CF_TxnState_INIT); UT_SetDataBuffer(UT_KEY(CF_CList_InsertBack), &context_clist_insert_back, sizeof(context_clist_insert_back), false); - /* setting (&CF_AppData.engine.channels[arg_t->chan_num])->qs[arg_q] to NULL + /* setting (&engine_ptr->channels[arg_t->chan_num])->qs[arg_q] to NULL * makes the list empty */ - chan = &CF_AppData.engine.channels[arg_t->chan_num]; chan->qs[arg_q] = NULL; expected_insert_back_head = &chan->qs[arg_q]; @@ -749,17 +760,18 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertBack_Ex_ListIsEmpty_AndSet_q_ind void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(void) { /* Arrange */ - CF_Transaction_t p_t; - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); - CF_CListNode_t *qs; - CF_Channel_t *chan; - CF_CListNode_t *expected_end; - CF_CListFn_t expected_fn; - CF_CListNode_t **expected_insert_after_head; - CF_CListNode_t **expected_insert_after_start; - CF_CListNode_t **expected_insert_after_after; + CF_Transaction_t p_t; + CF_Transaction_t txn; + CF_Transaction_t *arg_t = &txn; + CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); + CF_CListNode_t *qs; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_CListNode_t *expected_end; + CF_CListFn_t expected_fn; + CF_CListNode_t **expected_insert_after_head; + CF_CListNode_t **expected_insert_after_start; + CF_CListNode_t **expected_insert_after_after; CF_CList_Traverse_R_context_t context_cf_clist_traverse_r; CF_CList_InsertAfter_context_t context_CF_CList_InsertAfter; @@ -769,12 +781,11 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(voi &context_cf_clist_traverse_r); /* txn settings to bypass CF_Assert */ - txn.chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); + txn.chan_ptr = chan; txn.state = Any_uint8_Except(CF_TxnState_INIT); - /* setting (&CF_AppData.engine.channels[arg_t->chan_num])->qs[arg_q] to + /* setting (&engine_ptr->channels[arg_t->chan_num])->qs[arg_q] to * &qs makes the list NOT empty */ - chan = &CF_AppData.engine.channels[arg_t->chan_num]; chan->qs[arg_q] = (CF_CListNode_t *)&qs; /* setup CF_Traverse_PriorityArg_t altered value */ @@ -813,15 +824,16 @@ void Test_CF_InsertSortPrio_Call_CF_CList_InsertAfter_Ex_AndSet_q_index_To_q(voi void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) { /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); - CF_CListNode_t *qs; - CF_Channel_t *chan; - CF_CListNode_t *expected_end; - CF_CListFn_t expected_fn; - CF_CListNode_t **expected_insert_back_head; - CF_CListNode_t *expected_insert_back_node; + CF_Transaction_t txn; + CF_Transaction_t *arg_t = &txn; + CF_QueueIdx_t arg_q = Any_cf_queue_index_t(); + CF_CListNode_t *qs; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_CListNode_t *expected_end; + CF_CListFn_t expected_fn; + CF_CListNode_t **expected_insert_back_head; + CF_CListNode_t *expected_insert_back_node; CF_CList_Traverse_R_context_t context_cf_clist_traverse_r; CF_CList_InsertBack_context_t context_clist_insert_back; @@ -832,12 +844,11 @@ void Test_CF_InsertSortPrio_When_p_t_Is_NULL_Call_CF_CList_InsertBack_Ex(void) false); /* txn settings to bypass CF_Assert */ - txn.chan_num = Any_uint8_LessThan(CF_NUM_CHANNELS); + txn.chan_ptr = chan; txn.state = Any_uint8_Except(CF_TxnState_INIT); - /* setting (&CF_AppData.engine.channels[arg_t->chan_num])->qs[arg_q] to + /* setting (&engine_ptr->channels[arg_t->chan_num])->qs[arg_q] to * &qs makes the list NOT empty */ - chan = &CF_AppData.engine.channels[arg_t->chan_num]; chan->qs[arg_q] = (CF_CListNode_t *)&qs; /* setup CF_Traverse_PriorityArg_t altered value */ @@ -1184,6 +1195,33 @@ void Test_CF_TxnStatus_From_ConditionCode(void) } } +static int32 CF_UT_ChannelFunc(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +{ + return UT_DEFAULT_IMPL(CF_UT_ChannelFunc); +} + +void Test_CF_ForEachChannel(void) +{ + /* Test function for: + * int32 CF_ForEachChannel(CF_Engine_t *engine_ptr, CF_ChannelFunc_t fn, void *arg) + */ + CF_Engine_t *engine_ptr = CF_GetEngine(); + + UT_ResetState(UT_KEY(CF_UT_ChannelFunc)); + UtAssert_INT32_EQ(CF_ForEachChannel(engine_ptr, CF_UT_ChannelFunc, NULL), CFE_SUCCESS); + UtAssert_STUB_COUNT(CF_UT_ChannelFunc, CF_NUM_CHANNELS); + + UT_ResetState(UT_KEY(CF_UT_ChannelFunc)); + UT_SetDeferredRetcode(UT_KEY(CF_UT_ChannelFunc), 1, -1); + UtAssert_INT32_EQ(CF_ForEachChannel(engine_ptr, CF_UT_ChannelFunc, NULL), -1); + UtAssert_STUB_COUNT(CF_UT_ChannelFunc, 1); + + UT_ResetState(UT_KEY(CF_UT_ChannelFunc)); + UT_SetDeferredRetcode(UT_KEY(CF_UT_ChannelFunc), CF_NUM_CHANNELS, -1); + UtAssert_INT32_EQ(CF_ForEachChannel(engine_ptr, CF_UT_ChannelFunc, NULL), -1); + UtAssert_STUB_COUNT(CF_UT_ChannelFunc, CF_NUM_CHANNELS); +} + /******************************************************************************* ** ** cf_utils_tests UtTest_Add groups @@ -1427,4 +1465,6 @@ void UtTest_Setup(void) add_CF_WrappedWrite_tests(); add_CF_WrappedLseek_tests(); + + UtTest_Add(Test_CF_ForEachChannel, cf_utils_tests_Setup, cf_utils_tests_Teardown, "Test_CF_ForEachChannel"); } diff --git a/unit-test/stubs/cf_cfdp_handlers.c b/unit-test/stubs/cf_cfdp_handlers.c index f41613a0..483ecf31 100644 --- a/unit-test/stubs/cf_cfdp_handlers.c +++ b/unit-test/stubs/cf_cfdp_handlers.c @@ -80,7 +80,7 @@ void UT_DefaultHandler_CF_CFDP_TxFile(void *UserObj, UT_EntryKey_t FuncKey, cons strncpy(ctxt->dst_filename, ptr, sizeof(ctxt->dst_filename)); ctxt->cfdp_class = UT_Hook_GetArgValueByName(Context, "cfdp_class", CF_CFDP_Class_t); ctxt->keep = UT_Hook_GetArgValueByName(Context, "keep", uint8); - ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", uint8); + ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); ctxt->priority = UT_Hook_GetArgValueByName(Context, "priority", uint8); ctxt->dest_id = UT_Hook_GetArgValueByName(Context, "dest_id", CF_EntityId_t); } @@ -105,7 +105,7 @@ void UT_DefaultHandler_CF_CFDP_PlaybackDir(void *UserObj, UT_EntryKey_t FuncKey, strncpy(ctxt->dst_filename, ptr, sizeof(ctxt->dst_filename)); ctxt->cfdp_class = UT_Hook_GetArgValueByName(Context, "cfdp_class", CF_CFDP_Class_t); ctxt->keep = UT_Hook_GetArgValueByName(Context, "keep", uint8); - ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", uint8); + ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); ctxt->priority = UT_Hook_GetArgValueByName(Context, "priority", uint8); ctxt->dest_id = UT_Hook_GetArgValueByName(Context, "dest_id", uint16); } diff --git a/unit-test/stubs/cf_cfdp_s_stubs.c b/unit-test/stubs/cf_cfdp_s_stubs.c index e6e49f7b..9a17e0ad 100644 --- a/unit-test/stubs/cf_cfdp_s_stubs.c +++ b/unit-test/stubs/cf_cfdp_s_stubs.c @@ -39,6 +39,19 @@ void CF_CFDP_S1_Recv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) UT_GenStub_Execute(CF_CFDP_S1_Recv, Basic, NULL); } +/* + * ---------------------------------------------------- + * Generated stub function for CF_CFDP_S2_Recv() + * ---------------------------------------------------- + */ +void CF_CFDP_S2_Recv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) +{ + UT_GenStub_AddParam(CF_CFDP_S2_Recv, CF_Transaction_t *, txn); + UT_GenStub_AddParam(CF_CFDP_S2_Recv, CF_Logical_PduBuffer_t *, ph); + + UT_GenStub_Execute(CF_CFDP_S2_Recv, Basic, NULL); +} + /* * ---------------------------------------------------- * Generated stub function for CF_CFDP_S2_SubstateEofAck() @@ -65,19 +78,6 @@ void CF_CFDP_S2_SubstateNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) UT_GenStub_Execute(CF_CFDP_S2_SubstateNak, Basic, NULL); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_CFDP_S2_Recv() - * ---------------------------------------------------- - */ -void CF_CFDP_S2_Recv(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) -{ - UT_GenStub_AddParam(CF_CFDP_S2_Recv, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_CFDP_S2_Recv, CF_Logical_PduBuffer_t *, ph); - - UT_GenStub_Execute(CF_CFDP_S2_Recv, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_CFDP_S_AckTimerTick() @@ -102,32 +102,6 @@ void CF_CFDP_S_CheckState(CF_Transaction_t *txn) UT_GenStub_Execute(CF_CFDP_S_CheckState, Basic, NULL); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_CFDP_S_SubstateEarlyFin() - * ---------------------------------------------------- - */ -void CF_CFDP_S_SubstateEarlyFin(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) -{ - UT_GenStub_AddParam(CF_CFDP_S_SubstateEarlyFin, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_CFDP_S_SubstateEarlyFin, CF_Logical_PduBuffer_t *, ph); - - UT_GenStub_Execute(CF_CFDP_S_SubstateEarlyFin, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_CFDP_S_SubstateRecvFin() - * ---------------------------------------------------- - */ -void CF_CFDP_S_SubstateRecvFin(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) -{ - UT_GenStub_AddParam(CF_CFDP_S_SubstateRecvFin, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_CFDP_S_SubstateRecvFin, CF_Logical_PduBuffer_t *, ph); - - UT_GenStub_Execute(CF_CFDP_S_SubstateRecvFin, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_CFDP_S_HandleFileRetention() @@ -171,6 +145,32 @@ CFE_Status_t CF_CFDP_S_SendFileData(CF_Transaction_t *txn, uint32 foffs, uint32 return UT_GenStub_GetReturnValue(CF_CFDP_S_SendFileData, CFE_Status_t); } +/* + * ---------------------------------------------------- + * Generated stub function for CF_CFDP_S_SubstateEarlyFin() + * ---------------------------------------------------- + */ +void CF_CFDP_S_SubstateEarlyFin(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) +{ + UT_GenStub_AddParam(CF_CFDP_S_SubstateEarlyFin, CF_Transaction_t *, txn); + UT_GenStub_AddParam(CF_CFDP_S_SubstateEarlyFin, CF_Logical_PduBuffer_t *, ph); + + UT_GenStub_Execute(CF_CFDP_S_SubstateEarlyFin, Basic, NULL); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_CFDP_S_SubstateRecvFin() + * ---------------------------------------------------- + */ +void CF_CFDP_S_SubstateRecvFin(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) +{ + UT_GenStub_AddParam(CF_CFDP_S_SubstateRecvFin, CF_Transaction_t *, txn); + UT_GenStub_AddParam(CF_CFDP_S_SubstateRecvFin, CF_Logical_PduBuffer_t *, ph); + + UT_GenStub_Execute(CF_CFDP_S_SubstateRecvFin, Basic, NULL); +} + /* * ---------------------------------------------------- * Generated stub function for CF_CFDP_S_SubstateSendFileData() diff --git a/unit-test/stubs/cf_cfdp_sbintf_stubs.c b/unit-test/stubs/cf_cfdp_sbintf_stubs.c index afd26193..af649ced 100644 --- a/unit-test/stubs/cf_cfdp_sbintf_stubs.c +++ b/unit-test/stubs/cf_cfdp_sbintf_stubs.c @@ -62,9 +62,9 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) * Generated stub function for CF_CFDP_Send() * ---------------------------------------------------- */ -void CF_CFDP_Send(uint8 chan_num, const CF_Logical_PduBuffer_t *ph) +void CF_CFDP_Send(CF_Channel_t *chan_ptr, const CF_Logical_PduBuffer_t *ph) { - UT_GenStub_AddParam(CF_CFDP_Send, uint8, chan_num); + UT_GenStub_AddParam(CF_CFDP_Send, CF_Channel_t *, chan_ptr); UT_GenStub_AddParam(CF_CFDP_Send, const CF_Logical_PduBuffer_t *, ph); UT_GenStub_Execute(CF_CFDP_Send, Basic, NULL); diff --git a/unit-test/stubs/cf_cfdp_stubs.c b/unit-test/stubs/cf_cfdp_stubs.c index 79c35255..a856756f 100644 --- a/unit-test/stubs/cf_cfdp_stubs.c +++ b/unit-test/stubs/cf_cfdp_stubs.c @@ -341,10 +341,12 @@ CF_TxnStatus_t CF_CFDP_GetTxnStatus(const CF_Transaction_t *txn) * Generated stub function for CF_CFDP_InitEngine() * ---------------------------------------------------- */ -CFE_Status_t CF_CFDP_InitEngine(void) +CFE_Status_t CF_CFDP_InitEngine(CF_Engine_t *engine_ptr) { UT_GenStub_SetupReturnBuffer(CF_CFDP_InitEngine, CFE_Status_t); + UT_GenStub_AddParam(CF_CFDP_InitEngine, CF_Engine_t *, engine_ptr); + UT_GenStub_Execute(CF_CFDP_InitEngine, Basic, NULL); return UT_GenStub_GetReturnValue(CF_CFDP_InitEngine, CFE_Status_t); @@ -355,12 +357,16 @@ CFE_Status_t CF_CFDP_InitEngine(void) * Generated stub function for CF_CFDP_InitTxnTxFile() * ---------------------------------------------------- */ -void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, CF_CFDP_Class_t cfdp_class, uint8 keep, uint8 chan, uint8 priority) +void CF_CFDP_InitTxnTxFile(CF_Transaction_t *txn, + CF_CFDP_Class_t cfdp_class, + uint8 keep, + CF_Channel_t *chan, + uint8 priority) { UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, CF_Transaction_t *, txn); UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, CF_CFDP_Class_t, cfdp_class); UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, uint8, keep); - UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, uint8, chan); + UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_CFDP_InitTxnTxFile, uint8, priority); UT_GenStub_Execute(CF_CFDP_InitTxnTxFile, Basic, NULL); @@ -375,7 +381,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, uint16 dest_id) { @@ -385,7 +391,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, UT_GenStub_AddParam(CF_CFDP_PlaybackDir, const char *, dst_filename); UT_GenStub_AddParam(CF_CFDP_PlaybackDir, CF_CFDP_Class_t, cfdp_class); UT_GenStub_AddParam(CF_CFDP_PlaybackDir, uint8, keep); - UT_GenStub_AddParam(CF_CFDP_PlaybackDir, uint8, chan); + UT_GenStub_AddParam(CF_CFDP_PlaybackDir, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_CFDP_PlaybackDir, uint8, priority); UT_GenStub_AddParam(CF_CFDP_PlaybackDir, uint16, dest_id); @@ -578,11 +584,11 @@ CFE_Status_t CF_CFDP_RecvNak(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) * Generated stub function for CF_CFDP_RecvPh() * ---------------------------------------------------- */ -CFE_Status_t CF_CFDP_RecvPh(uint8 chan_num, CF_Logical_PduBuffer_t *ph) +CFE_Status_t CF_CFDP_RecvPh(CF_Channel_t *chan, CF_Logical_PduBuffer_t *ph) { UT_GenStub_SetupReturnBuffer(CF_CFDP_RecvPh, CFE_Status_t); - UT_GenStub_AddParam(CF_CFDP_RecvPh, uint8, chan_num); + UT_GenStub_AddParam(CF_CFDP_RecvPh, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_CFDP_RecvPh, CF_Logical_PduBuffer_t *, ph); UT_GenStub_Execute(CF_CFDP_RecvPh, Basic, NULL); @@ -780,11 +786,11 @@ bool CF_CFDP_StartFirstPending(CF_Channel_t *chan) * Generated stub function for CF_CFDP_StartRxTransaction() * ---------------------------------------------------- */ -CF_Transaction_t *CF_CFDP_StartRxTransaction(uint8 chan_num) +CF_Transaction_t *CF_CFDP_StartRxTransaction(CF_Channel_t *chan) { UT_GenStub_SetupReturnBuffer(CF_CFDP_StartRxTransaction, CF_Transaction_t *); - UT_GenStub_AddParam(CF_CFDP_StartRxTransaction, uint8, chan_num); + UT_GenStub_AddParam(CF_CFDP_StartRxTransaction, CF_Channel_t *, chan); UT_GenStub_Execute(CF_CFDP_StartRxTransaction, Basic, NULL); @@ -812,7 +818,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, const char *dst_filename, CF_CFDP_Class_t cfdp_class, uint8 keep, - uint8 chan, + CF_Channel_t *chan, uint8 priority, CF_EntityId_t dest_id) { @@ -822,7 +828,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, UT_GenStub_AddParam(CF_CFDP_TxFile, const char *, dst_filename); UT_GenStub_AddParam(CF_CFDP_TxFile, CF_CFDP_Class_t, cfdp_class); UT_GenStub_AddParam(CF_CFDP_TxFile, uint8, keep); - UT_GenStub_AddParam(CF_CFDP_TxFile, uint8, chan); + UT_GenStub_AddParam(CF_CFDP_TxFile, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_CFDP_TxFile, uint8, priority); UT_GenStub_AddParam(CF_CFDP_TxFile, CF_EntityId_t, dest_id); diff --git a/unit-test/stubs/cf_cmd_stubs.c b/unit-test/stubs/cf_cmd_stubs.c index bf64cb2c..887ff78a 100644 --- a/unit-test/stubs/cf_cmd_stubs.c +++ b/unit-test/stubs/cf_cmd_stubs.c @@ -138,11 +138,11 @@ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) * ---------------------------------------------------- */ CF_ChanAction_Status_t -CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanActionFn_t fn, void *context) +CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context) { UT_GenStub_SetupReturnBuffer(CF_DoChanAction, CF_ChanAction_Status_t); - UT_GenStub_AddParam(CF_DoChanAction, const CF_UnionArgs_Payload_t *, data); + UT_GenStub_AddParam(CF_DoChanAction, CF_ChannelSelect_t, chan_select); UT_GenStub_AddParam(CF_DoChanAction, const char *, errstr); UT_GenStub_AddParam(CF_DoChanAction, CF_ChanActionFn_t, fn); UT_GenStub_AddParam(CF_DoChanAction, void *, context); @@ -157,11 +157,11 @@ CF_DoChanAction(const CF_UnionArgs_Payload_t *data, const char *errstr, CF_ChanA * Generated stub function for CF_DoEnableDisableDequeue() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg) { UT_GenStub_SetupReturnBuffer(CF_DoEnableDisableDequeue, CF_ChanAction_Status_t); - UT_GenStub_AddParam(CF_DoEnableDisableDequeue, uint8, chan_num); + UT_GenStub_AddParam(CF_DoEnableDisableDequeue, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_DoEnableDisableDequeue, void *, arg); UT_GenStub_Execute(CF_DoEnableDisableDequeue, Basic, NULL); @@ -174,11 +174,11 @@ CF_ChanAction_Status_t CF_DoEnableDisableDequeue(uint8 chan_num, void *arg) * Generated stub function for CF_DoEnableDisablePolldir() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg) { UT_GenStub_SetupReturnBuffer(CF_DoEnableDisablePolldir, CF_ChanAction_Status_t); - UT_GenStub_AddParam(CF_DoEnableDisablePolldir, uint8, chan_num); + UT_GenStub_AddParam(CF_DoEnableDisablePolldir, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_DoEnableDisablePolldir, void *, arg); UT_GenStub_Execute(CF_DoEnableDisablePolldir, Basic, NULL); @@ -191,11 +191,11 @@ CF_ChanAction_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, void *arg) * Generated stub function for CF_DoFreezeThaw() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_DoFreezeThaw(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg) { UT_GenStub_SetupReturnBuffer(CF_DoFreezeThaw, CF_ChanAction_Status_t); - UT_GenStub_AddParam(CF_DoFreezeThaw, uint8, chan_num); + UT_GenStub_AddParam(CF_DoFreezeThaw, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_DoFreezeThaw, void *, arg); UT_GenStub_Execute(CF_DoFreezeThaw, Basic, NULL); @@ -208,11 +208,11 @@ CF_ChanAction_Status_t CF_DoFreezeThaw(uint8 chan_num, void *arg) * Generated stub function for CF_DoPurgeQueue() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_DoPurgeQueue(uint8 chan_num, void *arg) +CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg) { UT_GenStub_SetupReturnBuffer(CF_DoPurgeQueue, CF_ChanAction_Status_t); - UT_GenStub_AddParam(CF_DoPurgeQueue, uint8, chan_num); + UT_GenStub_AddParam(CF_DoPurgeQueue, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_DoPurgeQueue, void *, arg); UT_GenStub_Execute(CF_DoPurgeQueue, Basic, NULL); @@ -348,12 +348,12 @@ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) * Generated stub function for CF_GetSetParamCmd() * ---------------------------------------------------- */ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, uint8 chan_num) +void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num) { UT_GenStub_AddParam(CF_GetSetParamCmd, bool, is_set); UT_GenStub_AddParam(CF_GetSetParamCmd, CF_GetSet_ValueID_t, param_id); UT_GenStub_AddParam(CF_GetSetParamCmd, uint32, value); - UT_GenStub_AddParam(CF_GetSetParamCmd, uint8, chan_num); + UT_GenStub_AddParam(CF_GetSetParamCmd, CF_ChannelSelect_t, chan_num); UT_GenStub_Execute(CF_GetSetParamCmd, Basic, NULL); } @@ -579,12 +579,12 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) * Generated stub function for CF_ValidateChunkSizeCmd() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_num) +CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan) { UT_GenStub_SetupReturnBuffer(CF_ValidateChunkSizeCmd, CF_ChanAction_Status_t); UT_GenStub_AddParam(CF_ValidateChunkSizeCmd, CF_ChunkSize_t, val); - UT_GenStub_AddParam(CF_ValidateChunkSizeCmd, uint8, chan_num); + UT_GenStub_AddParam(CF_ValidateChunkSizeCmd, CF_Channel_t *, chan); UT_GenStub_Execute(CF_ValidateChunkSizeCmd, Basic, NULL); @@ -596,12 +596,12 @@ CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, uint8 chan_nu * Generated stub function for CF_ValidateMaxOutgoingCmd() * ---------------------------------------------------- */ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, uint8 chan_num) +CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) { UT_GenStub_SetupReturnBuffer(CF_ValidateMaxOutgoingCmd, CF_ChanAction_Status_t); UT_GenStub_AddParam(CF_ValidateMaxOutgoingCmd, uint32, val); - UT_GenStub_AddParam(CF_ValidateMaxOutgoingCmd, uint8, chan_num); + UT_GenStub_AddParam(CF_ValidateMaxOutgoingCmd, CF_Channel_t *, chan); UT_GenStub_Execute(CF_ValidateMaxOutgoingCmd, Basic, NULL); diff --git a/unit-test/stubs/cf_utils_handlers.c b/unit-test/stubs/cf_utils_handlers.c index eb65f59c..7566496c 100644 --- a/unit-test/stubs/cf_utils_handlers.c +++ b/unit-test/stubs/cf_utils_handlers.c @@ -201,3 +201,30 @@ void UT_DefaultHandler_CF_WrappedOpenCreate(void *UserObj, UT_EntryKey_t FuncKey UT_Stub_SetReturnValue(FuncKey, ctxt->forced_return); } } + +/*---------------------------------------------------------------- + * + * Function: UT_DefaultHandler_CF_ForEachChannel + * + * Invokes the passed-in, as this is usually required for correct operation + * + *-----------------------------------------------------------------*/ +void UT_DefaultHandler_CF_ForEachChannel(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CF_Engine_t *engine_ptr = UT_Hook_GetArgValueByName(Context, "engine_ptr", CF_Engine_t *); + CF_ChannelFunc_t fn = UT_Hook_GetArgValueByName(Context, "fn", CF_ChannelFunc_t); + void *arg = UT_Hook_GetArgValueByName(Context, "arg", void *); + int32 ret; + + if (fn) + { + ret = fn(engine_ptr, &engine_ptr->channels[UT_CFDP_CHANNEL_IDX], arg); + } + else + { + ret = CFE_SUCCESS; + } + + UT_Stub_SetReturnValue(FuncKey, ret); +} + diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index c4828745..605ed2db 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -28,6 +28,7 @@ void UT_DefaultHandler_CF_FindTransactionBySequenceNumber(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_FindUnusedTransaction(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CF_ForEachChannel(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_ResetHistory(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_TraverseAllTransactions(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels(void *, UT_EntryKey_t, const UT_StubContext_t *); @@ -107,31 +108,32 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *chan, CF_Direction_t di /* * ---------------------------------------------------- - * Generated stub function for CF_FreeTransaction() + * Generated stub function for CF_ForEachChannel() * ---------------------------------------------------- */ -void CF_FreeTransaction(CF_Transaction_t *txn, uint8 chan) +int32 CF_ForEachChannel(CF_Engine_t *engine_ptr, CF_ChannelFunc_t fn, void *arg) { - UT_GenStub_AddParam(CF_FreeTransaction, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_FreeTransaction, uint8, chan); + UT_GenStub_SetupReturnBuffer(CF_ForEachChannel, int32); - UT_GenStub_Execute(CF_FreeTransaction, Basic, NULL); + UT_GenStub_AddParam(CF_ForEachChannel, CF_Engine_t *, engine_ptr); + UT_GenStub_AddParam(CF_ForEachChannel, CF_ChannelFunc_t, fn); + UT_GenStub_AddParam(CF_ForEachChannel, void *, arg); + + UT_GenStub_Execute(CF_ForEachChannel, Basic, UT_DefaultHandler_CF_ForEachChannel); + + return UT_GenStub_GetReturnValue(CF_ForEachChannel, int32); } /* * ---------------------------------------------------- - * Generated stub function for CF_GetChannelFromTxn() + * Generated stub function for CF_FreeTransaction() * ---------------------------------------------------- */ -CF_Channel_t *CF_GetChannelFromTxn(CF_Transaction_t *txn) +void CF_FreeTransaction(CF_Transaction_t *txn) { - UT_GenStub_SetupReturnBuffer(CF_GetChannelFromTxn, CF_Channel_t *); - - UT_GenStub_AddParam(CF_GetChannelFromTxn, CF_Transaction_t *, txn); - - UT_GenStub_Execute(CF_GetChannelFromTxn, Basic, NULL); + UT_GenStub_AddParam(CF_FreeTransaction, CF_Transaction_t *, txn); - return UT_GenStub_GetReturnValue(CF_GetChannelFromTxn, CF_Channel_t *); + UT_GenStub_Execute(CF_FreeTransaction, Basic, NULL); } /* diff --git a/unit-test/utilities/cf_test_utils.c b/unit-test/utilities/cf_test_utils.c index 5a13dddb..cef15ec7 100644 --- a/unit-test/utilities/cf_test_utils.c +++ b/unit-test/utilities/cf_test_utils.c @@ -389,7 +389,7 @@ void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length) } /* cf specific */ -uint8 Any_cf_chan_num(void) +CF_ChannelSelect_t Any_cf_chan_num(void) { - return Any_uint8_LessThan(CF_NUM_CHANNELS); + return (Any_uint8_LessThan(CF_NUM_CHANNELS)); } diff --git a/unit-test/utilities/cf_test_utils.h b/unit-test/utilities/cf_test_utils.h index 63f80f11..0960cdd7 100644 --- a/unit-test/utilities/cf_test_utils.h +++ b/unit-test/utilities/cf_test_utils.h @@ -45,7 +45,9 @@ #define RANDOM_VALUES_SEED 0 #endif /* !RANDOM_VALUES_SEED */ -#define UT_CFDP_CHANNEL 0 +#define UT_CFDP_CHANNEL_IDX 0 +#define UT_CFDP_CHANNEL CF_ChannelSelect_FromInt(UT_CFDP_CHANNEL_IDX) +#define UT_CFDP_CHANNEL_PTR CF_GetChannelPtr(UT_CFDP_CHANNEL) typedef enum { @@ -67,9 +69,9 @@ typedef struct { char src_filename[CF_FILENAME_MAX_LEN]; char dst_filename[CF_FILENAME_MAX_LEN]; + CF_Channel_t *chan; CF_CFDP_Class_t cfdp_class; uint8 keep; - uint8 chan; uint8 priority; CF_EntityId_t dest_id; } CF_CFDP_TxFile_context_t; @@ -78,9 +80,9 @@ typedef struct { char src_filename[CF_FILENAME_MAX_LEN]; char dst_filename[CF_FILENAME_MAX_LEN]; + CF_Channel_t *chan; CF_CFDP_Class_t cfdp_class; uint8 keep; - uint8 chan; uint8 priority; CF_EntityId_t dest_id; } CF_CFDP_PlaybackDir_context_t; @@ -252,6 +254,6 @@ int Any_int_Positive(void); char *AnyRandomStringOfLettersOfLength(size_t length); void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length); -uint8 Any_cf_chan_num(void); +CF_ChannelSelect_t Any_cf_chan_num(void); #endif From 12958cc2cca186c04cd06b0825ddd1f4d8bc0f2b Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 7 Aug 2026 13:20:54 -0400 Subject: [PATCH 07/18] Fix #90, correct workflow errors --- fsw/src/cf_cmd.h | 16 ++++++++-------- unit-test/cf_app_tests.c | 24 +++++++++--------------- unit-test/stubs/cf_utils_handlers.c | 1 - 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 87fbc3f1..d0881722 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -199,7 +199,7 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg); * @par Assumptions, External Events, and Notes: * cmd must not be NULL, errstr must not be NULL, fn must be a valid function, context may be NULL. * - * @param data Pointer to payload being processed + * @param chan_select Channel selector value from command (validated within this function) * @param errstr String to be included in the EVS event if command should fail * @param fn Callback action function to invoke for each affected channel * @param context Opaque pointer to pass through to callback (not used in this function) @@ -216,7 +216,7 @@ CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActio * @par Assumptions, External Events, and Notes: * context must not be NULL. * - * @param chan_num channel number + * @param chan channel pointer (must not be NULL) * @param arg context pointer to object, must be CF_ChanAction_BoolArg_t* * * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. @@ -380,7 +380,7 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg); * @par Assumptions, External Events, and Notes: * context must not be NULL. * - * @param chan_num channel number + * @param chan channel pointer (must not be NULL) * @param arg context pointer to object, must be CF_ChanAction_BoolArg_t* * * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. @@ -414,7 +414,7 @@ CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg); * @par Assumptions, External Events, and Notes: * context must not be NULL. * - * @param chan_num channel number + * @param chan channel pointer (must not be NULL) * @param arg context pointer to object, must be CF_ChanAction_BoolMsgArg_t* * * @returns success/fail status code @@ -483,7 +483,7 @@ CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignore * @par Assumptions, External Events, and Notes: * None * - * @param chan_num CF channel number + * @param chan CF channel pointer (must not be NULL) * @param arg Pointer to purge queue command * * @returns integer status code indicating success or failure @@ -519,7 +519,7 @@ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg); * None * * @param val Size of chunk to test - * @param chan_num Ignored by this implementation + * @param chan Ignored by this implementation * * @returns status code indicating if check passed * @retval CF_ChanAction_Status_SUCCESS if successful (val is less than or equal to max PDU) @@ -535,7 +535,7 @@ CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t * None * * @param val Number to test - * @param chan_num CF channel number + * @param chan CF channel pointer * * @returns status code indicating if check passed * @retval CF_ChanAction_Status_SUCCESS if successful (val is allowable as max packets per wakeup) @@ -559,7 +559,7 @@ CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) * @param is_set Whether to get (false) or set (true) * @param param_id Parameter ID * @param value Value to get/set - * @param chan_num Channel number to operate on + * @param chan_num Channel selector from original command (Validated within this function) * */ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num); diff --git a/unit-test/cf_app_tests.c b/unit-test/cf_app_tests.c index ae0a12a0..5e927df3 100644 --- a/unit-test/cf_app_tests.c +++ b/unit-test/cf_app_tests.c @@ -137,27 +137,21 @@ void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_ReturnsNot_CFE_SUCCESS_Or_CFE UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); } -void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_SUCCESS(void) +void Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_SUCCESS(void) { - CF_ConfigTable_t ut_config; - void *TablePtr = &ut_config; - - memset(&ut_config, 0, sizeof(ut_config)); - - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_TBL_INFO_UPDATED); - UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TablePtr, sizeof(TablePtr), false); + UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_Manage), CFE_SUCCESS); /* Act */ CF_CheckTables(); /* Assert */ - UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 1); + UtAssert_STUB_COUNT(CFE_TBL_ReleaseAddress, 0); UtAssert_STUB_COUNT(CFE_TBL_Manage, 1); - UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 1); + UtAssert_STUB_COUNT(CFE_TBL_GetAddress, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); } -void Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED(void) +void Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_TBL_INFO_UPDATED(void) { CF_ConfigTable_t ut_config; void *TablePtr = &ut_config; @@ -636,14 +630,14 @@ void add_CF_CheckTables_tests(void) Setup_cf_config_table_tests, CF_App_Tests_Teardown, "Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_ReturnsNot_CFE_SUCCESS_Or_CFE_TBL_INFO_UPDATED_SendEvent"); - UtTest_Add(Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_SUCCESS, + UtTest_Add(Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_SUCCESS, Setup_cf_config_table_tests, CF_App_Tests_Teardown, - "Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_SUCCESS"); - UtTest_Add(Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED, + "Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_SUCCESS"); + UtTest_Add(Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_TBL_INFO_UPDATED, Setup_cf_config_table_tests, CF_App_Tests_Teardown, - "Test_CF_CheckTables_CallTo_CFE_TBL_GetAddress_Returns_CFE_TBL_INFO_UPDATED"); + "Test_CF_CheckTables_CallTo_CFE_TBL_Manage_Returns_CFE_TBL_INFO_UPDATED"); } void add_CF_ValidateConfigTable_tests(void) diff --git a/unit-test/stubs/cf_utils_handlers.c b/unit-test/stubs/cf_utils_handlers.c index 7566496c..05a99148 100644 --- a/unit-test/stubs/cf_utils_handlers.c +++ b/unit-test/stubs/cf_utils_handlers.c @@ -227,4 +227,3 @@ void UT_DefaultHandler_CF_ForEachChannel(void *UserObj, UT_EntryKey_t FuncKey, c UT_Stub_SetReturnValue(FuncKey, ret); } - From 7debcb8d395a498cf3d94d792ebdffa267ffd1fc Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 21 Aug 2026 12:45:17 -0400 Subject: [PATCH 08/18] Fix #90, selectively clear data during InitEngine Incorporates review feedback to re-instate the data clearing that occured during CF_InitEngine, but do so in a way that preserves the configuration data that is already populated. --- fsw/src/cf_cfdp.c | 71 +++++++++++++++++++++----------- fsw/src/cf_cfdp_sbintf.c | 6 +-- fsw/src/cf_cfdp_types.h | 22 ++++------ unit-test/cf_cfdp_sbintf_tests.c | 12 +++--- unit-test/cf_cfdp_tests.c | 64 ++++++++++++++-------------- 5 files changed, 96 insertions(+), 79 deletions(-) diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index ab693389..c8491c45 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1255,6 +1255,18 @@ static int32 CF_CFDP_DoEngineChannelInit(CF_Engine_t *engine_ptr, CF_Channel_t * char nbuf[64]; CFE_Status_t ret = CFE_SUCCESS; + /* selectively wipe data within the channel struct - + * note this struct also contains the config which is already + * populated and needs to be preserved */ + + memset(chan->qs, 0, sizeof(chan->qs)); + memset(chan->cs, 0, sizeof(chan->cs)); + memset(&chan->stat, 0, sizeof(chan->stat)); + + chan->pipe = CFE_SB_INVALID_PIPE; + chan->sem_id = OS_OBJECT_ID_UNDEFINED; + chan->tick_resume = NULL; + snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, chan_num); ret = CFE_SB_CreatePipe(&chan->pipe, chan->config.pipe_depth_input, nbuf); if (ret != CFE_SUCCESS) @@ -1356,10 +1368,19 @@ CFE_Status_t CF_CFDP_InitEngine(CF_Engine_t *engine_ptr) CFE_Status_t ret; CF_EngineInitState_t state; - /* NOTE: Not clearing the engine global struct here. - * It was already cleared at the beginning of CF_AppInit(), and - * since then the configuration was imported from the table. Clearing - * the global would wipe that configuration data. */ + /* NOTE: Selectively clearing members so we do not + * wipe the configuration data which is also stored here. */ + + engine_ptr->seq_num = 0; + engine_ptr->enabled = false; + + memset(&engine_ptr->out, 0, sizeof(engine_ptr->out)); + memset(&engine_ptr->in, 0, sizeof(engine_ptr->in)); + + memset(engine_ptr->transactions, 0, sizeof(engine_ptr->transactions)); + memset(engine_ptr->histories, 0, sizeof(engine_ptr->histories)); + memset(engine_ptr->chunks, 0, sizeof(engine_ptr->chunks)); + memset(engine_ptr->chunk_mem, 0, sizeof(engine_ptr->chunk_mem)); /* Ensure that the temp directory exists (ignore error if it already exists) */ OS_mkdir(engine_ptr->config.tmp_dir, 0); @@ -1412,13 +1433,13 @@ static void CF_CFDP_S_Tick_SendFileData(CF_Transaction_t *txn) */ do { - last_outgoing_counter = chan->outgoing_counter; + last_outgoing_counter = chan->stat.outgoing_counter; CFE_ES_PerfLogEntry(CF_PERF_ID_PDUSENT(chan_num)); CF_CFDP_S_SubstateSendFileData(txn); CFE_ES_PerfLogExit(CF_PERF_ID_PDUSENT(chan_num)); - } while (last_outgoing_counter != chan->outgoing_counter); + } while (last_outgoing_counter != chan->stat.outgoing_counter); } /*---------------------------------------------------------------- @@ -1484,7 +1505,7 @@ CF_CListTraverse_Status_t CF_CFDP_DoTick(CF_CListNode_t *node, void *context) /* if args->chan->cur was set to not-NULL above, then exit early */ /* NOTE: if channel is frozen, then tick processing won't have been entered. * so there is no need to check it here */ - if (args->chan->tx_blocked) + if (args->chan->stat.tx_blocked) { ret = CF_CLIST_EXIT; } @@ -1505,7 +1526,7 @@ void CF_CFDP_CompleteTick(CF_Transaction_t *txn) /* check if the TX is now blocked and if so, record this txn as the resume point */ chan = CF_GetChannelFromTxn(txn); - if (chan != NULL && chan->tx_blocked && chan->tick_resume == NULL) + if (chan != NULL && chan->stat.tx_blocked && chan->tick_resume == NULL) { chan->tick_resume = txn; } @@ -1550,7 +1571,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *chan) */ while (curr_state < CF_TickState_COMPLETE) { - last_counter = chan->outgoing_counter; + last_counter = chan->stat.outgoing_counter; switch (curr_state) { @@ -1588,7 +1609,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *chan) } /* If blocked, stop */ - if (chan->tx_blocked) + if (chan->stat.tx_blocked) { break; } @@ -1599,7 +1620,7 @@ void CF_CFDP_TickTransactions(CF_Channel_t *chan) case CF_TickState_TX_NAK: /* This should be repeated so long as something was produced */ /* advance state only if the last pass sent nothing */ - if (last_counter == chan->outgoing_counter) + if (last_counter == chan->stat.outgoing_counter) { ++curr_state; } @@ -1701,7 +1722,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, CF_TRACE("%s(): start, channel=%d\n", __func__, CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan))); - if (chan->num_cmd_tx < CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN) + if (chan->stat.num_cmd_tx < CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN) { txn = CF_FindUnusedTransaction(chan, CF_Direction_TX); } @@ -1726,7 +1747,7 @@ CFE_Status_t CF_CFDP_TxFile(const char *src_filename, txn->history->fnames.dst_filename[sizeof(txn->history->fnames.dst_filename) - 1] = 0; CF_CFDP_TxFile_Initiate(txn, cfdp_class, keep, chan, priority, dest_id); - ++chan->num_cmd_tx; + ++chan->stat.num_cmd_tx; txn->flags.tx.cmd_tx = true; } @@ -1830,7 +1851,7 @@ CFE_Status_t CF_CFDP_PlaybackDir(const char *src_filename, for (i = 0; i < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++i) { - pb = &chan->playback[i]; + pb = &chan->stat.playback[i]; if (!pb->busy) { break; @@ -1964,8 +1985,8 @@ static void CF_CFDP_ProcessPlaybackDirectories(CF_Channel_t *chan) for (i = 0; i < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++i) { - CF_CFDP_ProcessPlaybackDirectory(chan, &chan->playback[i]); - CF_CFDP_UpdatePollPbCounted(&chan->playback[i], chan->playback[i].busy, &chan->stat.playback_counter); + CF_CFDP_ProcessPlaybackDirectory(chan, &chan->stat.playback[i]); + CF_CFDP_UpdatePollPbCounted(&chan->stat.playback[i], chan->stat.playback[i].busy, &chan->stat.playback_counter); } } @@ -1986,7 +2007,7 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) { - poll = &chan->poll[i]; + poll = &chan->stat.poll[i]; cc = &chan->config; pd = &cc->polldir[i]; count_check = 0; @@ -2051,8 +2072,8 @@ void CF_CFDP_ProcessPollingDirectories(CF_Channel_t *chan) *-----------------------------------------------------------------*/ static int32 CF_CFDP_DoEngineChannelCycle(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { - chan->outgoing_counter = 0; - chan->tx_blocked = false; + chan->stat.outgoing_counter = 0; + chan->stat.tx_blocked = false; /* consume all received messages, even if channel is frozen */ CF_CFDP_ReceiveMessage(chan); @@ -2123,9 +2144,9 @@ void CF_CFDP_FinishTransaction(CF_Transaction_t *txn, bool keep_history) /* extra bookkeeping for tx direction only */ if (txn->history->dir == CF_Direction_TX && txn->flags.tx.cmd_tx) { - CF_Assert(chan->num_cmd_tx); /* sanity check */ + CF_Assert(chan->stat.num_cmd_tx); /* sanity check */ - --chan->num_cmd_tx; + --chan->stat.num_cmd_tx; } txn->flags.com.keep_history = keep_history; @@ -2360,17 +2381,17 @@ static int32 CF_CFDP_DoCloseChannel(CF_Engine_t *engine_ptr, CF_Channel_t *chan, /* any playback directories need to have their directory ids closed */ for (j = 0; j < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++j) { - if (chan->playback[j].busy) + if (chan->stat.playback[j].busy) { - OS_DirectoryClose(chan->playback[j].dir_id); + OS_DirectoryClose(chan->stat.playback[j].dir_id); } } for (j = 0; j < CF_MAX_POLLING_DIR_PER_CHAN; ++j) { - if (chan->poll[j].pb.busy) + if (chan->stat.poll[j].pb.busy) { - OS_DirectoryClose(chan->poll[j].pb.dir_id); + OS_DirectoryClose(chan->stat.poll[j].pb.dir_id); } } diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index 4a994b79..190cca15 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -78,7 +78,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile } if (chan->config.max_outgoing_messages_per_wakeup - && (chan->outgoing_counter >= chan->config.max_outgoing_messages_per_wakeup)) + && (chan->stat.outgoing_counter >= chan->config.max_outgoing_messages_per_wakeup)) { /* no more messages this wakeup allowed */ success = false; @@ -119,7 +119,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile CFE_MSG_Init(&engine_ptr->out.msg->Msg, CFE_SB_ValueToMsgId(chan->config.mid_output), offsetof(CF_PduTlmMsg_t, ph)); - ++chan->outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok + ++chan->stat.outgoing_counter; /* even if max_outgoing_messages_per_wakeup is 0 (unlimited), it's ok to inc this */ /* prepare for encoding - the "tx_pdudata" is what serves as the temporary holding area for content */ @@ -132,7 +132,7 @@ CF_Logical_PduBuffer_t *CF_CFDP_MsgOutGet(const CF_Transaction_t *txn, bool sile if (ret == NULL) { /* stop trying to send anything until next wake up */ - chan->tx_blocked = true; + chan->stat.tx_blocked = true; } else { diff --git a/fsw/src/cf_cfdp_types.h b/fsw/src/cf_cfdp_types.h index 01fb0f1e..77392ebf 100644 --- a/fsw/src/cf_cfdp_types.h +++ b/fsw/src/cf_cfdp_types.h @@ -442,6 +442,14 @@ typedef struct CF_LocalChanStat uint8 poll_counter; /**< \brief Number of active polling directories */ uint8 playback_counter; /**< \brief Number of active playback directories */ bool frozen; /**< \brief Frozen state: 0 == not frozen, else frozen */ + bool tx_blocked; /**< Set true if PDU transmission was blocked due to limits */ + + uint32 num_cmd_tx; + uint32 outgoing_counter; + + CF_Playback_t playback[CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN]; + CF_Poll_t poll[CF_MAX_POLLING_DIR_PER_CHAN]; + } CF_LocalChanStat_t; /** @@ -459,17 +467,7 @@ struct CF_Channel CF_CListNode_t *cs[CF_Direction_NUM]; CFE_SB_PipeId_t pipe; - - uint32 num_cmd_tx; - - CF_Playback_t playback[CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN]; - - /* For polling directories, the configuration data is in a table. */ - CF_Poll_t poll[CF_MAX_POLLING_DIR_PER_CHAN]; - - osal_id_t sem_id; /**< \brief semaphore id for output pipe */ - - uint32 outgoing_counter; + osal_id_t sem_id; /**< \brief semaphore id for output pipe */ /* If tick processing gets blocked due to TX limits (i.e. tx_blocked gets set during * tick processing) then this captures where the tick processing left off. @@ -478,8 +476,6 @@ struct CF_Channel * items get ticked. */ const CF_Transaction_t *tick_resume; - bool tx_blocked; /**< Set true if PDU transmission was blocked due to limits */ - CF_LocalChanConfig_t config; CF_LocalChanStat_t stat; }; diff --git a/unit-test/cf_cfdp_sbintf_tests.c b/unit-test/cf_cfdp_sbintf_tests.c index a7a2e0d5..7340b88a 100644 --- a/unit-test/cf_cfdp_sbintf_tests.c +++ b/unit-test/cf_cfdp_sbintf_tests.c @@ -126,9 +126,9 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, ut_transaction.history = &ut_history; ut_transaction.chan_ptr = local_channel_p; - local_channel_p->outgoing_counter = 0; - local_channel_p->num_cmd_tx = 0; - local_channel_p->tx_blocked = 0; + local_channel_p->stat.outgoing_counter = 0; + local_channel_p->stat.num_cmd_tx = 0; + local_channel_p->stat.tx_blocked = 0; if (pdu_buffer_p) { @@ -295,11 +295,11 @@ void Test_CF_CFDP_MsgOutGet(void) /* test the various throttling mechanisms */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, &config); chan->config.max_outgoing_messages_per_wakeup = 3; - chan->outgoing_counter = 2; + chan->stat.outgoing_counter = 2; UtAssert_NOT_NULL(CF_CFDP_MsgOutGet(txn, false)); - UtAssert_BOOL_FALSE(chan->tx_blocked); + UtAssert_BOOL_FALSE(chan->stat.tx_blocked); UtAssert_NULL(CF_CFDP_MsgOutGet(txn, false)); - UtAssert_BOOL_TRUE(chan->tx_blocked); + UtAssert_BOOL_TRUE(chan->stat.tx_blocked); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, &txn, NULL); diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index c39560d3..834cadc5 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -931,7 +931,7 @@ void Test_CF_CFDP_TxFile(void) UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_1, 1, UT_CFDP_CHANNEL_PTR, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); - UtAssert_UINT32_EQ(chan->num_cmd_tx, 1); + UtAssert_UINT32_EQ(chan->stat.num_cmd_tx, 1); UT_CF_AssertEventID(CF_CFDP_S_START_SEND_INF_EID); /* same but for class 2 (for branch coverage) */ @@ -942,12 +942,12 @@ void Test_CF_CFDP_TxFile(void) UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_2, 1, UT_CFDP_CHANNEL_PTR, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); - UtAssert_UINT32_EQ(chan->num_cmd_tx, 2); + UtAssert_UINT32_EQ(chan->stat.num_cmd_tx, 2); UT_CF_AssertEventID(CF_CFDP_S_START_SEND_INF_EID); /* max TX */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, &history, &txn, NULL); - chan->num_cmd_tx = CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN; + chan->stat.num_cmd_tx = CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN; UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_1, 1, UT_CFDP_CHANNEL_PTR, 0, 1), -1); UT_CF_AssertEventID(CF_CFDP_MAX_CMD_TX_ERR_EID); } @@ -990,7 +990,7 @@ void Test_CF_CFDP_PlaybackDir(void) /* nominal call */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, NULL); - pb = &chan->playback[0]; + pb = &chan->stat.playback[0]; memset(pb, 0, sizeof(*pb)); UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_Class_1, 1, chan, 0, 1), 0); UtAssert_STRINGBUF_EQ(dest, -1, pb->fnames.dst_filename, sizeof(pb->fnames.dst_filename)); @@ -1008,7 +1008,7 @@ void Test_CF_CFDP_PlaybackDir(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, NULL, NULL); for (i = 0; i < CF_MAX_COMMANDED_PLAYBACK_DIRECTORIES_PER_CHAN; ++i) { - pb = &chan->playback[i]; + pb = &chan->stat.playback[i]; pb->busy = true; } UtAssert_INT32_EQ(CF_CFDP_PlaybackDir(src, dest, CF_CFDP_Class_1, 1, chan, 0, 1), -1); @@ -1022,7 +1022,7 @@ Ut_Hook_StateHandler_SetCount(void *UserObj, int32 StubRetcode, uint32 CallCount if (CallCount < 3) { - ++chan->outgoing_counter; + ++chan->stat.outgoing_counter; } return StubRetcode; } @@ -1058,7 +1058,7 @@ static void DoTickFnSetBlocked(CF_Transaction_t *txn) { CF_Channel_t *chan = CF_GetChannelFromTxn(txn); - chan->tx_blocked = true; + chan->stat.tx_blocked = true; } static void DoTickNoop(CF_Transaction_t *txn) @@ -1117,7 +1117,7 @@ void Test_CF_CFDP_ProcessPollingDirectories(void) UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, NULL, NULL, &config); pdcfg = &chan->config.polldir[0]; - poll = &chan->poll[0]; + poll = &chan->stat.poll[0]; /* nominal call, polldir disabled (noop) */ UtAssert_VOIDCALL(CF_CFDP_ProcessPollingDirectories(chan)); @@ -1263,7 +1263,7 @@ Ut_Hook_TickTransactions_SetBlocked(void *UserObj, int32 StubRetcode, uint32 Cal if (CallCount != 0) { - args->chan->tx_blocked = true; + args->chan->stat.tx_blocked = true; } return StubRetcode; @@ -1278,7 +1278,7 @@ static int32 Ut_Hook_TickTransactions_UpdateCount(void *UserOb if (CallCount < 5) { - ++chan->outgoing_counter; + ++chan->stat.outgoing_counter; } return StubRetcode; @@ -1303,7 +1303,7 @@ void Test_CF_CFDP_TickTransactions(void) UT_ResetState(UT_KEY(CF_CList_Traverse)); UT_SetHookFunction(UT_KEY(CF_CList_Traverse), Ut_Hook_TickTransactions_UpdateCount, chan); - chan->tx_blocked = false; + chan->stat.tx_blocked = false; UtAssert_VOIDCALL(CF_CFDP_TickTransactions(chan)); UtAssert_STUB_COUNT(CF_CList_Traverse, 7); /* because NAK is repeated several times */ } @@ -1385,19 +1385,19 @@ void Test_CF_CFDP_FinishTransaction(void) UtAssert_BOOL_TRUE(txn->flags.com.keep_history); /* coverage completeness: - * test decrement of chan->num_cmd_tx + * test decrement of chan->stat.num_cmd_tx * test decrement of playback num_ts */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_TX, NULL, &chan, &history, &txn, NULL); - pb.num_ts = 10; - txn->pb = &pb; - txn->flags.tx.cmd_tx = 5; - chan->num_cmd_tx = 8; - history->dir = CF_Direction_TX; - txn->state = CF_TxnState_S1; + pb.num_ts = 10; + txn->pb = &pb; + txn->flags.tx.cmd_tx = 5; + chan->stat.num_cmd_tx = 8; + history->dir = CF_Direction_TX; + txn->state = CF_TxnState_S1; UtAssert_VOIDCALL(CF_CFDP_FinishTransaction(txn, true)); UtAssert_UINT32_EQ(pb.num_ts, 9); - UtAssert_UINT32_EQ(chan->num_cmd_tx, 7); + UtAssert_UINT32_EQ(chan->stat.num_cmd_tx, 7); /* coverage completeness: history is NULL (should never happen in real use) */ UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, &history, &txn, NULL); @@ -1528,10 +1528,10 @@ void Test_CF_CFDP_DisableEngine(void) UtAssert_BOOL_FALSE(engine_ptr->enabled); /* nominal call with playbacks and polls active */ - chan->playback[0].busy = true; - OS_DirectoryOpen(&chan->playback[0].dir_id, "ut"); - chan->poll[0].pb.busy = true; - OS_DirectoryOpen(&chan->poll[0].pb.dir_id, "ut"); + chan->stat.playback[0].busy = true; + OS_DirectoryOpen(&chan->stat.playback[0].dir_id, "ut"); + chan->stat.poll[0].pb.busy = true; + OS_DirectoryOpen(&chan->stat.poll[0].pb.dir_id, "ut"); UtAssert_VOIDCALL(CF_CFDP_DisableEngine()); UtAssert_STUB_COUNT(OS_DirectoryClose, 2); } @@ -1859,27 +1859,27 @@ void Test_CF_CFDP_CompleteTick(void) CF_Channel_t *chan; UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - chan->tx_blocked = true; - chan->tick_resume = NULL; + chan->stat.tx_blocked = true; + chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_ADDRESS_EQ(chan->tick_resume, txn); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - chan->tx_blocked = true; - chan->tick_resume = &txn2; + chan->stat.tx_blocked = true; + chan->tick_resume = &txn2; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_ADDRESS_EQ(chan->tick_resume, &txn2); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - chan->tx_blocked = false; - chan->tick_resume = NULL; + chan->stat.tx_blocked = false; + chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_NULL(chan->tick_resume); UT_CFDP_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); - txn->chan_ptr = NULL; - chan->tx_blocked = false; - chan->tick_resume = NULL; + txn->chan_ptr = NULL; + chan->stat.tx_blocked = false; + chan->tick_resume = NULL; UtAssert_VOIDCALL(CF_CFDP_CompleteTick(txn)); UtAssert_NULL(chan->tick_resume); } From 0121fc5ed7db98c109c28c9f3e5bd03b58eefada Mon Sep 17 00:00:00 2001 From: Justin Figueroa Date: Thu, 30 Jul 2026 05:47:30 -0400 Subject: [PATCH 09/18] Fix nasa/cFS#1063, Fix #408, Updates requirements --- docs/cf_FunctionalRequirements.csv | 245 +++++++++++++++-------------- fsw/src/cf_cmd.h | 2 +- 2 files changed, 128 insertions(+), 119 deletions(-) diff --git a/docs/cf_FunctionalRequirements.csv b/docs/cf_FunctionalRequirements.csv index 9c14b1d4..79c040c2 100644 --- a/docs/cf_FunctionalRequirements.csv +++ b/docs/cf_FunctionalRequirements.csv @@ -1,49 +1,48 @@ -Summary,Custom field (Requirement ID),Description,Custom field (Requirement Rationale) -CF1000,CF1000,"When CF receives a ""No-Op"" command, CF shall increment the ""CF Valid-Command Counter"" and issue a cFE event message.",CF application is a cFS compliant component that must implement the cFS architectural patterns. The No-Op command allows operational checks on the end-to-end CF command and telemetry paths. -CF1001,CF1001,"When a ""Reset-Counters"" command is received, CF shall set the command-specified ""housekeeping counters"" to a value of zero.",cFS architectural pattern for application operational interfaces. Allows for partial or full resetting of housekeeping counters. All reset operations should be observable. -CF1002,CF1002,"If a command's header-specified length is not equal to the expected command length, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Basic command verification in the event of SEU or memory corruption. " -CF1003,CF1003,"When CF receives a valid command, CF shall increment the ""CF Valid-Command Counter"" and issue a ""Command Received"" cFE event message. ",Support an operational interface to provide operator feedback. -CF1004,CF1004,"When CF receives a command, if the command is not valid, CF shall reject the command.","For robust and secure operations, invalid commands must be rejected and not executed." -CF1004.1,CF1004.1,"When CF receives a command, CF shall check that the command is valid before execution.","For robust and secure operations, commands and their parameters must be validated prior to execution" -CF1004.2,CF1004.2,"When CF rejects a command, CF shall issue a ""Command Rejected"" error event message and increment the ""CF Command Rejected"" Counter.","Provide operator feedback; operators need to be made aware of command rejection both in real-time through cFS event messages and through HouseKeeping telemetry through counters." -CF2000,CF2000,"When CF receives a CFDP receive-file protocol-directive PDU, CF shall process the file transfer request according to the directive-specified CFDP Mode, ""Unacknowledged"" Class-1 Service or ""Acknowledged"" Class-2 Service. ",Basic file transfer function that specifies the CFDP classes that shall be implemented. -CF2001,CF2001,CF shall extract uplinked CFDP PDUs from cFE-SB messages.,CF application is a cFS compliant component that must implement the cFS architectural patterns -CF2002,CF2002,CF shall extract file data from File-Data PDUs and reconstruct an identical copy of the extracted file from the meta-data-specified directory.,Basic CFDP function with fault handling defined in sub requirements -CF2002.1,CF2002.1,"If CF detects that a ""fault"" has occurred, CF shall close out the transaction and issue an ""Error"" cFE event message.","For robust and secure operations, errors in execution must be detected and handled with appropriate constraints on resource use and state machine iterations. ""Close out"" is intentionally vague since the action needs to be appropriate for the transmission class. As long as the transaction doesn't hang and become stale the requirement is met. Note ""cancel"" is overly specific, there's a cancel transaction command that is different than what is done here." -CF2002.1.2,CF2002.1.2,"CF shall detect the following scenarios and identify them as faults: +Summary,Requirement ID,Description,Requirement Rationale +CF: No-Op Command,CF1000,"When CF receives a ""No-Op"" command, CF shall increment the ""CF Valid-Command Counter"" and issue a cFE event message.",CF application is a cFS compliant component that must implement the cFS architectural patterns. The No-Op command allows operational checks on the end-to-end CF command and telemetry paths. +CF: Reset Counters Command,CF1001,"When a ""Reset-Counters"" command is received, CF shall set the command-specified ""housekeeping counters"" to a value of zero.",cFS architectural pattern for application operational interfaces. Allows for partial or full resetting of housekeeping counters. All reset operations should be observable. +CF: Command Length Verification,CF1002,"If a command's header-specified length is not equal to the expected command length, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Basic command verification in the event of SEU or memory corruption. " +CF: Valid Command Counter,CF1003,"When CF receives a valid command, CF shall increment the ""CF Valid-Command Counter"" and issue a ""Command Received"" cFE event message. ",Support an operational interface to provide operator feedback. +CF: Reject Invalid Command,CF1004,"When CF receives a command, if the command is not valid, CF shall reject the command.","For robust and secure operations, invalid commands must be rejected and not executed." +CF: Reject Invalid Command - Validation Before Execution,CF1004.1,"When CF receives a command, CF shall check that the command is valid before execution.","For robust and secure operations, commands and their parameters must be validated prior to execution" +CF: Reject Invalid Command - Event And Counter,CF1004.2,"When CF rejects a command, CF shall issue a ""Command Rejected"" error event message and increment the ""CF Command Rejected"" Counter.",Provide operator feedback; operators need to be made aware of command rejection both in real-time through cFS event messages and through HouseKeeping telemetry through counters. +CF: Process Received File Transfer,CF2000,"When CF receives a CFDP receive-file protocol-directive PDU, CF shall process the file transfer request according to the directive-specified CFDP Mode, ""Unacknowledged"" Class-1 Service or ""Acknowledged"" Class-2 Service. ",Basic file transfer function that specifies the CFDP classes that shall be implemented. +CF: Extract PDUs From Software Bus Messages,CF2001,CF shall extract uplinked CFDP PDUs from cFE-SB messages.,CF application is a cFS compliant component that must implement the cFS architectural patterns +CF: Reconstruct Received File,CF2002,CF shall extract file data from File-Data PDUs and reconstruct an identical copy of the extracted file from the meta-data-specified directory.,Basic CFDP function with fault handling defined in sub requirements +CF: Reconstruct Received File - Fault Handling,CF2002.1,"If CF detects that a ""fault"" has occurred, CF shall close out the transaction and issue an ""Error"" cFE event message.","For robust and secure operations, errors in execution must be detected and handled with appropriate constraints on resource use and state machine iterations. ""Close out"" is intentionally vague since the action needs to be appropriate for the transmission class. As long as the transaction doesn't hang and become stale the requirement is met. Note ""cancel"" is overly specific, there's a cancel transaction command that is different than what is done here." +CF: Reconstruct Received File - Fault Handling - Detected Fault Scenarios,CF2002.1.2,"CF shall detect the following scenarios and identify them as faults: 1. Positive Ack Limit Reached 2. Filestore Rejection 3. File-CRC Mismatch Failure 4. File-Size Error 5. NAK Limit Reached 6. Inactivity Limit Reached",Fault scenarios explicitly listed and tested for specification compliance. -CF2002.1.3,CF2002.1.3,"CF shall issue a DEBUG message if an attempt is made to reset a transaction that has already been freed" -CF3000,CF3000,"When CF receives a ""Transfer File"" command, CF shall play back the file indicated by the command-specified: filename, source path, destination path, keep/delete flag, service class, priority, channel, and peer-entity id. ","Also referred to as ""playback file"" command. Basic function of file transfer required to operate cFS flight systems. " -CF3000.1,CF3000.1,"When CF receives a ""Transfer File"" command, if the command-specified is open, CF reject the command.",Open files are in a uncertain state and may change during transfer potential containing erroneous data or cause other undefined behaviors -CF3000.2,CF3000.2, -CF3000.3,CF3000.3,"When CF receives a ""Transfer File"" command, if the command-specified file is not found, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed." -CF3000.4,CF3000.4,"When CF receives a ""Transfer File"" command, if the playback-pending queue is full, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed. Filterable is required to avoid multiple events when commands are sequenced." -CF3000.5,CF3000.5,"When CF receives a ""Transfer File"" command, if the command-specified playback-channel number is not valid, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution" -CF3000.6,CF3000.6,"When CF receives a ""Transfer File"" command, if the command-specified CFDP class is neither Class 1 nor Class 2, CF shall reject the command.",CF App only supports Class 1 and Class 2 CFDP requests -CF3001,CF3001,"When CF receives a ""Playback Directory"" command, CF shall play back all the files inside the command-specified directory as indicated by the command-specified service class, priority, destination path, keep/delete flag, channel, and peer-entity id.",Operational interface to support automation of file transfer. Interface excludes subdirectories to reduce complexity of implementation. Note the -CF3001.1,CF3001.1,"While CF is playing back multiple files, if the next file to be transferred is open, CF shall skip its transfer and issue an error event message. ",Open files are in a uncertain state and may change during transfer potential containing erroneous data. Note this requirement is different than CF3000.1 in that this is determined at time of playback not at command receipt. -CF3001.3,CF3001.3,"When CF receives a ""Playback Directory"" command, if the command-specified directory is not found, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed." -CF3001.5,CF3001.5,"When CF receives a ""Playback Directory"" command, if the playback-pending queue is full, CF shall reject the command.","For robust and secure operations, constraints on resource violations must be checked and reported." -CF3001.6,CF3001.6,"When CF receives a ""Playback Directory"" command, if the command-specified playback channel number is not valid, CF shall reject the command.",Support an operational interface to provide operator feedback when commands are malformed. -CF3001.7,CF3001.7,"When CF receives a ""Playback Directory"" command, if the command-specified class number is not valid, CF shall reject the command.",Basic requirement to check parameters for reliable and secure operations. -CF3005,CF3005,CF shall encapsulate and publish CFDP-PDUs as cFE-SB messages.,CF application is a cFS compliant component that must implement the cFS architectural patterns. Each channel's MID should be unique to that channel. The intent is to allow different communication interfaces to subscribe to a selected channel and manage it independently -CF3005.1,CF3005.1,Each CF channel shall have a unique cFE-SB Message ID.,"Playback channels may have different message routes to destination. In cFS, the Message ID provides that routing identifier. Unique cFE-SB Message IDs can avoid data corruption and memory problems. " -CF3005.1.1,CF3005.1.1,The CF-channel cFE-SB Message IDs shall be specified in a CF configuration table.,"Run-time configuration table supports ease of deployment, operation maintenance, fault management, and data path configuration." -CF3006,CF3006,The PDU output rate shall be controllable from outside the CF Application.,"As a data source in a real-time resourced constrained system, CF must not send more data than the receiver can reliably process or forward" -CF3007,CF3007,"While there are multiple transactions in the playback-pending queue for a given channel, CF shall wait for the ""EOF Sent"" marker on the file currently being played back before starting playback for the next file in the queue. ","Provides predictable file-in-order delivery. This does not imply that the ""EOF Sent"" has been acknowledged by the receiving peer entity. +CF: Reconstruct Received File - Fault Handling - Reset Of Freed Transaction,CF2002.1.3,CF shall issue a DEBUG message if an attempt is made to reset a transaction that has already been freed,Provides diagnostic visibility into invalid or duplicate transaction cleanup attempts +CF: Transfer File Command,CF3000,"When CF receives a ""Transfer File"" command, CF shall play back the file indicated by the command-specified: filename, source path, destination path, keep/delete flag, service class, priority, channel, and peer-entity id. ","Also referred to as ""playback file"" command. Basic function of file transfer required to operate cFS flight systems. " +CF: Transfer File Command - File Open,CF3000.1,"When CF receives a ""Transfer File"" command, if the command-specified is open, CF reject the command.",Open files are in a uncertain state and may change during transfer potential containing erroneous data or cause other undefined behaviors +CF: Transfer File Command - File Not Found,CF3000.3,"When CF receives a ""Transfer File"" command, if the command-specified file is not found, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed." +CF: Transfer File Command - Pending Queue Full,CF3000.4,"When CF receives a ""Transfer File"" command, if the playback-pending queue is full, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed. Filterable is required to avoid multiple events when commands are sequenced." +CF: Transfer File Command - Invalid Channel,CF3000.5,"When CF receives a ""Transfer File"" command, if the command-specified playback-channel number is not valid, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution" +CF: Transfer File Command - Invalid Service Class,CF3000.6,"When CF receives a ""Transfer File"" command, if the command-specified CFDP class is neither Class 1 nor Class 2, CF shall reject the command.",CF App only supports Class 1 and Class 2 CFDP requests +CF: Playback Directory Command,CF3001,"When CF receives a ""Playback Directory"" command, CF shall play back all the files inside the command-specified directory as indicated by the command-specified service class, priority, destination path, keep/delete flag, channel, and peer-entity id.",Operational interface to support automation of file transfer. Interface excludes subdirectories to reduce complexity of implementation. Note the +CF: Playback Directory Command - Skip Open File,CF3001.1,"While CF is playing back multiple files, if the next file to be transferred is open, CF shall skip its transfer and issue an error event message. ",Open files are in a uncertain state and may change during transfer potential containing erroneous data. Note this requirement is different than CF3000.1 in that this is determined at time of playback not at command receipt. +CF: Playback Directory Command - Directory Not Found,CF3001.3,"When CF receives a ""Playback Directory"" command, if the command-specified directory is not found, CF shall reject the command.","For robust and secure operations, command must be validated prior to execution. Provides operational interface as to why the command was not executed." +CF: Playback Directory Command - Pending Queue Full,CF3001.5,"When CF receives a ""Playback Directory"" command, if the playback-pending queue is full, CF shall reject the command.","For robust and secure operations, constraints on resource violations must be checked and reported." +CF: Playback Directory Command - Invalid Channel,CF3001.6,"When CF receives a ""Playback Directory"" command, if the command-specified playback channel number is not valid, CF shall reject the command.",Support an operational interface to provide operator feedback when commands are malformed. +CF: Playback Directory Command - Invalid Service Class,CF3001.7,"When CF receives a ""Playback Directory"" command, if the command-specified class number is not valid, CF shall reject the command.",Basic requirement to check parameters for reliable and secure operations. +CF: Publish PDUs To Software Bus,CF3005,CF shall encapsulate and publish CFDP-PDUs as cFE-SB messages.,CF application is a cFS compliant component that must implement the cFS architectural patterns. Each channel's MID should be unique to that channel. The intent is to allow different communication interfaces to subscribe to a selected channel and manage it independently +CF: Publish PDUs To Software Bus - Unique Message ID Per Channel,CF3005.1,Each CF channel shall have a unique cFE-SB Message ID.,"Playback channels may have different message routes to destination. In cFS, the Message ID provides that routing identifier. Unique cFE-SB Message IDs can avoid data corruption and memory problems. " +CF: Publish PDUs To Software Bus - Unique Message ID Per Channel - Configuration Table,CF3005.1.1,The CF-channel cFE-SB Message IDs shall be specified in a CF configuration table.,"Run-time configuration table supports ease of deployment, operation maintenance, fault management, and data path configuration." +CF: External PDU Output Rate Control,CF3006,The PDU output rate shall be controllable from outside the CF Application.,"As a data source in a real-time resourced constrained system, CF must not send more data than the receiver can reliably process or forward" +CF: Sequential Playback Within A Channel,CF3007,"While there are multiple transactions in the playback-pending queue for a given channel, CF shall wait for the ""EOF Sent"" marker on the file currently being played back before starting playback for the next file in the queue. ","Provides predictable file-in-order delivery. This does not imply that the ""EOF Sent"" has been acknowledged by the receiving peer entity. Although CCSDS 3.1.2 says ""The CFDP entity shall be implemented such that virtually any number of transactions may be concurrently in various stages of transmission or reception at a single CFDP entity."" this number must be constrained for performance." -CF3008,CF3008,"While there is no playback in progress, CF shall check the playback-pending channel queue for files at the configuration-table-defied frequency.",Supports automation of playback queuing -CF3009,CF3009,The CF channel playback-pending-queue depth shall be configurable.,Supports recovery of file transfer operations to a known configuration and state -CF3010,CF3010,The CF file-transfer history-queue depth shall be configurable.,Operational interface to support user knowledge of which files have been transferred and in what order. -CF4000,CF4000,The number of CF channels shall be defined by a CF configuration table.,Table-defined configurations support cFS architecture goals of scalability and reconfiguration of mission variability points -CF4000.1,CF4000.1,CF-channel parameters shall be defined by a CF configuration table.,Table-defined configurations support cFS architecture goals of scalability and reconfiguration of mission variability points -CF4000.1.1,CF4000.1.1,"The ""CF Configuration Table"" shall include the following parameters: +CF: Pending Queue Check Frequency,CF3008,"While there is no playback in progress, CF shall check the playback-pending channel queue for files at the configuration-table-defied frequency.",Supports automation of playback queuing +CF: Configurable Pending Queue Depth,CF3009,The CF channel playback-pending-queue depth shall be configurable.,Supports recovery of file transfer operations to a known configuration and state +CF: Configurable History Queue Depth,CF3010,The CF file-transfer history-queue depth shall be configurable.,Operational interface to support user knowledge of which files have been transferred and in what order. +CF: Configurable Number Of Channels,CF4000,The number of CF channels shall be defined by a CF configuration table.,Table-defined configurations support cFS architecture goals of scalability and reconfiguration of mission variability points +CF: Configurable Channel Parameters,CF4000.1,CF-channel parameters shall be defined by a CF configuration table.,Table-defined configurations support cFS architecture goals of scalability and reconfiguration of mission variability points +CF: Configurable Channel Parameters - Configuration Table Contents,CF4000.1.1,"The ""CF Configuration Table"" shall include the following parameters: -- Engine parameter(s) 1. Local entity ID -- Channel parameters (per-channel) @@ -63,93 +62,103 @@ CF4000.1.1,CF4000.1.1,"The ""CF Configuration Table"" shall include the followin 14. Source Path 15. Destination Path 16. Peer Entity Id","Engine, channel, and polling directory configuration parameters for operational flexibility." -CF4000.2,CF4000.2,Each CF channel shall have a dedicated and independent pending queue. ,"Playback channels should be independent to avoid one channels from stalling another channel. +CF: Dedicated Channel Pending Queue,CF4000.2,Each CF channel shall have a dedicated and independent pending queue. ,"Playback channels should be independent to avoid one channels from stalling another channel. The channel dictates the SB MsgId / Apid that the playback data PDUs will be generated with. Separate queues also helps when the one channel is throttled - e.g. if there are two channels and one is slow and one is faster, a playback requests to the slow channel may block the faster channel if they shared a single pending queue." -CF4000.3,CF4000.3 -CF4001,CF4001,"When CF receives an ""Enable Polling"" command, CF shall enable poll-directory processing.",Operational interface -CF4001.1,CF4001.1,CF Polling Directories shall be polled for files at the configuration-table-defined frequency.,Operational interface to support optimization of resource utilization and file transfer bandwidth -CF4001.2.1,CF4001.2.1,CF shall send all files in the polling directory at the configuration-table-specified priority level.,Operational interface for resource management -CF4001.3,CF4001.3,"When CF receives a ""Disable Polling"" command, CF shall disable poll-directory processing.",Operational Interface -CF5000,CF5000,"When CF receives a ""Freeze Channel"" command, CF shall disable the command-specified channel.","Operational interface that halts all transactions at their current state. (timers, suspend, etc.) Typically used for contact scheduling " -CF5000.1,CF5000.1,"When CF receives a ""Freeze Channel"" command, CF shall pause all in-progress transactions for the command-specified channel.",Ensure command is applied immediately -CF5000.2,CF5000.2,"While a channel is frozen, when a new transaction is received for that channel, CF shall not process that transaction.",A frozen channel cannot receive new transactions -CF5001,CF5001,"When CF receives a ""Thaw Channel"" command, CF shall re-enable the command-specified channel.",Operational Interface -CF5001.1,CF5001.1,"When CF receives a ""Thaw Channel"" command, CF shall resume processing all paused transactions for the command-specified channel.","Operational interface that resumes all transactions at their current state. (timers, suspend,…) Typical used for contact scheduling" -CF5002,CF5002,"The following parameters shall be configurable by a CF command: +CF: Enable Directory Polling Command,CF4001,"When CF receives an ""Enable Polling"" command, CF shall enable poll-directory processing.",Operational interface +CF: Polling Directory Scan Frequency,CF4001.1,CF Polling Directories shall be polled for files at the configuration-table-defined frequency.,Operational interface to support optimization of resource utilization and file transfer bandwidth +CF: Polling Directory Transmission Priority,CF4001.2.1,CF shall send all files in the polling directory at the configuration-table-specified priority level.,Operational interface for resource management +CF: Disable Directory Polling Command,CF4001.3,"When CF receives a ""Disable Polling"" command, CF shall disable poll-directory processing.",Operational Interface +CF: Freeze Channel Command,CF5000,"When CF receives a ""Freeze Channel"" command, CF shall disable the command-specified channel.","Operational interface that halts all transactions at their current state. (timers, suspend, etc.) Typically used for contact scheduling " +CF: Freeze Channel Command - Pause In-Progress Transactions,CF5000.1,"When CF receives a ""Freeze Channel"" command, CF shall pause all in-progress transactions for the command-specified channel.",Ensure command is applied immediately +CF: Freeze Channel Command - New Transaction While Frozen,CF5000.2,"While a channel is frozen, when a new transaction is received for that channel, CF shall not process that transaction.",A frozen channel cannot receive new transactions +CF: Thaw Channel Command,CF5001,"When CF receives a ""Thaw Channel"" command, CF shall re-enable the command-specified channel.",Operational Interface +CF: Thaw Channel Command - Resume Paused Transactions,CF5001.1,"When CF receives a ""Thaw Channel"" command, CF shall resume processing all paused transactions for the command-specified channel.","Operational interface that resumes all transactions at their current state. (timers, suspend,…) Typical used for contact scheduling" +CF: Commandable Protocol Parameters,CF5002,"The following parameters shall be configurable by a CF command: 1. CFDP channel Ack-Timer Value (seconds) 2. CFDP channel NAK-Timer Value (seconds) 3. CFDP channel Inactivity-Timeout Value (seconds) 4. CFDP channel Maximum Ack Timeouts (integer counts) 5. CFDP channel Maximum NAK Timeouts (integer counts)","Operational interface to support mission variability and reconfiguration " -CF5002.1,CF5002.1,"The default values for the CFDP channel protocol parameters below shall be defined by a CF Configuration Table: +CF: Commandable Protocol Parameters - Configuration Table Defaults,CF5002.1,"The default values for the CFDP channel protocol parameters below shall be defined by a CF Configuration Table: 1. CFDP channel Ack-Timer Value (seconds) 2. CFDP channel NAK-Timer Value (seconds) 3. CFDP channel Inactivity-Timeout Value (seconds) 4. CFDP channel Maximum Ack Timeouts (integer counts) 5. CFDP channel Maximum NAK Timeouts (integer counts)",Ensure CF starts in a known and valid operational state -CF5002.2,CF5002.2,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, CF shall set the command-specified parameter to the command-specified value and issue a cFE event message that confirms the change. ",Operational Interface -CF5002.3,CF5002.3,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, if the command-specified parameter is invalid, CF shall reject the command. ",Command validity check for robust operation -CF5002.4,CF5002.4,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, if the command-specified parameter *value* is invalid, CF shall reject the command.",Command validity check for robust operation -CF5003,CF5003,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, CF shall issue an event message containing the current value of the command-specified configuration-table parameter.",Operational interface -CF5003.1,CF5003.1,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, if the command-specified parameter is invalid, CF shall reject the command. ",Operational robustness -CF5004,CF5004,"When CF receives a ""Get Full CFDP Channel-Protocol Configuration"" command, CF shall publish all CFDP Channel Protocol Configuration parameters to a cFS-SB message. ",Compatibility with cFE App behavior. Message can be downlinked as Housekeeping Data or sent to another app for consumption -CF5005,CF5005,"When CF receives a ""Cancel Transaction"" command, CF shall cancel the transaction indicated by the command-specified Entity ID and transaction-sequence number.",Support an operational interface to control transactions. Transaction-Id provides a mechanism to scale to large systems and avoid performance issues with string searches -CF5005.1,CF5005.1,"When CF receives a ""Cancel Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. -CF5006,CF5006,"When CF receives an ""Abandon Transaction"" command, CF shall abandon the command-specified transaction.",Support an operational interface to provide operator feedback. -CF5006.1,CF5006.1,"When CF receives an ""Abandon Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. -CF5007,CF5007,"When CF receives an ""Abandon All Transactions"" command, CF shall abandon all transactions.",Operational interface that removes transaction state for all active transaction. -CF5007.1,CF5007.1,"When CF receives an ""Abandon All Transactions"" command, if there are no transactions in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. -CF5008,CF5008, -CF5008.1,CF5008.1, -CF5009,CF5009,"When CF receives a ""Write Active Transactions"" command, CF shall write all active transactions to a file. ",Operational interface supporting operator insight into transfer sequence and state -CF5012,CF5012,The CF maximum-uplink PDU size shall be defined and configured at compile time.,Support constraints for security checks and resource utilization. -CF5013,CF5013,The CF maximum number of simultaneous per-channel transactions shall be defined and configured at compile time. ,Channel concept extended to allow independent operations when other channels may be blocked due to maximum transactions -CF5014,CF5014,The CF maximum per-channel downlink-PDU size shall be defined and configured at compile time.,Support constraints for security checks and resource utilization. Allows the PDU size to be optimized for the channel communications stack (MTU for transport and data link) -CF5015,CF5015,"When CF receives a ""Cancel All Transactions"" command, CF shall cancel all in-progress transactions.","Support an operational interface to control transactions. ""All"" provides an interface to cancel transactions without having knowledge of each individual transaction number. Especially useful when there may be hundreds or thousands of transactions in progress." -CF5015.1,CF5015.1,"When CF receives ""Cancel *All* Transactions"" command, if there are no transactions in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. -CF5016,CF5016,"When CF receives a ""Suspend Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. -CF5016.1,CF5016.1,"When CF receives a ""Suspend Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. -CF5017,CF5017,"When CF receives a ""Suspend All Transactions"" command, CF shall suspend all in-progress transactions.",Operational interface to align file transfer with communications contact schedule. -CF5017.1,CF5017.1,"When CF receives a ""Suspend All Transactions"" command, if no transactions are in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. -CF5018,CF5018,"When CF receives a ""Resume Transaction"" command, CF shall resume the command-specified suspended transaction",Operational interface to resume normal operations without knowing which files are suspended -CF5018.1,CF5018.1,"When CF receives a ""Resume Transaction"" command, if the command-specified transaction is not suspended, CF shall reject the command. ",Operational interface -CF5019,CF5019,"When CF receives a ""Resume *All* Transactions"", CF shall resume all suspended transactions",Operational interface to resume normal operations without knowing which files are suspended -CF5019.1,CF5019.1,"When CF receives a ""Resume ALL Transactions"", if there are no suspended transactions, CF shall reject the command. ",Ensure robust operations and provide operator feedback. -CF5020,CF5020,"When CF receives a ""Purge Queue"" command, CF shall purge the command-specified queue for the command-specified output channel. ",Support an operational interface to provide operator feedback. -CF5020.1,CF5020.1,"When CF receives a ""Purge Queue"" command, if the command-specified queue is not defined, CF shall reject the command.",Ensure robust operations and provide operator feedback. -CF5020.2,CF5020.2,"When CF receives a ""Purge Queue"" command, if the command-specified channel is not defined, CF shall reject the command. ",Ensure robust operations and provide operator feedback. -CF5021,CF5021,"When CF receives a ""Write Queue"" command, CF shall write the command-specified queue's contents to the command-specified file.",Operational interface to allow insight into file transfer order. -CF5021.1,CF5021.1,"When CF receives a ""Write Queue"" command, if the command-specified queue is not defined, CF shall reject the command. ",Ensure robust operations and provide operator feedback. -CF5022,CF5022,"When CF receives a ""De-Queue File"" command, CF shall remove the command-specified file from its current queue.",Support an operational interface to provide operator feedback. -CF5022.1,CF5022.1,"When CF receives a ""De-Queue File"" command, if the command-specified file is not found, CF shall reject the command. ",Ensure robust operations and provide operator feedback. -CF5023,CF5023,"The maximum number of transmissions, that is, the sum of simultaneous transmit and receive transactions, shall be defined at compile time.",Supports scaling resource use for mission variability -CF5024,CF5024,"When CF receives a file-transfer request, if the requested file's size is larger than 2^32 bytes, CF shall reject the request and issue an error event message.",Constrain resources use and exclude implementation complexity of CCSDS Large-file-size header extensions. CFDP-1S-01 -CF5025,CF5025,"When CF receives a PDU, if the size of the Entity ID fields are too large for the configured internal storage, CF shall reject the PDU and issue an error event message.",Prevent silent truncation of variable length Entity ID fields in PDU by checking the configured storage size and rejecting PDUs that with an Entity ID field that would be truncated. -CF5026,CF5026,"When CF receives a PDU, if the size of the Transaction Sequence Number field is too large for the configured internal storage, CF shall reject the PDU and issue an error event message.",Prevent silent truncation of variable length Transaction Sequence Number field in PDU by checking configured storage size and rejecting PDUs that with a Transaction Sequence Number field that would be truncated. -CF5030,CF5030,Each CF output channel shall have 256 file-transfer priority levels.,Priority levels are used to control the order of file transfer PDUs within a channel. Priority levels allow the control of PDU interleaving in a output channel and prevent a lower-priority transfer from blocking a high-priority operational transfer. 256 priority levels provide a high-level of granularity in the compact space of 1 byte. -CF5030.1,CF5030.1,The CF file transmission priority level for each polling directory shall be configurable.,Supports management of priorities for each polling directory. Commanded transfers (single file or playback directory) use the priority level contained in the command. -CF5030.2,CF5030.2,The highest file-transfer priority level shall be zero.,Standardized interface. If the number of levels increases or decreases the highest priority will always be the same -CF5031,CF5031,CF shall send NAK re-transmissions in the order received at the same priority as the NAK-targeted file,PDU re-transmission priority should be the same as the original request. To not do so would allow a form of priority inversion where a large number of NAKs on a lower priority transfer would suppress re-transmission of higher priority transfers. -CF5040,CF5040,"CF shall support CFDP file transfers in ""Unacknowledged""(Class-1) Service Mode.","Basic file transfer function. Unacknowledged Mode, also called unreliable mode, is used for non-critical data or operations without bi-directional data paths." -CF5041,CF5041,"CF shall support CFDP file transfer in ""Acknowledged"" (Class-2) Service, Mode.","Basic file transfer function. Acknowledged Mode, also called reliable mode, is used for critical data and/or operations with bi-directional data paths." -CF6000,CF6000,"The CF Housekeeping message shall include +CF: Set Protocol Configuration Command,CF5002.2,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, CF shall set the command-specified parameter to the command-specified value and issue a cFE event message that confirms the change. ",Operational Interface +CF: Set Protocol Configuration Command - Invalid Parameter,CF5002.3,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, if the command-specified parameter is invalid, CF shall reject the command. ",Command validity check for robust operation +CF: Set Protocol Configuration Command - Invalid Parameter Value,CF5002.4,"When CF receives a ""Set CFDP Channel Protocol Configuration"" command, if the command-specified parameter *value* is invalid, CF shall reject the command.",Command validity check for robust operation +CF: Get Protocol Configuration Command,CF5003,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, CF shall issue an event message containing the current value of the command-specified configuration-table parameter.",Operational interface +CF: Get Protocol Configuration Command - Invalid Parameter,CF5003.1,"When CF receives a ""Get CFDP Channel-Protocol Configuration Parameter"" command, if the command-specified parameter is invalid, CF shall reject the command. ",Operational robustness +CF: Cancel Transaction Command,CF5005,"When CF receives a ""Cancel Transaction"" command, CF shall cancel the transaction indicated by the command-specified Entity ID and transaction-sequence number.",Support an operational interface to control transactions. Transaction-Id provides a mechanism to scale to large systems and avoid performance issues with string searches +CF: Cancel Transaction Command - Transaction Not In Progress,CF5005.1,"When CF receives a ""Cancel Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. +CF: Abandon Transaction Command,CF5006,"When CF receives an ""Abandon Transaction"" command, CF shall abandon the command-specified transaction.",Support an operational interface to provide operator feedback. +CF: Abandon Transaction Command - Transaction Not In Progress,CF5006.1,"When CF receives an ""Abandon Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. +CF: Abandon All Transactions Command,CF5007,"When CF receives an ""Abandon All Transactions"" command, CF shall abandon all transactions.",Operational interface that removes transaction state for all active transaction. +CF: Abandon All Transactions Command - No Transactions In Progress,CF5007.1,"When CF receives an ""Abandon All Transactions"" command, if there are no transactions in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. +CF: Write Active Transactions Command,CF5009,"When CF receives a ""Write Active Transactions"" command, CF shall write all active transactions to a file. ",Operational interface supporting operator insight into transfer sequence and state +CF: Enable Dequeue Command,CF5010,"When CF receives an ""Enable Dequeue"" command, CF shall enable the dequeueing of pending transactions for the command-specified channel.",Operational interface that allows queued file transfers to begin on a channel. Separate from channel freeze so that transfer requests can continue to be queued while transmission is withheld. +CF: Enable Dequeue Command - Invalid Channel,CF5010.1,"When CF receives an ""Enable Dequeue"" command, if the command-specified channel is not valid, CF shall reject the command.",Ensure robust operations and provide operator feedback. +CF: Disable Dequeue Command,CF5011,"When CF receives a ""Disable Dequeue"" command, CF shall disable the dequeueing of pending transactions for the command-specified channel.",Operational interface that withholds pending file transfers from becoming active while allowing in-progress transactions to complete. Typically used to quiesce a channel before reconfiguration. +CF: Disable Dequeue Command - Invalid Channel,CF5011.1,"When CF receives a ""Disable Dequeue"" command, if the command-specified channel is not valid, CF shall reject the command.",Ensure robust operations and provide operator feedback. +CF: Maximum Simultaneous Transactions Per Channel,CF5013,The CF maximum number of simultaneous per-channel transactions shall be defined and configured at compile time. ,Channel concept extended to allow independent operations when other channels may be blocked due to maximum transactions +CF: Maximum Downlink PDU Size Per Channel,CF5014,The CF maximum per-channel downlink-PDU size shall be defined and configured at compile time.,Support constraints for security checks and resource utilization. Allows the PDU size to be optimized for the channel communications stack (MTU for transport and data link) +CF: Cancel All Transactions Command,CF5015,"When CF receives a ""Cancel All Transactions"" command, CF shall cancel all in-progress transactions.","Support an operational interface to control transactions. ""All"" provides an interface to cancel transactions without having knowledge of each individual transaction number. Especially useful when there may be hundreds or thousands of transactions in progress." +CF: Cancel All Transactions Command - No Transactions In Progress,CF5015.1,"When CF receives ""Cancel *All* Transactions"" command, if there are no transactions in progress, CF shall reject the command.",Support an operational interface to provide operator feedback. +CF: Suspend Transaction Command,CF5016,"When CF receives a ""Suspend Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. +CF: Suspend Transaction Command - Transaction Not In Progress,CF5016.1,"When CF receives a ""Suspend Transaction"" command, if the command-specified transaction is not in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. +CF: Suspend All Transactions Command,CF5017,"When CF receives a ""Suspend All Transactions"" command, CF shall suspend all in-progress transactions.",Operational interface to align file transfer with communications contact schedule. +CF: Suspend All Transactions Command - No Transactions In Progress,CF5017.1,"When CF receives a ""Suspend All Transactions"" command, if no transactions are in progress, CF shall reject the command. ",Support an operational interface to provide operator feedback. +CF: Resume Transaction Command,CF5018,"When CF receives a ""Resume Transaction"" command, CF shall resume the command-specified suspended transaction",Operational interface to resume normal operations without knowing which files are suspended +CF: Resume Transaction Command - Transaction Not Suspended,CF5018.1,"When CF receives a ""Resume Transaction"" command, if the command-specified transaction is not suspended, CF shall reject the command. ",Operational interface +CF: Resume All Transactions Command,CF5019,"When CF receives a ""Resume *All* Transactions"", CF shall resume all suspended transactions",Operational interface to resume normal operations without knowing which files are suspended +CF: Resume All Transactions Command - No Suspended Transactions,CF5019.1,"When CF receives a ""Resume ALL Transactions"", if there are no suspended transactions, CF shall reject the command. ",Ensure robust operations and provide operator feedback. +CF: Purge Queue Command,CF5020,"When CF receives a ""Purge Queue"" command, CF shall purge the command-specified queue for the command-specified output channel. ",Support an operational interface to provide operator feedback. +CF: Purge Queue Command - Undefined Queue,CF5020.1,"When CF receives a ""Purge Queue"" command, if the command-specified queue is not defined, CF shall reject the command.",Ensure robust operations and provide operator feedback. +CF: Purge Queue Command - Undefined Channel,CF5020.2,"When CF receives a ""Purge Queue"" command, if the command-specified channel is not defined, CF shall reject the command. ",Ensure robust operations and provide operator feedback. +CF: Write Queue Command,CF5021,"When CF receives a ""Write Queue"" command, CF shall write the command-specified queue's contents to the command-specified file.",Operational interface to allow insight into file transfer order. +CF: Write Queue Command - Undefined Queue,CF5021.1,"When CF receives a ""Write Queue"" command, if the command-specified queue is not defined, CF shall reject the command. ",Ensure robust operations and provide operator feedback. +CF: Maximum Simultaneous Transactions,CF5023,"The maximum number of transmissions, that is, the sum of simultaneous transmit and receive transactions, shall be defined at compile time.",Supports scaling resource use for mission variability +CF: Maximum Transferable File Size,CF5024,"When CF receives a file-transfer request, if the requested file's size is larger than 2^32 bytes, CF shall reject the request and issue an error event message.",Constrain resources use and exclude implementation complexity of CCSDS Large-file-size header extensions. CFDP-1S-01 +CF: Entity ID Field Size Limit,CF5025,"When CF receives a PDU, if the size of the Entity ID fields are too large for the configured internal storage, CF shall reject the PDU and issue an error event message.",Prevent silent truncation of variable length Entity ID fields in PDU by checking the configured storage size and rejecting PDUs that with an Entity ID field that would be truncated. +CF: Transaction Sequence Number Field Size Limit,CF5026,"When CF receives a PDU, if the size of the Transaction Sequence Number field is too large for the configured internal storage, CF shall reject the PDU and issue an error event message.",Prevent silent truncation of variable length Transaction Sequence Number field in PDU by checking configured storage size and rejecting PDUs that with a Transaction Sequence Number field that would be truncated. +CF: File Transfer Priority Levels,CF5030,Each CF output channel shall have 256 file-transfer priority levels.,Priority levels are used to control the order of file transfer PDUs within a channel. Priority levels allow the control of PDU interleaving in a output channel and prevent a lower-priority transfer from blocking a high-priority operational transfer. 256 priority levels provide a high-level of granularity in the compact space of 1 byte. +CF: File Transfer Priority Levels - Configurable Polling Directory Priority,CF5030.1,The CF file transmission priority level for each polling directory shall be configurable.,Supports management of priorities for each polling directory. Commanded transfers (single file or playback directory) use the priority level contained in the command. +CF: File Transfer Priority Levels - Highest Priority Value,CF5030.2,The highest file-transfer priority level shall be zero.,Standardized interface. If the number of levels increases or decreases the highest priority will always be the same +CF: NAK Retransmission Ordering,CF5031,CF shall send NAK re-transmissions in the order received at the same priority as the NAK-targeted file,PDU re-transmission priority should be the same as the original request. To not do so would allow a form of priority inversion where a large number of NAKs on a lower priority transfer would suppress re-transmission of higher priority transfers. +CF: Class 1 Unacknowledged Service,CF5040,"CF shall support CFDP file transfers in ""Unacknowledged""(Class-1) Service Mode.","Basic file transfer function. Unacknowledged Mode, also called unreliable mode, is used for non-critical data or operations without bi-directional data paths." +CF: Class 2 Acknowledged Service,CF5041,"CF shall support CFDP file transfer in ""Acknowledged"" (Class-2) Service, Mode.","Basic file transfer function. Acknowledged Mode, also called reliable mode, is used for critical data and/or operations with bi-directional data paths." +CF: Housekeeping Message,CF6000,"The CF Housekeeping message shall include 1. Command Counter 2. Command Error Counter -- Per-Channel HouseKeeping Entries -4. Number of transactions on the various queues -5. Frozen Status -6. Number of Valid PDUs Received -7. Number of Receive-Transaction Errors -8. Number of Sent PDUs -9. Number of Acknowledge Retry Limit Exceeded Faults -10. Number of Non-Acknowledge Retry Limit Exceeded Faults -11. Number of Inactivity Timer-Limit Faults -12. Number of CRC Mismatch Faults -13. Number of Filestore Rejection Faults (can be split by type) -14. Number of Filesize Mismatch Faults",Operator interface that provides detailed status on operational state -CF6001,CF6001,"The CF End of Transaction message shall include +3. Number of transactions on the various queues +4. Number of active polling directories +5. Number of active playback directories +6. Frozen Status +7. Number of Sent File Data Bytes +8. Number of Sent PDUs +9. Number of Sent NAK Segment Requests +10. Number of Received File Data Bytes +11. Number of Received PDUs with Valid Headers +12. Number of Received PDUs with Errors +13. Number of Spurious Received PDUs +14. Number of Dropped Received PDUs +15. Number of Received NAK Segment Requests +16. Number of File Open Faults +17. Number of File Read Faults +18. Number of File Seek Faults +19. Number of File Write Faults +20. Number of File Rename Faults +21. Number of Directory Read Faults +22. Number of CRC Mismatch Faults +23. Number of File Size Mismatch Faults +24. Number of NAK Limit Exceeded Faults +25. Number of ACK Limit Exceeded Faults +26. Number of Inactivity Timer Limit Exceeded Faults",Operator interface that provides detailed status on operational state +CF: End Of Transaction Message,CF6001,"The CF End of Transaction message shall include 1. Transaction identifier 2. Channel number 3. Direction of transaction @@ -160,12 +169,12 @@ CF6001,CF6001,"The CF End of Transaction message shall include 8. Peer EID of transaction 9. File size 10. CRC state",Operator interface that provides detailed information on transaction -CF6001.1,CF6001.1,"When a transaction terminates, CF shall generate an End of Transaction information packet",Operational awareness of transaction closure and potential automation of follow-on actions -CF6001.2,CF6001.2,"If a transaction has reached the FIN or EOF state, the CF End of Transaction message Condition Code shall be set to the CFDP condition code for that transaction.", -CF6001.3,CF6001.3,"If the transaction has not reached the FIN or EOF state, the CF End of Transaction message Condition Code shall indicate why the transaction stopped early.", -CF7000,CF7000,"When CF is initialized, CF shall initialize the the housekeeping counters/numbers to zero and the frozen status as ""thawed"".",All variable must be set to a known valid state on initialization to support reliable functioning -CF7001,CF7001,"When CF is initialized, CF shall load valid CF Configuration Tables.",All variables must be set to a known valid state on initialization to support reliable functioning. Table interface supports operational reconfiguration of CF functions. -CF7001.1,CF7001.1,"If a CF Configuration Table fails validation, CF shall issue an error cFE event message and exit.",Support constraints for security checks and resource utilization. Without a valid configuration CF can not initialize to a functional state. -CF7001.1.1,CF7001.1.1,CF shall validate CF configuration table parameters.,Support constraints for security checks and resource utilization. Without a valid configuration CF can not initialize to a functional state. Specific content validation is implementation defined. -CF8000,CF8000,"When CF receives an ""Initialize Engine"" command, CF shall enable the CFDP engine and re-load its configuration.",Supports operator interface to disable operations due to misconfiguration and other faults -CF8001,CF8001,"When CF receives a ""Disable Engine"" command, CF shall disable the CFDP engine and reset its state.",Supports operator interface to disable operations due to misconfiguration and other faults +CF: End Of Transaction Message - Generation,CF6001.1,"When a transaction terminates, CF shall generate an End of Transaction information packet",Operational awareness of transaction closure and potential automation of follow-on actions +CF: End Of Transaction Message - Condition Code On Normal Completion,CF6001.2,"If a transaction has reached the FIN or EOF state, the CF End of Transaction message Condition Code shall be set to the CFDP condition code for that transaction.",Preserves the CFDP transaction result in telemetry for operator assessment and automated processing +CF: End Of Transaction Message - Condition Code On Early Termination,CF6001.3,"If the transaction has not reached the FIN or EOF state, the CF End of Transaction message Condition Code shall indicate why the transaction stopped early.",Provides the cause of premature transaction termination in telemetry to support fault diagnosis and recovery +CF: Initialize Housekeeping Data,CF7000,"When CF is initialized, CF shall initialize the the housekeeping counters/numbers to zero and the frozen status as ""thawed"".",All variable must be set to a known valid state on initialization to support reliable functioning +CF: Load Configuration Tables,CF7001,"When CF is initialized, CF shall load valid CF Configuration Tables.",All variables must be set to a known valid state on initialization to support reliable functioning. Table interface supports operational reconfiguration of CF functions. +CF: Load Configuration Tables - Validation Failure,CF7001.1,"If a CF Configuration Table fails validation, CF shall issue an error cFE event message and exit.",Support constraints for security checks and resource utilization. Without a valid configuration CF can not initialize to a functional state. +CF: Load Configuration Tables - Parameter Validation,CF7001.1.1,CF shall validate CF configuration table parameters.,Support constraints for security checks and resource utilization. Without a valid configuration CF can not initialize to a functional state. Specific content validation is implementation defined. +CF: Enable Engine Command,CF8000,"When CF receives an ""Initialize Engine"" command, CF shall enable the CFDP engine and re-load its configuration.",Supports operator interface to disable operations due to misconfiguration and other faults +CF: Disable Engine Command,CF8001,"When CF receives a ""Disable Engine"" command, CF shall disable the CFDP engine and reset its state.",Supports operator interface to disable operations due to misconfiguration and other faults diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 8be5fe18..a3632576 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -575,7 +575,7 @@ void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg); /************************************************************************/ -/** @brief Ground command to set a configuration parameter. +/** @brief Ground command to get a configuration parameter. * * @par Assumptions, External Events, and Notes: * msg must not be NULL. From a6ae55cc37a3027a1d5ae2cdec92a1c90e3fa6ed Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 3 Aug 2026 19:31:38 +0000 Subject: [PATCH 10/18] Part nasa/cFS#1079, adding further guidance to the pull request templates. --- .../comment_documentation_change.md | 1 + .github/PULL_REQUEST_TEMPLATE/fsw_code_change.md | 3 ++- .github/PULL_REQUEST_TEMPLATE/workflows_change.md | 2 ++ .github/pull_request_template.md | 13 +++++++------ 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md b/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md index 4c5537cc..de1252a5 100644 --- a/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md +++ b/.github/PULL_REQUEST_TEMPLATE/comment_documentation_change.md @@ -16,6 +16,7 @@ Closes # ## Areas of Expertise Touched + - [ ] ASTRO - [ ] CI/CD - [ ] COSMOS diff --git a/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md b/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md index 4701113d..7ea66ac2 100644 --- a/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md +++ b/.github/PULL_REQUEST_TEMPLATE/fsw_code_change.md @@ -31,6 +31,8 @@ Closes # ## Areas of Expertise Touched + + - [ ] ASTRO - [ ] CI/CD - [ ] COSMOS @@ -68,7 +70,6 @@ Closes # - [ ] Code is readable, maintainable, and follows project conventions - [ ] `.clang-format` has been applied - [ ] Static analysis results reviewed and acceptable -- [ ] Unit tests are meaningful and adequately cover the changes - [ ] **The change has been exercised by the unit tests** (not just that tests pass — the new/changed code paths are actually covered) - [ ] **COSMOS test suite was executed against this change** and results reviewed (or confirmed N/A with justification) - [ ] **Reviewer has independently verified the change behaves as described** (e.g., by running the tests locally, reviewing CI output in detail, or performing additional ad-hoc testing as warranted) diff --git a/.github/PULL_REQUEST_TEMPLATE/workflows_change.md b/.github/PULL_REQUEST_TEMPLATE/workflows_change.md index 8fe91cb4..700e3983 100644 --- a/.github/PULL_REQUEST_TEMPLATE/workflows_change.md +++ b/.github/PULL_REQUEST_TEMPLATE/workflows_change.md @@ -14,6 +14,8 @@ Closes # ## Areas of Expertise Touched + + - [ ] ASTRO - [ ] CI/CD - [ ] COSMOS diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index fd963177..cfae1f8c 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,3 +1,9 @@ +**For members of the cFS Team** +Click the `Preview` tab and select the pull request template corresponding to the type of change you are submitting: +- [Comment/Documentation Change](?expand=1&template=comment_documentation_change.md) +- [Flight Software Code Change](?expand=1&template=fsw_code_change.md) +- [Workflows Change](?expand=1&template=workflows_change.md) + **Checklist (Please check before submitting)** * [ ] I reviewed the [Contributing Guide](https://github.com/nasa/CF/blob/main/CONTRIBUTING.md). @@ -32,9 +38,4 @@ If included, identify any third party code and provide text file of license **Contributor Info - All information REQUIRED for consideration of pull request** Full name and company/organization/center of all contributors ("Personal" if individual work) - Note CLA's apply to software contributions. - -**For members of the cFS Team** -Click the `Preview` tab and select the pull request template corresponding to the type of change you are submitting: -- [Comment/Documentation Change](?expand=1&template=comment_documentation_change.md) -- [Flight Software Code Change](?expand=1&template=fsw_code_change.md) -- [Workflows Change](?expand=1&template=workflows_change.md) + \ No newline at end of file From 525091534f5bafd308990e6ab8466f96505d9fee Mon Sep 17 00:00:00 2001 From: Justin Figueroa <55672943+chillfig@users.noreply.github.com> Date: Tue, 1 Sep 2026 14:09:03 -0400 Subject: [PATCH 11/18] Fix #508, Adds complete transaction housekeeping counters (#511) --- config/default_cf_msgdefs.h | 4 + cosmos/big_endian/CF/cf_cmd.txt | 223 ----------------------------- cosmos/big_endian/CF/cf_tlm.txt | 90 ------------ cosmos/little_endian/CF/cf_cmd.txt | 223 ----------------------------- cosmos/little_endian/CF/cf_tlm.txt | 90 ------------ docs/cf_FunctionalRequirements.csv | 6 +- eds/cf.xml | 4 + fsw/src/cf_cfdp.c | 9 ++ fsw/src/cf_cfdp_r.c | 6 + fsw/src/cf_cfdp_s.c | 6 + unit-test/cf_cfdp_r_tests.c | 11 +- unit-test/cf_cfdp_s_tests.c | 17 ++- unit-test/cf_cfdp_tests.c | 10 ++ unit-test/cf_cmd_tests.c | 24 +++- 14 files changed, 87 insertions(+), 636 deletions(-) delete mode 100644 cosmos/big_endian/CF/cf_cmd.txt delete mode 100644 cosmos/big_endian/CF/cf_tlm.txt delete mode 100644 cosmos/little_endian/CF/cf_cmd.txt delete mode 100644 cosmos/little_endian/CF/cf_tlm.txt diff --git a/config/default_cf_msgdefs.h b/config/default_cf_msgdefs.h index fcd5be2c..91391f73 100644 --- a/config/default_cf_msgdefs.h +++ b/config/default_cf_msgdefs.h @@ -110,6 +110,8 @@ typedef struct CF_HkSent uint64 file_data_bytes; /**< \brief Sent File data bytes */ uint32 pdu; /**< \brief Sent PDUs counter */ uint32 nak_segment_requests; /**< \brief Sent NAK segment requests counter */ + uint32 files_sent; /**< \brief Files successfully sent counter */ + uint32 files_started; /**< \brief Files initialized to be sent counter */ } CF_HkSent_t; /** @@ -126,6 +128,8 @@ typedef struct CF_HkRecv */ uint16 dropped; /**< \brief Received PDUs dropped due to a transaction error */ uint32 nak_segment_requests; /**< \brief Received NAK segment requests counter */ + uint32 files_recv; /**< \brief Files successfully received counter */ + uint32 files_started; /**< \brief Files initialized to be received counter */ } CF_HkRecv_t; /** diff --git a/cosmos/big_endian/CF/cf_cmd.txt b/cosmos/big_endian/CF/cf_cmd.txt deleted file mode 100644 index 56e898bb..00000000 --- a/cosmos/big_endian/CF/cf_cmd.txt +++ /dev/null @@ -1,223 +0,0 @@ -COMMAND CF NOOP BIG_ENDIAN "Generate an info event message with app version" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 0 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF RESET_CTRS BIG_ENDIAN "Resets HK TLM parent and child task counters" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 1 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER VALUE 8 UINT 0 4 0 "0=all, 1=cmd, 2=fault 3=up 4=down" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF TX_FILE BIG_ENDIAN "Send file from Spacecraft to Ground" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 135 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 2 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CLASS 8 UINT 0 1 0 "0=CFDP class 1, 1=CFDP class 2" - APPEND_PARAMETER KEEP 8 UINT 0 1 1 "0=delete file after transfer, 1=keep file" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER PRIO 8 UINT 0 255 0 "Priority (0 is highest)" - APPEND_PARAMETER DEST_ID 16 UINT MIN_UINT16 MAX_UINT16 26 "CFDP destination entity ID" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.bin" "Spacecraft /path/filename" - APPEND_PARAMETER DEST_FILENAME 512 STRING "/home/vagrant/temp.bin" "Complete host /path/filename" - -COMMAND CF PLAYBACK_DIR BIG_ENDIAN "Playback a directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 135 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 3 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CLASS 8 UINT 0 1 0 "0=CFDP class 1, 1=CFDP class 2" - APPEND_PARAMETER KEEP 8 UINT 0 1 1 "0=delete file after transfer, 1=keep file" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER PRIO 8 UINT 0 255 0 "Priority (0 is highest)" - APPEND_PARAMETER DEST_ID 16 UINT MIN_UINT16 MAX_UINT16 26 "CFDP destination entity ID" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.bin" "Spacecraft /path/filename of directory" - APPEND_PARAMETER DEST_FILENAME 512 STRING "/home/vagrant/temp.bin" "directory prefix for files on host" - - -COMMAND CF WRITE_QUEUE BIG_ENDIAN "Write a queue to file" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 69 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 15 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TYPE 8 UINT 0 2 0 "0=all, 1=up, 2=down" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER QUEUE 8 UINT 0 3 0 "0=pending, 1=active, 2=history, 3=all" - APPEND_PARAMETER SPARE 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.txt" "Spacecraft /path/filename of directory" - - -COMMAND CF FREEZE_CHAN BIG_ENDIAN "Freeze a channel (unable to send messages, and timers stop)" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 4 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF THAW_CHAN BIG_ENDIAN "Thaw a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 5 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF SUSPEND_TRANSACTION BIG_ENDIAN "Suspend a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 6 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to suspend all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF RESUME_TRANSACTION BIG_ENDIAN "Resume a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 7 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to resume all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF CANCEL_TRANSACTION BIG_ENDIAN "Cancel a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 8 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to cancel all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF ABANDON_TRANSACTION BIG_ENDIAN "Abandon a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 9 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to abandon all. 254 means use TSN. 255 means all transactions" - -COMMAND CF ENABLE_DEQUEUE BIG_ENDIAN "Enable dequeue (tx file) for a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 16 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF DISABLE_DEQUEUE BIG_ENDIAN "Disable dequeue (tx file) for a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 17 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF ENABLE_POLLDIR BIG_ENDIAN "Enable polling directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 18 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER POLLDIR 8 UINT MIN_UINT8 MAX_UINT8 0 "polldir (as indexed in the table) 255 means all polldirs" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF DISABLE_POLLDIR BIG_ENDIAN "Disable polling directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 19 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER POLLDIR 8 UINT MIN_UINT8 MAX_UINT8 0 "polldir (as indexed in the table) 255 means all polldirs" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF PURGE_QUEUE BIG_ENDIAN "Purge either the PEND or HISTORY queue" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 21 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER QUEUE 8 UINT MIN_UINT8 MAX_UINT8 0 "queue number. 0 is PEND, 1 is HISTORY, 2 is both" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF SEND_CFG_PARAMS BIG_ENDIAN "Send a packet with the current local MIB parameters" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 14 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF SET_MIB_PARAM BIG_ENDIAN "Set a local parameter" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 10 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER VALUE 32 UINT MIN_UINT32 MAX_UINT32 0 "Value to set parameter to" - APPEND_PARAMETER KEY 8 UINT 0 255 0 "The parameter ID (see item index of CFG_TLM_PKT)" - APPEND_PARAMETER CHAN_INDEX 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF GET_MIB_PARAM BIG_ENDIAN "Get a local parameter" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 3 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 11 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER KEY 8 UINT 0 255 0 "The parameter ID (see item index of CFG_TLM_PKT)" - APPEND_PARAMETER CHAN_INDEX 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF ENABLE_ENGINE BIG_ENDIAN "Enable the CFDP engine to cycle per app wakeup, and reload configuration" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 22 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF DISABLE_ENGINE BIG_ENDIAN "Disable and reset the CFDP engine" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 23 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - diff --git a/cosmos/big_endian/CF/cf_tlm.txt b/cosmos/big_endian/CF/cf_tlm.txt deleted file mode 100644 index 1bb09420..00000000 --- a/cosmos/big_endian/CF/cf_tlm.txt +++ /dev/null @@ -1,90 +0,0 @@ -TELEMETRY CF HK_TLM_PKT BIG_ENDIAN "CFDP housekeeping Packet" - APPEND_ID_ITEM CCSDS_STREAMID 16 UINT 0x08B0 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_ITEM CCSDS_SEQUENCE 16 UINT "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_ITEM CCSDS_LENGTH 16 UINT "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_ITEM CCSDS_SECONDS 32 UINT "CCSDS Telemetry Secondary Header (seconds)" - APPEND_ITEM CCSDS_SUBSECS 16 UINT "CCSDS Telemetry Secondary Header (subseconds)" - APPEND_ITEM CMD_VALID_COUNT 16 UINT "Count of valid commands received." - APPEND_ITEM CMD_ERROR_COUNT 16 UINT "Count of invalid commands received." - APPEND_ITEM SENT_FD0 64 UINT "File data bytes sent" - APPEND_ITEM SENT_PDU0 32 UINT "Count of PDUs sent" - APPEND_ITEM SENT_NAK_SR0 32 UINT "Count of sent segment requests" - APPEND_ITEM RECV_FD0 64 UINT "File data bytes received" - APPEND_ITEM RECV_PDU0 32 UINT "Count of PDUs received" - APPEND_ITEM RECV_PDU_ERROR0 32 UINT "Count of invalid PDUs received" - APPEND_ITEM RECV_PDU_SPURIOUS0 16 UINT "Count of spurious PDUs received" - APPEND_ITEM RECV_PDU_DROPPED0 16 UINT "Count of dropped PDUs received" - APPEND_ITEM RECV_NAK_SR0 32 UINT "Count of received segment requests" - APPEND_ITEM FAULT_FILE_OPEN0 16 UINT "Count of file open errors" - APPEND_ITEM FAULT_FILE_READ0 16 UINT "Count of file read errors" - APPEND_ITEM FAULT_FILE_SEEK0 16 UINT "Count of file seek errors" - APPEND_ITEM FAULT_FILE_WRITE0 16 UINT "Count of file write errors" - APPEND_ITEM FAULT_FILE_RENAME0 16 UINT "Count of file rename errors" - APPEND_ITEM FAULT_FILE_DIR_READ0 16 UINT "Count of dir read errors" - APPEND_ITEM FAULT_FILE_CRC_MISMATCH0 16 UINT "Count of file crc mismatch errors" - APPEND_ITEM FAULT_FILE_FILE_SIZE_MISMATCH0 16 UINT "Count of file size mismatch errors" - APPEND_ITEM NAK_LIMIT0 16 UINT "Number of times nak limit reached for transaction" - APPEND_ITEM ACK_LIMIT0 16 UINT "Number of times ack limit reached for transaction" - APPEND_ITEM INACTIVITY_TIMER0 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM SPARE0 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM QPEND0 16 UINT "Count of transactions on pending queue (ch0)" - APPEND_ITEM QTXA0 16 UINT "Count of active TX transactions (ch0)" - APPEND_ITEM QTXW0 16 UINT "Count of TX transactions waiting for ACK/NAK (ch0)" - APPEND_ITEM QRX0 16 UINT "Number of active RX transactions (ch0)" - APPEND_ITEM QHIST0 16 UINT "Number of active history items (ch0)" - APPEND_ITEM QHISTFREE0 16 UINT "Number of free history items (ch0)" - APPEND_ITEM QFREE0 16 UINT "Count of free transactions available for the channel (ch0)" - APPEND_ITEM POLL_COUNT0 8 UINT "Count of number of active polling directories on channel" - APPEND_ITEM PLAYBACK_DIR_COUNT0 8 UINT "Count of number of active playback directories on channel" - APPEND_ITEM FLAGS0 8 UINT "If 1, the channel is frozen" - APPEND_ITEM SPARE30 16 UINT "" - APPEND_ITEM SPARE40 8 UINT "" - APPEND_ITEM SENT_FD1 64 UINT "File data bytes sent" - APPEND_ITEM SENT_PDU1 32 UINT "Count of PDUs sent" - APPEND_ITEM SENT_NAK_SR1 32 UINT "Count of sent segment requests" - APPEND_ITEM RECV_FD1 64 UINT "File data bytes received" - APPEND_ITEM RECV_PDU1 32 UINT "Count of PDUs received" - APPEND_ITEM RECV_PDU_ERROR1 32 UINT "Count of invalid PDUs received" - APPEND_ITEM RECV_PDU_SPURIOUS1 16 UINT "Count of spurious PDUs received" - APPEND_ITEM RECV_PDU_DROPPED1 16 UINT "Count of dropped PDUs received" - APPEND_ITEM RECV_NAK_SR1 32 UINT "Count of received segment requests" - APPEND_ITEM FAULT_FILE_OPEN1 16 UINT "Count of file open errors" - APPEND_ITEM FAULT_FILE_READ1 16 UINT "Count of file read errors" - APPEND_ITEM FAULT_FILE_SEEK1 16 UINT "Count of file seek errors" - APPEND_ITEM FAULT_FILE_WRITE1 16 UINT "Count of file write errors" - APPEND_ITEM FAULT_FILE_RENAME1 16 UINT "Count of file rename errors" - APPEND_ITEM FAULT_FILE_DIR_READ1 16 UINT "Count of dir read errors" - APPEND_ITEM FAULT_FILE_CRC_MISMATCH1 16 UINT "Count of file crc mismatch errors" - APPEND_ITEM FAULT_FILE_FILE_SIZE_MISMATCH1 16 UINT "Count of file size mismatch errors" - APPEND_ITEM NAK_LIMIT1 16 UINT "Number of times nak limit reached for transaction" - APPEND_ITEM ACK_LIMIT1 16 UINT "Number of times ack limit reached for transaction" - APPEND_ITEM INACTIVITY_TIMER1 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM SPARE1 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM QPEND1 16 UINT "Count of transactions on pending queue (ch1)" - APPEND_ITEM QTXA1 16 UINT "Count of active TX transactions (ch1)" - APPEND_ITEM QTXW1 16 UINT "Count of TX transactions waiting for ACK/NAK (ch1)" - APPEND_ITEM QRX1 16 UINT "Number of active RX transactions (ch1)" - APPEND_ITEM QHIST1 16 UINT "Number of active history items (ch1)" - APPEND_ITEM QHISTFREE1 16 UINT "Number of free history items (ch1)" - APPEND_ITEM QFREE1 16 UINT "Count of free transactions available for the channel (ch1)" - APPEND_ITEM POLL_COUNT1 8 UINT "Count of number of active polling directories on channel" - APPEND_ITEM PLAYBACK_DIR_COUNT1 8 UINT "Count of number of active playback directories on channel" - APPEND_ITEM FLAGS1 8 UINT "If 1, the channel is frozen" - APPEND_ITEM SPARE31 16 UINT "" - APPEND_ITEM SPARE41 8 UINT "" - -TELEMETRY CF CFG_TLM_PKT BIG_ENDIAN "CF config parameters" - APPEND_ID_ITEM CCSDS_STREAMID 16 UINT 0x08B2 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_ITEM CCSDS_SEQUENCE 16 UINT "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_ITEM CCSDS_LENGTH 16 UINT "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_ITEM CCSDS_SECONDS 32 UINT "CCSDS Telemetry Secondary Header (seconds)" - APPEND_ITEM CCSDS_SUBSECS 16 UINT "CCSDS Telemetry Secondary Header (subseconds)" - APPEND_ITEM TICKS_PER_SECOND 32 UINT "Number of ticks (SCH wakeup messages) per second" - APPEND_ITEM R2_CRC_BYTES_PER_WAKEUP 32 UINT "Number of bytes of CRC to calculate for each R2 transaction per wakeup" - APPEND_ITEM ACK_TIMER_S 32 UINT "Number of seconds for ack timer" - APPEND_ITEM NAK_TIMER_S 32 UINT "Number of seconds for nak timer" - APPEND_ITEM INACTIVITY_TIMER_S 32 UINT "Number of seconds for inactivity timer" - APPEND_ITEM OUTGOING_FILE_CHUNK_SIZE 16 UINT "Max amount of file data per outgoing PDU" - APPEND_ITEM ACK_LIMIT 8 UINT "Number of times to retry ack" - APPEND_ITEM NAK_LIMIT 8 UINT "Number of times to retry nak" - APPEND_ITEM LOCAL_EID 8 UINT "The local entity ID" diff --git a/cosmos/little_endian/CF/cf_cmd.txt b/cosmos/little_endian/CF/cf_cmd.txt deleted file mode 100644 index 6f006a58..00000000 --- a/cosmos/little_endian/CF/cf_cmd.txt +++ /dev/null @@ -1,223 +0,0 @@ -COMMAND CF NOOP LITTLE_ENDIAN "Generate an info event message with app version" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 0 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF RESET_CTRS LITTLE_ENDIAN "Resets HK TLM parent and child task counters" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 1 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER VALUE 8 UINT 0 4 0 "0=all, 1=cmd, 2=fault 3=up 4=down" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF TX_FILE LITTLE_ENDIAN "Send file from Spacecraft to Ground" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 135 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 2 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CLASS 8 UINT 0 1 0 "0=CFDP class 1, 1=CFDP class 2" - APPEND_PARAMETER KEEP 8 UINT 0 1 1 "0=delete file after transfer, 1=keep file" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER PRIO 8 UINT 0 255 0 "Priority (0 is highest)" - APPEND_PARAMETER DEST_ID 16 UINT MIN_UINT16 MAX_UINT16 26 "CFDP destination entity ID" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.bin" "Spacecraft /path/filename" - APPEND_PARAMETER DEST_FILENAME 512 STRING "/home/vagrant/temp.bin" "Complete host /path/filename" - -COMMAND CF PLAYBACK_DIR LITTLE_ENDIAN "Playback a directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 135 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 3 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CLASS 8 UINT 0 1 0 "0=CFDP class 1, 1=CFDP class 2" - APPEND_PARAMETER KEEP 8 UINT 0 1 1 "0=delete file after transfer, 1=keep file" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER PRIO 8 UINT 0 255 0 "Priority (0 is highest)" - APPEND_PARAMETER DEST_ID 16 UINT MIN_UINT16 MAX_UINT16 26 "CFDP destination entity ID" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.bin" "Spacecraft /path/filename of directory" - APPEND_PARAMETER DEST_FILENAME 512 STRING "/home/vagrant/temp.bin" "directory prefix for files on host" - - -COMMAND CF WRITE_QUEUE LITTLE_ENDIAN "Write a queue to file" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 69 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 15 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TYPE 8 UINT 0 2 0 "0=all, 1=up, 2=down" - APPEND_PARAMETER CHAN 8 UINT 0 1 0 "Channel number (0 or 1)" - APPEND_PARAMETER QUEUE 8 UINT 0 3 0 "0=pending, 1=active, 2=history, 3=all" - APPEND_PARAMETER SPARE 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SRC_FILENAME 512 STRING "/cf/example.txt" "Spacecraft /path/filename of directory" - - -COMMAND CF FREEZE_CHAN LITTLE_ENDIAN "Freeze a channel (unable to send messages, and timers stop)" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 4 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF THAW_CHAN LITTLE_ENDIAN "Thaw a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 5 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - - -COMMAND CF SUSPEND_TRANSACTION LITTLE_ENDIAN "Suspend a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 6 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to suspend all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF RESUME_TRANSACTION LITTLE_ENDIAN "Resume a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 7 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to resume all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF CANCEL_TRANSACTION LITTLE_ENDIAN "Cancel a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 8 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to cancel all. 254 means use TSN. 255 means all transactions" - - -COMMAND CF ABANDON_TRANSACTION LITTLE_ENDIAN "Abandon a transaction" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 9 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER TSN 32 UINT 0 0xffffffff 0 "transaction id number" - APPEND_PARAMETER EID 8 UINT 0 0xff 25 "Entity ID of transaction source" - APPEND_PARAMETER CHAN 8 UINT 0 0xff 0xfe "Specify a channel to abandon all. 254 means use TSN. 255 means all transactions" - -COMMAND CF ENABLE_DEQUEUE LITTLE_ENDIAN "Enable dequeue (tx file) for a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 16 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF DISABLE_DEQUEUE LITTLE_ENDIAN "Disable dequeue (tx file) for a channel" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 17 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER SPARE_1 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF ENABLE_POLLDIR LITTLE_ENDIAN "Enable polling directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 18 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER POLLDIR 8 UINT MIN_UINT8 MAX_UINT8 0 "polldir (as indexed in the table) 255 means all polldirs" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF DISABLE_POLLDIR LITTLE_ENDIAN "Disable polling directory" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 19 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER POLLDIR 8 UINT MIN_UINT8 MAX_UINT8 0 "polldir (as indexed in the table) 255 means all polldirs" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF PURGE_QUEUE LITTLE_ENDIAN "Purge either the PEND or HISTORY queue" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 5 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 21 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER CHANNEL 8 UINT 0 255 0 "channel number (0, 1, ...) 255 means all channels" - APPEND_PARAMETER QUEUE 8 UINT MIN_UINT8 MAX_UINT8 0 "queue number. 0 is PEND, 1 is HISTORY, 2 is both" - APPEND_PARAMETER SPARE_2 8 UINT MIN_UINT8 MAX_UINT8 0 "" - APPEND_PARAMETER SPARE_3 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF SEND_CFG_PARAMS LITTLE_ENDIAN "Send a packet with the current local MIB parameters" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 14 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF SET_MIB_PARAM LITTLE_ENDIAN "Set a local parameter" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 7 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 10 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER VALUE 32 UINT MIN_UINT32 MAX_UINT32 0 "Value to set parameter to" - APPEND_PARAMETER KEY 8 UINT 0 255 0 "The parameter ID (see item index of CFG_TLM_PKT)" - APPEND_PARAMETER CHAN_INDEX 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF GET_MIB_PARAM LITTLE_ENDIAN "Get a local parameter" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 3 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 11 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - APPEND_PARAMETER KEY 8 UINT 0 255 0 "The parameter ID (see item index of CFG_TLM_PKT)" - APPEND_PARAMETER CHAN_INDEX 8 UINT MIN_UINT8 MAX_UINT8 0 "" - -COMMAND CF ENABLE_ENGINE LITTLE_ENDIAN "Enable the CFDP engine to cycle per app wakeup, and reload configuration" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 22 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - -COMMAND CF DISABLE_ENGINE LITTLE_ENDIAN "Disable and reset the CFDP engine" - APPEND_ID_PARAMETER CCSDS_STREAMID 16 UINT MIN_UINT16 MAX_UINT16 0x18B3 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_PARAMETER CCSDS_SEQUENCE 16 UINT MIN_UINT16 MAX_UINT16 0xC000 "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_PARAMETER CCSDS_LENGTH 16 UINT MIN_UINT16 MAX_UINT16 1 "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_PARAMETER CCSDS_FC 8 UINT MIN_UINT8 MAX_UINT8 23 "CCSDS Command Function Code" - APPEND_PARAMETER CCSDS_CHECKSUM 8 UINT MIN_UINT8 MIN_UINT8 0 "Checksum" - diff --git a/cosmos/little_endian/CF/cf_tlm.txt b/cosmos/little_endian/CF/cf_tlm.txt deleted file mode 100644 index 4b3a3e52..00000000 --- a/cosmos/little_endian/CF/cf_tlm.txt +++ /dev/null @@ -1,90 +0,0 @@ -TELEMETRY CF HK_TLM_PKT LITTLE_ENDIAN "CFDP housekeeping Packet" - APPEND_ID_ITEM CCSDS_STREAMID 16 UINT 0x08B0 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_ITEM CCSDS_SEQUENCE 16 UINT "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_ITEM CCSDS_LENGTH 16 UINT "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_ITEM CCSDS_SECONDS 32 UINT "CCSDS Telemetry Secondary Header (seconds)" - APPEND_ITEM CCSDS_SUBSECS 16 UINT "CCSDS Telemetry Secondary Header (subseconds)" - APPEND_ITEM CMD_VALID_COUNT 16 UINT "Count of valid commands received." - APPEND_ITEM CMD_ERROR_COUNT 16 UINT "Count of invalid commands received." - APPEND_ITEM SENT_FD0 64 UINT "File data bytes sent" - APPEND_ITEM SENT_PDU0 32 UINT "Count of PDUs sent" - APPEND_ITEM SENT_NAK_SR0 32 UINT "Count of sent segment requests" - APPEND_ITEM RECV_FD0 64 UINT "File data bytes received" - APPEND_ITEM RECV_PDU0 32 UINT "Count of PDUs received" - APPEND_ITEM RECV_PDU_ERROR0 32 UINT "Count of invalid PDUs received" - APPEND_ITEM RECV_PDU_SPURIOUS0 16 UINT "Count of spurious PDUs received" - APPEND_ITEM RECV_PDU_DROPPED0 16 UINT "Count of dropped PDUs received" - APPEND_ITEM RECV_NAK_SR0 32 UINT "Count of received segment requests" - APPEND_ITEM FAULT_FILE_OPEN0 16 UINT "Count of file open errors" - APPEND_ITEM FAULT_FILE_READ0 16 UINT "Count of file read errors" - APPEND_ITEM FAULT_FILE_SEEK0 16 UINT "Count of file seek errors" - APPEND_ITEM FAULT_FILE_WRITE0 16 UINT "Count of file write errors" - APPEND_ITEM FAULT_FILE_RENAME0 16 UINT "Count of file rename errors" - APPEND_ITEM FAULT_FILE_DIR_READ0 16 UINT "Count of dir read errors" - APPEND_ITEM FAULT_FILE_CRC_MISMATCH0 16 UINT "Count of file crc mismatch errors" - APPEND_ITEM FAULT_FILE_FILE_SIZE_MISMATCH0 16 UINT "Count of file size mismatch errors" - APPEND_ITEM NAK_LIMIT0 16 UINT "Number of times nak limit reached for transaction" - APPEND_ITEM ACK_LIMIT0 16 UINT "Number of times ack limit reached for transaction" - APPEND_ITEM INACTIVITY_TIMER0 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM SPARE0 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM QPEND0 16 UINT "Count of transactions on pending queue (ch0)" - APPEND_ITEM QTXA0 16 UINT "Count of active TX transactions (ch0)" - APPEND_ITEM QTXW0 16 UINT "Count of TX transactions waiting for ACK/NAK (ch0)" - APPEND_ITEM QRX0 16 UINT "Number of active RX transactions (ch0)" - APPEND_ITEM QHIST0 16 UINT "Number of active history items (ch0)" - APPEND_ITEM QHISTFREE0 16 UINT "Number of free history items (ch0)" - APPEND_ITEM QFREE0 16 UINT "Count of free transactions available for the channel (ch0)" - APPEND_ITEM POLL_COUNT0 8 UINT "Count of number of active polling directories on channel" - APPEND_ITEM PLAYBACK_DIR_COUNT0 8 UINT "Count of number of active playback directories on channel" - APPEND_ITEM FLAGS0 8 UINT "If 1, the channel is frozen" - APPEND_ITEM SPARE30 16 UINT "" - APPEND_ITEM SPARE40 8 UINT "" - APPEND_ITEM SENT_FD1 64 UINT "File data bytes sent" - APPEND_ITEM SENT_PDU1 32 UINT "Count of PDUs sent" - APPEND_ITEM SENT_NAK_SR1 32 UINT "Count of sent segment requests" - APPEND_ITEM RECV_FD1 64 UINT "File data bytes received" - APPEND_ITEM RECV_PDU1 32 UINT "Count of PDUs received" - APPEND_ITEM RECV_PDU_ERROR1 32 UINT "Count of invalid PDUs received" - APPEND_ITEM RECV_PDU_SPURIOUS1 16 UINT "Count of spurious PDUs received" - APPEND_ITEM RECV_PDU_DROPPED1 16 UINT "Count of dropped PDUs received" - APPEND_ITEM RECV_NAK_SR1 32 UINT "Count of received segment requests" - APPEND_ITEM FAULT_FILE_OPEN1 16 UINT "Count of file open errors" - APPEND_ITEM FAULT_FILE_READ1 16 UINT "Count of file read errors" - APPEND_ITEM FAULT_FILE_SEEK1 16 UINT "Count of file seek errors" - APPEND_ITEM FAULT_FILE_WRITE1 16 UINT "Count of file write errors" - APPEND_ITEM FAULT_FILE_RENAME1 16 UINT "Count of file rename errors" - APPEND_ITEM FAULT_FILE_DIR_READ1 16 UINT "Count of dir read errors" - APPEND_ITEM FAULT_FILE_CRC_MISMATCH1 16 UINT "Count of file crc mismatch errors" - APPEND_ITEM FAULT_FILE_FILE_SIZE_MISMATCH1 16 UINT "Count of file size mismatch errors" - APPEND_ITEM NAK_LIMIT1 16 UINT "Number of times nak limit reached for transaction" - APPEND_ITEM ACK_LIMIT1 16 UINT "Number of times ack limit reached for transaction" - APPEND_ITEM INACTIVITY_TIMER1 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM SPARE1 16 UINT "Number of times inactivity timer timed out for transaction" - APPEND_ITEM QPEND1 16 UINT "Count of transactions on pending queue (ch1)" - APPEND_ITEM QTXA1 16 UINT "Count of active TX transactions (ch1)" - APPEND_ITEM QTXW1 16 UINT "Count of TX transactions waiting for ACK/NAK (ch1)" - APPEND_ITEM QRX1 16 UINT "Number of active RX transactions (ch1)" - APPEND_ITEM QHIST1 16 UINT "Number of active history items (ch1)" - APPEND_ITEM QHISTFREE1 16 UINT "Number of free history items (ch1)" - APPEND_ITEM QFREE1 16 UINT "Count of free transactions available for the channel (ch1)" - APPEND_ITEM POLL_COUNT1 8 UINT "Count of number of active polling directories on channel" - APPEND_ITEM PLAYBACK_DIR_COUNT1 8 UINT "Count of number of active playback directories on channel" - APPEND_ITEM FLAGS1 8 UINT "If 1, the channel is frozen" - APPEND_ITEM SPARE31 16 UINT "" - APPEND_ITEM SPARE41 8 UINT "" - -TELEMETRY CF CFG_TLM_PKT LITTLE_ENDIAN "CF config parameters" - APPEND_ID_ITEM CCSDS_STREAMID 16 UINT 0x08B2 "CCSDS Packet Identification" BIG_ENDIAN - APPEND_ITEM CCSDS_SEQUENCE 16 UINT "CCSDS Packet Sequence Control" BIG_ENDIAN - APPEND_ITEM CCSDS_LENGTH 16 UINT "CCSDS Packet Data Length" BIG_ENDIAN - APPEND_ITEM CCSDS_SECONDS 32 UINT "CCSDS Telemetry Secondary Header (seconds)" - APPEND_ITEM CCSDS_SUBSECS 16 UINT "CCSDS Telemetry Secondary Header (subseconds)" - APPEND_ITEM TICKS_PER_SECOND 32 UINT "Number of ticks (SCH wakeup messages) per second" - APPEND_ITEM R2_CRC_BYTES_PER_WAKEUP 32 UINT "Number of bytes of CRC to calculate for each R2 transaction per wakeup" - APPEND_ITEM ACK_TIMER_S 32 UINT "Number of seconds for ack timer" - APPEND_ITEM NAK_TIMER_S 32 UINT "Number of seconds for nak timer" - APPEND_ITEM INACTIVITY_TIMER_S 32 UINT "Number of seconds for inactivity timer" - APPEND_ITEM OUTGOING_FILE_CHUNK_SIZE 16 UINT "Max amount of file data per outgoing PDU" - APPEND_ITEM ACK_LIMIT 8 UINT "Number of times to retry ack" - APPEND_ITEM NAK_LIMIT 8 UINT "Number of times to retry nak" - APPEND_ITEM LOCAL_EID 8 UINT "The local entity ID" diff --git a/docs/cf_FunctionalRequirements.csv b/docs/cf_FunctionalRequirements.csv index 79c040c2..a3d32c7c 100644 --- a/docs/cf_FunctionalRequirements.csv +++ b/docs/cf_FunctionalRequirements.csv @@ -157,7 +157,11 @@ CF: Housekeeping Message,CF6000,"The CF Housekeeping message shall include 23. Number of File Size Mismatch Faults 24. Number of NAK Limit Exceeded Faults 25. Number of ACK Limit Exceeded Faults -26. Number of Inactivity Timer Limit Exceeded Faults",Operator interface that provides detailed status on operational state +26. Number of Inactivity Timer Limit Exceeded Faults +27. Number of Files Successfully Sent +28. Number of Files Successfully Received +29. Number of Files Initialized To Be Sent +30. Number of Files Initialized To Be Received",Operator interface that provides detailed status on operational state CF: End Of Transaction Message,CF6001,"The CF End of Transaction message shall include 1. Transaction identifier 2. Channel number diff --git a/eds/cf.xml b/eds/cf.xml index 20199da3..1361548e 100644 --- a/eds/cf.xml +++ b/eds/cf.xml @@ -216,6 +216,8 @@ + + @@ -228,6 +230,8 @@ file directive FIN without matching active transaction counter" /> + + diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index c8491c45..8c216dc8 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1136,6 +1136,12 @@ void CF_CFDP_SetupTxTransaction(CF_Transaction_t *txn) *-----------------------------------------------------------------*/ void CF_CFDP_SetupRxTransaction(CF_Transaction_t *txn, CF_Logical_PduBuffer_t *ph) { + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); + + /* this is only reached for a brand-new RX transaction, so the file is now set up + * for reception, whether or not it ultimately succeeds */ + ++chan->stat.counters.recv.files_started; + /* only RX transactions dare tread here */ txn->history->seq_num = ph->pdu_header.sequence_num; @@ -1689,6 +1695,9 @@ static void CF_CFDP_TxFile_Initiate(CF_Transaction_t *txn, CF_CFDP_InitTxnTxFile(txn, cfdp_class, keep, chan, priority); + /* the file is now set up for transmission, whether or not it ultimately succeeds */ + ++chan->stat.counters.sent.files_started; + /* Increment sequence number for new transaction */ ++engine_ptr->seq_num; diff --git a/fsw/src/cf_cfdp_r.c b/fsw/src/cf_cfdp_r.c index 61347e26..ab21ef82 100644 --- a/fsw/src/cf_cfdp_r.c +++ b/fsw/src/cf_cfdp_r.c @@ -1011,6 +1011,7 @@ CF_RxSubState_t CF_CFDP_R_CheckState_FINACK(CF_Transaction_t *txn) void CF_CFDP_R_CheckState(CF_Transaction_t *txn) { CF_RxSubState_t next_state = txn->state_data.sub_state; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* State transitions are done here */ switch (txn->state_data.sub_state) @@ -1074,6 +1075,11 @@ void CF_CFDP_R_CheckState(CF_Transaction_t *txn) txn->flags.rx.send_fin = true; break; case CF_RxSubState_COMPLETE: + /* only a transaction that reached this point without error received a complete file */ + if (CF_CFDP_TxnIsOK(txn)) + { + ++chan->stat.counters.recv.files_recv; + } /* This changes the txn state such that this function is no longer called. */ CF_CFDP_FinishTransaction(txn, true); break; diff --git a/fsw/src/cf_cfdp_s.c b/fsw/src/cf_cfdp_s.c index 75265b83..b45b5ead 100644 --- a/fsw/src/cf_cfdp_s.c +++ b/fsw/src/cf_cfdp_s.c @@ -827,6 +827,7 @@ CF_TxSubState_t CF_CFDP_S_CheckState_FILESTORE(CF_Transaction_t *txn) void CF_CFDP_S_CheckState(CF_Transaction_t *txn) { CF_TxSubState_t next_state = txn->state_data.sub_state; + CF_Channel_t *chan = CF_GetChannelFromTxn(txn); /* State transitions are done here */ switch (txn->state_data.sub_state) @@ -871,6 +872,11 @@ void CF_CFDP_S_CheckState(CF_Transaction_t *txn) txn->flags.tx.send_eof = true; break; case CF_TxSubState_COMPLETE: + /* only a transaction that reached this point without error sent a complete file */ + if (CF_CFDP_TxnIsOK(txn)) + { + ++chan->stat.counters.sent.files_sent; + } /* This changes the txn state such that this function is no longer called. */ CF_CFDP_FinishTransaction(txn, true); break; diff --git a/unit-test/cf_cfdp_r_tests.c b/unit-test/cf_cfdp_r_tests.c index 49b2e1f5..1fc9699b 100644 --- a/unit-test/cf_cfdp_r_tests.c +++ b/unit-test/cf_cfdp_r_tests.c @@ -1158,6 +1158,7 @@ void Test_CF_CFDP_R_CheckState_FINACK(void) * void CF_CFDP_R_CheckState(CF_Transaction_t *txn) */ CF_Transaction_t *txn; + CF_Channel_t *chan; /* FINACK state, R1, fin pending */ UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); @@ -1214,30 +1215,36 @@ void Test_CF_CFDP_R_CheckState_FINACK(void) /* FINACK state, R2, fin sent, not acked, timer expired, over limit */ UT_ResetState(0); - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = true; txn->flags.rx.finack_recv = false; txn->flags.rx.send_fin = false; txn->flags.com.ack_timer_armed = false; txn->state_data.sub_state = CF_RxSubState_FINACK; UT_SetDeferredRetcode(UT_KEY(CF_CFDP_CheckAckNakCount), 1, false); + UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_TxnIsOK), true); UtAssert_VOIDCALL(CF_CFDP_R_CheckState(txn)); UtAssert_UINT8_EQ(txn->state_data.sub_state, CF_RxSubState_COMPLETE); UtAssert_BOOL_FALSE(txn->flags.rx.send_fin); UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); + /* the fin-ack never arrived but the file itself was received without error */ + UtAssert_UINT32_EQ(chan->stat.counters.recv.files_recv, 1); /* FINACK state, R2, fin sent, not acked, inactivity reached */ UT_ResetState(0); - UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); txn->reliable_mode = true; txn->flags.rx.finack_recv = false; txn->flags.rx.send_fin = false; txn->flags.com.inactivity_fired = true; txn->state_data.sub_state = CF_RxSubState_FINACK; + UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_TxnIsOK), false); UtAssert_VOIDCALL(CF_CFDP_R_CheckState(txn)); UtAssert_UINT8_EQ(txn->state_data.sub_state, CF_RxSubState_COMPLETE); UtAssert_BOOL_FALSE(txn->flags.rx.send_fin); UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); + /* inactivity is a failure, so the count must remain at the 1 from the prior case */ + UtAssert_UINT32_EQ(chan->stat.counters.recv.files_recv, 1); } void Test_CF_CFDP_R_CheckState_COMPLETE(void) diff --git a/unit-test/cf_cfdp_s_tests.c b/unit-test/cf_cfdp_s_tests.c index 6f630301..2e7d8fc8 100644 --- a/unit-test/cf_cfdp_s_tests.c +++ b/unit-test/cf_cfdp_s_tests.c @@ -1072,12 +1072,27 @@ void Test_CF_CFDP_S_CheckState_FILESTORE(void) * void CF_CFDP_S_CheckState(CF_Transaction_t *txn) */ CF_Transaction_t *txn; + CF_Channel_t *chan; - UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, NULL, NULL, &txn, NULL); + /* nominal, transaction reached the end without error */ + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); + UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_TxnIsOK), true); + txn->state_data.sub_state = CF_TxSubState_FILESTORE; + UtAssert_VOIDCALL(CF_CFDP_S_CheckState(txn)); + UtAssert_UINT8_EQ(txn->state_data.sub_state, CF_TxSubState_COMPLETE); + UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_sent, 1); + + /* transaction reached the end in an error state, so no file was successfully sent */ + UT_ResetState(0); + UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_NONE, NULL, &chan, NULL, &txn, NULL); + UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_TxnIsOK), false); txn->state_data.sub_state = CF_TxSubState_FILESTORE; UtAssert_VOIDCALL(CF_CFDP_S_CheckState(txn)); UtAssert_UINT8_EQ(txn->state_data.sub_state, CF_TxSubState_COMPLETE); UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); + /* the error case must not count, so the total remains at the 1 from the prior case */ + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_sent, 1); } void Test_CF_CFDP_S_CheckState_COMPLETE(void) diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 834cadc5..68504049 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -932,6 +932,7 @@ void Test_CF_CFDP_TxFile(void) UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); UtAssert_UINT32_EQ(chan->stat.num_cmd_tx, 1); + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_started, 1); UT_CF_AssertEventID(CF_CFDP_S_START_SEND_INF_EID); /* same but for class 2 (for branch coverage) */ @@ -943,6 +944,7 @@ void Test_CF_CFDP_TxFile(void) UtAssert_STRINGBUF_EQ(dest, -1, history->fnames.dst_filename, sizeof(history->fnames.dst_filename)); UtAssert_STRINGBUF_EQ(src, -1, history->fnames.src_filename, sizeof(history->fnames.src_filename)); UtAssert_UINT32_EQ(chan->stat.num_cmd_tx, 2); + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_started, 2); UT_CF_AssertEventID(CF_CFDP_S_START_SEND_INF_EID); /* max TX */ @@ -950,6 +952,8 @@ void Test_CF_CFDP_TxFile(void) chan->stat.num_cmd_tx = CF_MAX_COMMANDED_PLAYBACK_FILES_PER_CHAN; UtAssert_INT32_EQ(CF_CFDP_TxFile(src, dest, CF_CFDP_Class_1, 1, UT_CFDP_CHANNEL_PTR, 0, 1), -1); UT_CF_AssertEventID(CF_CFDP_MAX_CMD_TX_ERR_EID); + /* rejected before initiation, so the count must remain at the 2 from the prior cases */ + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_started, 2); } void Test_CF_CFDP_StartRxTransaction(void) @@ -1254,6 +1258,8 @@ void Test_CF_CFDP_ProcessPlaybackDirectory(void) UtAssert_STRINGBUF_EQ(history->fnames.dst_filename, sizeof(history->fnames.dst_filename), "/ut", -1); UtAssert_STRINGBUF_EQ(pb.pending_file, sizeof(pb.pending_file), "", -1); UT_CF_AssertEventID(CF_CFDP_S_START_SEND_INF_EID); + /* playback-initiated transfers count as started, same as commanded ones */ + UtAssert_UINT32_EQ(chan->stat.counters.sent.files_started, 1); } static int32 @@ -1742,6 +1748,8 @@ void Test_CF_CFDP_SetupRxTransaction(void) UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_NULL(txn.chunks); UtAssert_UINT32_EQ(txn.state, CF_TxnState_HOLD); + /* a transaction that immediately goes to holdover was still initialized for reception */ + UtAssert_UINT32_EQ(chan->stat.counters.recv.files_started, 1); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); @@ -1754,6 +1762,7 @@ void Test_CF_CFDP_SetupRxTransaction(void) UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_UINT32_EQ(txn.state, CF_TxnState_R1); UtAssert_STUB_COUNT(CF_CFDP_R_Init, 1); + UtAssert_UINT32_EQ(chan->stat.counters.recv.files_started, 2); memset(&txn, 0, sizeof(txn)); memset(&hist, 0, sizeof(hist)); @@ -1766,6 +1775,7 @@ void Test_CF_CFDP_SetupRxTransaction(void) UtAssert_VOIDCALL(CF_CFDP_SetupRxTransaction(&txn, &ph)); UtAssert_UINT32_EQ(txn.state, CF_TxnState_R2); UtAssert_STUB_COUNT(CF_CFDP_R_Init, 2); + UtAssert_UINT32_EQ(chan->stat.counters.recv.files_started, 3); } void Test_CF_CFDP_ReceivePdu(void) diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index 60b49486..c851467f 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -252,7 +252,7 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_fault_ResetAllHkFaultCount UtAssert_ZERO(chan->stat.counters.fault.inactivity_timer); UtAssert_MemCmpValue(&chan->stat.counters.fault, 0, - sizeof(&chan->stat.counters.fault), + sizeof(chan->stat.counters.fault), "fault channel was completely cleared to 0"); /* Assert to show counter incremented */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); @@ -276,6 +276,8 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_up_AndResetAllHkRecvCountS chan->stat.counters.recv.spurious = Any_uint16_Except(0); chan->stat.counters.recv.dropped = Any_uint16_Except(0); chan->stat.counters.recv.nak_segment_requests = Any_uint32_Except(0); + chan->stat.counters.recv.files_recv = Any_uint32_Except(0); + chan->stat.counters.recv.files_started = Any_uint32_Except(0); CF_AppData.counters.cmd = initial_hk_cmd_counter; @@ -293,9 +295,11 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_up_AndResetAllHkRecvCountS UtAssert_ZERO(chan->stat.counters.recv.spurious); UtAssert_ZERO(chan->stat.counters.recv.pdu); UtAssert_ZERO(chan->stat.counters.recv.nak_segment_requests); + UtAssert_ZERO(chan->stat.counters.recv.files_recv); + UtAssert_ZERO(chan->stat.counters.recv.files_started); UtAssert_MemCmpValue(&chan->stat.counters.recv, 0, - sizeof(&chan->stat.counters.recv), + sizeof(chan->stat.counters.recv), "recv channel was completely cleared to 0"); /* Assert to show counter incremented */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); @@ -316,6 +320,8 @@ void Test_CF_ResetCountersCmd_tests_SWhenCommandByteIs_down_AndResetAllHkSentCou chan->stat.counters.sent.file_data_bytes = Any_uint64_Except(0); chan->stat.counters.sent.nak_segment_requests = Any_uint32_Except(0); chan->stat.counters.sent.pdu = Any_uint32_Except(0); + chan->stat.counters.sent.files_sent = Any_uint32_Except(0); + chan->stat.counters.sent.files_started = Any_uint32_Except(0); CF_AppData.counters.cmd = initial_hk_cmd_counter; @@ -330,9 +336,11 @@ void Test_CF_ResetCountersCmd_tests_SWhenCommandByteIs_down_AndResetAllHkSentCou UtAssert_ZERO(chan->stat.counters.sent.file_data_bytes); UtAssert_ZERO(chan->stat.counters.sent.nak_segment_requests); UtAssert_ZERO(chan->stat.counters.sent.pdu); + UtAssert_ZERO(chan->stat.counters.sent.files_sent); + UtAssert_ZERO(chan->stat.counters.sent.files_started); UtAssert_MemCmpValue(&chan->stat.counters.sent, 0, - sizeof(&chan->stat.counters.sent), + sizeof(chan->stat.counters.sent), "sent channel was completely cleared to 0"); /* Assert to show counter incremented */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); @@ -370,10 +378,14 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_all_AndResetAllMemValuesSe chan->stat.counters.recv.spurious = Any_uint16_Except(0); chan->stat.counters.recv.dropped = Any_uint16_Except(0); chan->stat.counters.recv.nak_segment_requests = Any_uint32_Except(0); + chan->stat.counters.recv.files_recv = Any_uint32_Except(0); + chan->stat.counters.recv.files_started = Any_uint32_Except(0); chan->stat.counters.sent.file_data_bytes = Any_uint64_Except(0); chan->stat.counters.sent.nak_segment_requests = Any_uint32_Except(0); chan->stat.counters.sent.pdu = Any_uint32_Except(0); + chan->stat.counters.sent.files_sent = Any_uint32_Except(0); + chan->stat.counters.sent.files_started = Any_uint32_Except(0); /* Act */ CF_ResetCountersCmd(&utbuf); @@ -387,15 +399,15 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_all_AndResetAllMemValuesSe UtAssert_ZERO(CF_AppData.counters.err); UtAssert_MemCmpValue(&chan->stat.counters.fault, 0, - sizeof(&chan->stat.counters.fault), + sizeof(chan->stat.counters.fault), "fault channel was completely cleared to 0"); UtAssert_MemCmpValue(&chan->stat.counters.recv, 0, - sizeof(&chan->stat.counters.recv), + sizeof(chan->stat.counters.recv), "recv channel was completely cleared to 0"); UtAssert_MemCmpValue(&chan->stat.counters.sent, 0, - sizeof(&chan->stat.counters.sent), + sizeof(chan->stat.counters.sent), "sent channel was completely cleared to 0"); } From d7ab63b7e5b586795509009bf71ca8957e12626e Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 2 Sep 2026 12:03:32 -0400 Subject: [PATCH 12/18] Fix #515, reduce cyclic complexity of command handlers Refactor the cf_cmd.c to reduce complexity of various functions This removes multiple variations on how the loops over multiple entities are being performed in command handlers, creating standard patterns for all commands. The index specifier value of 0 is reserved to mean "all" for any command which accepts this type of wildcard value. All singluar item specifiers should be 1-based. For all commands accepting a channel number, the value of "all" (0) is permitted whenever feasible. The only exception is TxFile which is only valid for a single specific channel. All other commands will accept "all" and go through the same ForEachChannel loop to perform the same operation on all channels. This removes a lot of inconsistencies in how this channel number had been interpreted. For other indices such as Queue selections, direction specifiers, polling dirs, and any other index - 0 will mean "all" and will be processed consistently across all commands. IMPORTANT: this changes some command definitions where "0" was a valid value. Enumerations are changed so that all valid (singular) values start at 1, and 0 is reserved to mean "all" or will be rejected as invalid if the command does not permit operation on multiple channels. --- config/default_cf_extern_typedefs.h | 8 + config/default_cf_fcncode_values.h | 2 +- config/default_cf_msg.h | 5 +- config/default_cf_msgdefs.h | 92 +- config/default_cf_tbldefs.h | 8 +- config/eds_cf_extern_typedefs.h | 12 +- eds/cf.xml | 124 +- fsw/inc/cf_eventids.h | 36 +- fsw/inc/cf_fcncodes.h | 14 +- fsw/src/cf_app.c | 4 +- fsw/src/cf_app.h | 66 +- fsw/src/cf_cfdp.c | 16 +- fsw/src/cf_cfdp_sbintf.c | 6 +- fsw/src/cf_cmd.c | 2233 ++++++++++++------- fsw/src/cf_cmd.h | 334 +-- fsw/src/cf_utils.c | 42 +- fsw/src/cf_utils.h | 13 - unit-test/cf_cfdp_dispatch_tests.c | 2 +- unit-test/cf_cfdp_r_tests.c | 2 +- unit-test/cf_cfdp_s_tests.c | 2 +- unit-test/cf_cfdp_sbintf_tests.c | 2 +- unit-test/cf_cfdp_tests.c | 2 +- unit-test/cf_cmd_tests.c | 2367 ++++++--------------- unit-test/cf_utils_tests.c | 31 - unit-test/stubs/cf_cfdp_sbintf_stubs.c | 4 +- unit-test/stubs/cf_cmd_stubs.c | 262 --- unit-test/stubs/cf_utils_handlers.c | 77 +- unit-test/stubs/cf_utils_stubs.c | 26 +- unit-test/utilities/cf_test_alt_handler.c | 77 + unit-test/utilities/cf_test_alt_handler.h | 10 + unit-test/utilities/cf_test_utils.c | 2 +- unit-test/utilities/cf_test_utils.h | 22 +- 32 files changed, 2494 insertions(+), 3409 deletions(-) diff --git a/config/default_cf_extern_typedefs.h b/config/default_cf_extern_typedefs.h index 66100420..b774195d 100644 --- a/config/default_cf_extern_typedefs.h +++ b/config/default_cf_extern_typedefs.h @@ -52,6 +52,14 @@ enum CF_CFDP_Class */ typedef uint8 CF_CFDP_Class_Enum_t; +/** + * @brief A simple boolean for enable/disable switches + * + * This is fixed as an 8-bit unsigned value in commands + * and telemetry where 0=false/off and 1=true/on + */ +typedef uint8 CF_EnableFlag_Enum_t; + /** * @brief CF queue identifiers */ diff --git a/config/default_cf_fcncode_values.h b/config/default_cf_fcncode_values.h index 2e2948d2..6193c599 100644 --- a/config/default_cf_fcncode_values.h +++ b/config/default_cf_fcncode_values.h @@ -35,7 +35,7 @@ #define CF_CCVAL(x) CF_FunctionCode_##x -enum CF_FunctionCode_ +enum CF_FunctionCode { CF_FunctionCode_NOOP = 0, CF_FunctionCode_RESET_COUNTERS = 1, diff --git a/config/default_cf_msg.h b/config/default_cf_msg.h index d3e5f377..2e0a0fcb 100644 --- a/config/default_cf_msg.h +++ b/config/default_cf_msg.h @@ -37,8 +37,7 @@ #include "cf_msgdefs.h" #include "cf_msgstruct.h" -#define CF_COMPOUND_KEY (254) -#define CF_ALL_CHANNELS (255) -#define CF_ALL_POLLDIRS (CF_ALL_CHANNELS) +#define CF_ALL_CHANNELS CF_ChannelSelect_FromInt(0) +#define CF_ALL_POLLDIRS (0) #endif diff --git a/config/default_cf_msgdefs.h b/config/default_cf_msgdefs.h index 91391f73..0074d55d 100644 --- a/config/default_cf_msgdefs.h +++ b/config/default_cf_msgdefs.h @@ -38,10 +38,11 @@ */ typedef enum CF_Type { - CF_Type_all = 0, /**< \brief Type all */ - CF_Type_up = 1, /**< \brief Type up */ - CF_Type_down = 2 /**< \brief Type down */ -} CF_Type_t; + CF_DirectionType_all = 0, /**< \brief Unspecified - Select all types */ + CF_DirectionType_up = 1, /**< \brief Type up */ + CF_DirectionType_down = 2, /**< \brief Type down */ + CF_DirectionType_MAX = 3 /**< \brief Limit - All valid values are less than this */ +} CF_DirectionType_t; /** * @brief External type to use for CFDP queue type @@ -49,7 +50,7 @@ typedef enum CF_Type * This uses the labels defined in enum CF_Type * but maps to a fixed-width type for use in CMD/TLM/Tables */ -typedef uint8 CF_Type_Enum_t; +typedef uint8 CF_DirectionType_Enum_t; /** * @brief Standardized type used for channel selection in commands @@ -72,10 +73,11 @@ typedef uint8 CF_PollIdxSelect_t; */ enum CF_QueueSelect { - CF_QueueSelect_Pending = 0, /**< \brief Pending Queue */ - CF_QueueSelect_Active = 1, /**< \brief Active Queue */ - CF_QueueSelect_History = 2, /**< \brief History Queue */ - CF_QueueSelect_All = 3, /**< \brief All queues */ + CF_QueueSelect_All = 0, /**< \brief Unspecified - Select all queues */ + CF_QueueSelect_Pending = 1, /**< \brief Pending Queue */ + CF_QueueSelect_Active = 2, /**< \brief Active Queue */ + CF_QueueSelect_History = 3, /**< \brief History Queue */ + CF_QueueSelect_MAX = 4 /**< \brief Limit - All valid values are less than this */ }; /** @@ -166,12 +168,12 @@ typedef struct CF_HkCounters */ typedef struct CF_HkChannel_Data { - CF_HkCounters_t counters; /**< \brief Counters */ - uint16 q_size[CF_QueueIdx_NUM]; /**< \brief Queue sizes */ - uint8 poll_counter; /**< \brief Number of active polling directories */ - uint8 playback_counter; /**< \brief Number of active playback directories */ - uint8 frozen; /**< \brief Frozen state: 0 == not frozen, else frozen */ - uint8 spare; /**< \brief Alignment spare (uint64 values in the counters) */ + CF_HkCounters_t counters; /**< \brief Counters */ + uint16 q_size[CF_QueueIdx_NUM]; /**< \brief Queue sizes */ + uint8 poll_counter; /**< \brief Number of active polling directories */ + uint8 playback_counter; /**< \brief Number of active playback directories */ + CF_EnableFlag_Enum_t frozen; /**< \brief Frozen state: 0 == not frozen, else frozen */ + uint8 spare; /**< \brief Alignment spare (uint64 values in the counters) */ } CF_HkChannel_Data_t; /** @@ -218,7 +220,8 @@ enum CF_Reset CF_Reset_command = 1, /**< \brief Reset command */ CF_Reset_fault = 2, /**< \brief Reset fault */ CF_Reset_up = 3, /**< \brief Reset up */ - CF_Reset_down = 4 /**< \brief Reset down */ + CF_Reset_down = 4, /**< \brief Reset down */ + CF_Reset_MAX = 5 /**< \brief Limit - All valid values are less than this */ }; /** @@ -243,8 +246,8 @@ typedef struct CF_ResetCountersCmd_Payload * \brief Single byte channel selector payload * * Used in all commands needing only a channel selection - * - 255 = all channels - * - else = single channel + * - 0 = unspecified/all channels + * - else = single channel, 1-based */ typedef struct CF_ChannelSelect_Payload { @@ -257,12 +260,12 @@ typedef struct CF_ChannelSelect_Payload * Used in all commands needing a polldir selection * * Single byte channel selector - * - 255 = all channels - * - else = single channel + * - 0 = unspecified/all channels + * - else = single channel, 1-based * * Single byte polling directory index - * - 255 = all polling directories - * - else = single polling directory index + * - 0 = unspecified/all polling directories + * - else = single polling directory index, 1-based */ typedef struct CF_PollDirSelect_Payload { @@ -281,9 +284,10 @@ typedef struct CF_PollDirSelect_Payload * * Single byte queue selection enum * Values indicated by #CF_QueueSelect enum - * - 0 = Pending queue - * - 1 = History queue - * - 2 = Both pending and history queue + * - 0 = Unspecified/all valid queues + * - 1 = Pending queue + * - 2 = Active queue (if applicable; not valid for all commands) + * - 3 = History queue */ typedef struct CF_QueueSelect_Payload { @@ -299,17 +303,17 @@ typedef struct CF_QueueSelect_Payload */ enum CF_GetSet_ValueID { - CF_GetSet_ValueID_ticks_per_second, /**< \brief Ticks per second key */ - CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup, /**< \brief Receive CRC calculated bytes per wake-up key */ - CF_GetSet_ValueID_ack_timer_s, /**< \brief ACK timer in seconds key */ - CF_GetSet_ValueID_nak_timer_s, /**< \brief NAK timer in seconds key */ - CF_GetSet_ValueID_inactivity_timer_s, /**< \brief Inactivity timer in seconds key */ - CF_GetSet_ValueID_outgoing_file_chunk_size, /**< \brief Outgoing file chunk size key */ - CF_GetSet_ValueID_ack_limit, /**< \brief ACK retry limit key */ - CF_GetSet_ValueID_nak_limit, /**< \brief NAK retry limit key */ - CF_GetSet_ValueID_local_eid, /**< \brief Local entity id key */ - CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup, /**< \brief Max outgoing messages per wake-up key */ - CF_GetSet_ValueID_MAX /**< \brief Key limit used for validity check */ + CF_GetSet_ValueID_ticks_per_second = 1, /**< \brief Ticks per second key */ + CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup = 2, /**< \brief Receive CRC calculated bytes per wake-up key */ + CF_GetSet_ValueID_ack_timer_s = 3, /**< \brief ACK timer in seconds key */ + CF_GetSet_ValueID_nak_timer_s = 4, /**< \brief NAK timer in seconds key */ + CF_GetSet_ValueID_inactivity_timer_s = 5, /**< \brief Inactivity timer in seconds key */ + CF_GetSet_ValueID_outgoing_file_chunk_size = 6, /**< \brief Outgoing file chunk size key */ + CF_GetSet_ValueID_ack_limit = 7, /**< \brief ACK retry limit key */ + CF_GetSet_ValueID_nak_limit = 8, /**< \brief NAK retry limit key */ + CF_GetSet_ValueID_local_eid = 9, /**< \brief Local entity id key */ + CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup = 10, /**< \brief Max outgoing messages per wake-up key */ + CF_GetSet_ValueID_MAX = 11 /**< \brief Key limit used for validity check */ }; /** @@ -352,7 +356,7 @@ typedef struct CF_SetParam_Payload typedef struct CF_TxFile_Payload { CF_CFDP_Class_Enum_t cfdp_class; /**< \brief CFDP class: 0=class 1, 1=class 2 */ - uint8 keep; /**< \brief Keep file flag: 1=keep, else delete */ + CF_EnableFlag_Enum_t keep; /**< \brief Keep file flag: 1=keep, else delete */ CF_ChannelSelect_t chan_num; /**< \brief Channel number */ uint8 priority; /**< \brief Priority: 0=highest priority */ CF_EntityId_t dest_id; /**< \brief Destination entity id */ @@ -367,10 +371,10 @@ typedef struct CF_TxFile_Payload */ typedef struct CF_WriteQueue_Payload { - CF_Type_Enum_t type; /**< \brief Transaction direction: all=0, up=1, down=2 */ - CF_ChannelSelect_t chan; /**< \brief Channel number */ - CF_QueueSelect_Enum_t queue; /**< \brief Queue type: 0=pending, 1=active, 2=history, 3=all */ - uint8 spare; /**< \brief Alignment spare, puts filename on 32-bit boundary */ + CF_DirectionType_Enum_t dir_type; /**< \brief Transaction direction: all=0, up=1, down=2 */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number */ + CF_QueueSelect_Enum_t queue; /**< \brief Queue type */ + uint8 spare; /**< \brief Alignment spare, puts filename on 32-bit boundary */ char filename[CF_FILENAME_MAX_LEN]; /**< \brief Filename written to */ } CF_WriteQueue_Payload_t; @@ -384,8 +388,10 @@ typedef struct CF_Transaction_Payload { CF_TransactionSeq_t ts; /**< \brief Transaction sequence number */ CF_EntityId_t eid; /**< \brief Entity id */ - CF_ChannelSelect_t chan_num; /**< \brief Channel number: 254=use ts, 255=all channels, else channel */ - uint8 spare[3]; /**< \brief Alignment spare for 32-bit multiple */ + CF_ChannelSelect_t chan_num; /**< \brief Channel number: 0=all channels, else 1-based channel */ + CF_EnableFlag_Enum_t + use_ts_eid; /**< \brief If true, apply to transactions matching ts+eid, else all transactions */ + uint8 spare[2]; /**< \brief Alignment spare for 32-bit multiple */ } CF_Transaction_Payload_t; /**\}*/ diff --git a/config/default_cf_tbldefs.h b/config/default_cf_tbldefs.h index 73f0801d..f428edd8 100644 --- a/config/default_cf_tbldefs.h +++ b/config/default_cf_tbldefs.h @@ -48,7 +48,7 @@ typedef struct CF_PollDir char src_dir[CF_FILENAME_MAX_PATH]; /**< \brief path to source dir */ char dst_dir[CF_FILENAME_MAX_PATH]; /**< \brief path to destination dir */ - uint8 enabled; /**< \brief Enabled flag */ + CF_EnableFlag_Enum_t enabled; /**< \brief Enabled flag */ } CF_PollDir_t; /** @@ -73,9 +73,9 @@ typedef struct CF_ChannelConfig CF_PollDir_t polldir[CF_MAX_POLLING_DIR_PER_CHAN]; /**< \brief Configuration for polled directories */ - char sem_name[OS_MAX_API_NAME]; /**< \brief name of throttling semaphore in TO */ - uint8 dequeue_enabled; /**< \brief if 1, then the channel will make pending transactions active */ - char move_dir[OS_MAX_PATH_LEN]; /**< \brief Move directory if not empty */ + char sem_name[OS_MAX_API_NAME]; /**< \brief name of throttling semaphore in TO */ + CF_EnableFlag_Enum_t dequeue_enabled; /**< \brief if 1, then the channel will make pending transactions active */ + char move_dir[OS_MAX_PATH_LEN]; /**< \brief Move directory if not empty */ } CF_ChannelConfig_t; /* diff --git a/config/eds_cf_extern_typedefs.h b/config/eds_cf_extern_typedefs.h index 374bb160..b71f7aa8 100644 --- a/config/eds_cf_extern_typedefs.h +++ b/config/eds_cf_extern_typedefs.h @@ -34,8 +34,16 @@ /* Define type mappings for CF-specific types */ -#define CF_QueueIdx_NUM (1 + EdsDataType_EdsEnum_CF_QueueIdx_t_MAX) -#define CF_GetSet_ValueID_MAX (1 + EdsDataType_EdsEnum_CF_GetSet_ValueID_t_MAX) +/* Define additional enum mappings based on EDS defines */ +/* This is done as an enum so these values have to be fixed integers */ +enum +{ + CF_QueueSelect_MAX = (1 + EdsDataType_EdsEnum_CF_QueueSelect_t_MAX), + CF_DirectionType_MAX = (1 + EdsDataType_EdsEnum_CF_DirectionType_t_MAX), + CF_QueueIdx_NUM = (1 + EdsDataType_EdsEnum_CF_QueueIdx_t_MAX), + CF_GetSet_ValueID_MAX = (1 + EdsDataType_EdsEnum_CF_GetSet_ValueID_t_MAX), + CF_Reset_MAX = (1 + EdsDataType_EdsEnum_CF_Reset_t_MAX), +}; typedef EdsDataType_CF_EntityId_t CF_EntityId_t; typedef EdsDataType_CF_TransactionSeq_t CF_TransactionSeq_t; diff --git a/eds/cf.xml b/eds/cf.xml index 1361548e..c2c64acd 100644 --- a/eds/cf.xml +++ b/eds/cf.xml @@ -89,10 +89,10 @@ - - - - + + + + @@ -111,23 +111,23 @@ CF_SetParamCmd_t message structures. - - - - - - - - - - + + + + + + + + + + - + @@ -207,7 +207,7 @@ - + @@ -224,9 +224,9 @@ - - - + + @@ -238,16 +238,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -348,8 +348,8 @@ Single byte channel selector payload - - 255 = all channels - - else = single channel + - 0 = unspecified / all channels + - else = single channel, 1-based @@ -361,12 +361,12 @@ Polling directory selector payload Single byte channel selector - - 255 = all channels - - else = single channel + - 0 = unspecified / all channels + - else = single channel, 1-based Single byte polling directory index - - 255 = all polling directories - - else = single polling directory index + - 0 = unspecified / all polling directories + - else = single polling directory index, 1-based @@ -376,17 +376,14 @@ - Queue selector payload + Queue selector payload - Single byte channel selector - - 255 = all channels - - else = single channel + Single byte channel selector + - 0 = unspecified / all channels + - else = single channel, 1-based - Single byte queue selection enum + Single byte queue selection enum Values indicated by #CF_QueueSelect enum - - 0 = Pending queue - - 1 = History queue - - 2 = Both pending and history queue @@ -422,7 +419,7 @@ - + @@ -431,22 +428,12 @@ - - - - - - - - - - - - - + + + @@ -454,10 +441,11 @@ - - - - + + + + + @@ -720,7 +708,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - Already in requested state, #CF_CMD_SUSPRES_SAME_ERR_EID - No matching transaction, #CF_CMD_SUSPRES_CHAN_ERR_EID @@ -763,7 +751,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - Already in requested state, #CF_CMD_SUSPRES_SAME_ERR_EID - No matching transaction, #CF_CMD_SUSPRES_CHAN_ERR_EID @@ -805,7 +793,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - No matching transaction, #CF_CMD_CANCEL_CHAN_ERR_EID \par Evidence of failure may be found in the following telemetry: @@ -846,7 +834,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - No matching transaction, #CF_CMD_ABANDON_CHAN_ERR_EID \par Evidence of failure may be found in the following telemetry: @@ -885,7 +873,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Invalid configuration parameter key, #CF_CMD_GETSET_PARAM_ERR_EID - - Invalid channel number, #CF_CMD_GETSET_CHAN_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - Parameter value failed validation, #CF_CMD_GETSET_VALIDATE_ERR_EID \par Evidence of failure may be found in the following telemetry: @@ -924,7 +912,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Invalid configuration parameter key, #CF_CMD_GETSET_PARAM_ERR_EID - - Invalid channel number, #CF_CMD_GETSET_CHAN_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID \par Evidence of failure may be found in the following telemetry: - #CF_HkPacket_t.counters #CF_HkCmdCounters_t.err will increment @@ -962,7 +950,7 @@ This command may fail for the following reason(s): - Command packet length not as expected, #CF_CMD_LEN_ERR_EID - Invalid parameter combination, #CF_CMD_WQ_ARGS_ERR_EID - - Invalid channel number, #CF_CMD_WQ_CHAN_ERR_EID + - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID - Open file to write failed, #CF_CMD_WQ_OPEN_ERR_EID - Write RX data failed, #CF_CMD_WQ_WRITEQ_RX_ERR_EID - Write RX history data failed, #CF_CMD_WQ_WRITEHIST_RX_ERR_EID diff --git a/fsw/inc/cf_eventids.h b/fsw/inc/cf_eventids.h index c37fbe9f..6f2b10e9 100644 --- a/fsw/inc/cf_eventids.h +++ b/fsw/inc/cf_eventids.h @@ -1170,16 +1170,10 @@ */ #define CF_CMD_TRANS_NOT_FOUND_ERR_EID 131 -/** - * \brief CF Command All Transaction Channel Invalid Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * Command received to act on all transactions with invalid channel +/* + * Note: CF_CMD_TSN_CHAN_INVALID_ERR_EID (132) removed, now uses + * common handling and sends CF_CMD_CHAN_PARAM_ERR_EID */ -#define CF_CMD_TSN_CHAN_INVALID_ERR_EID 132 /** * \brief CF Suspend/Resume Command For Single Transaction State Unchanged Event ID @@ -1225,16 +1219,10 @@ */ #define CF_CMD_PURGE_ARG_ERR_EID 136 -/** - * \brief CF Write Queue Command Invalid Channel Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * Write Queue command received with invalid channel argument +/* + * Note: CF_CMD_WQ_CHAN_ERR_EID (137) removed, now uses + * common handling and sends CF_CMD_CHAN_PARAM_ERR_EID */ -#define CF_CMD_WQ_CHAN_ERR_EID 137 /** * \brief CF Write Queue Command Invalid Queue Event ID @@ -1335,16 +1323,10 @@ */ #define CF_CMD_GETSET_PARAM_ERR_EID 146 -/** - * \brief CF Set/Get Parameter Command Invalid Channel Event ID - * - * \par Type: ERROR - * - * \par Cause: - * - * Invalid channel value received in set or get parameter command +/* + * Note: CF_CMD_GETSET_CHAN_ERR_EID (147) removed, now uses + * common handling and sends CF_CMD_CHAN_PARAM_ERR_EID */ -#define CF_CMD_GETSET_CHAN_ERR_EID 147 /** * \brief CF Enable Engine Command Failed Event ID diff --git a/fsw/inc/cf_fcncodes.h b/fsw/inc/cf_fcncodes.h index 3aa298b5..e3c3a3ce 100644 --- a/fsw/inc/cf_fcncodes.h +++ b/fsw/inc/cf_fcncodes.h @@ -255,7 +255,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - * - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - No matching transaction, #CF_CMD_SUSPRES_CHAN_ERR_EID * * \par Evidence of failure may be found in the following telemetry: @@ -291,7 +291,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - * - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - No matching transaction, #CF_CMD_SUSPRES_CHAN_ERR_EID * * \par Evidence of failure may be found in the following telemetry: @@ -325,7 +325,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - * - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - No matching transaction, #CF_CMD_CANCEL_CHAN_ERR_EID * * \par Evidence of failure may be found in the following telemetry: @@ -359,7 +359,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Transaction not found using compound key, #CF_CMD_TRANS_NOT_FOUND_ERR_EID - * - Invalid channel number, #CF_CMD_TSN_CHAN_INVALID_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - No matching transaction, #CF_CMD_ABANDON_CHAN_ERR_EID * * \par Evidence of failure may be found in the following telemetry: @@ -391,7 +391,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Invalid configuration parameter key, #CF_CMD_GETSET_PARAM_ERR_EID - * - Invalid channel number, #CF_CMD_GETSET_CHAN_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - Parameter value failed validation, #CF_CMD_GETSET_VALIDATE_ERR_EID * * \par Evidence of failure may be found in the following telemetry: @@ -423,7 +423,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Invalid configuration parameter key, #CF_CMD_GETSET_PARAM_ERR_EID - * - Invalid channel number, #CF_CMD_GETSET_CHAN_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * * \par Evidence of failure may be found in the following telemetry: * - #CF_HkPacket_Payload_t.counters #CF_HkCmdCounters_t.err will increment @@ -454,7 +454,7 @@ * This command may fail for the following reason(s): * - Command packet length not as expected, #CF_CMD_LEN_ERR_EID * - Invalid parameter combination, #CF_CMD_WQ_ARGS_ERR_EID - * - Invalid channel number, #CF_CMD_WQ_CHAN_ERR_EID + * - Invalid channel number, #CF_CMD_CHAN_PARAM_ERR_EID * - Open file to write failed, #CF_CMD_WQ_OPEN_ERR_EID * - Write RX data failed, #CF_CMD_WQ_WRITEQ_RX_ERR_EID * - Write RX history data failed, #CF_CMD_WQ_WRITEHIST_RX_ERR_EID diff --git a/fsw/src/cf_app.c b/fsw/src/cf_app.c index d7468faf..da01c77e 100644 --- a/fsw/src/cf_app.c +++ b/fsw/src/cf_app.c @@ -50,8 +50,8 @@ CF_AppData_t CF_AppData; static int32 CF_DoChannelConfig(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) { const CF_ConfigTable_t *config = arg; - const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); - const CF_ChannelConfig_t *chan_config = &config->chan[chan_num]; + const int chan_idx = CF_ChannelSelect_AsIndex(CF_GetChannelFromPtr(chan)); + const CF_ChannelConfig_t *chan_config = &config->chan[chan_idx]; const CF_PollDir_t *tbl_pd_config; CF_LocalPdConfig_t *pd_config; int pd; diff --git a/fsw/src/cf_app.h b/fsw/src/cf_app.h index d8b97357..3b8ba692 100644 --- a/fsw/src/cf_app.h +++ b/fsw/src/cf_app.h @@ -165,80 +165,80 @@ static inline bool CF_IsValidClass(CF_CFDP_Class_Enum_t cv) */ static inline bool CF_IsValidChannel(CF_ChannelSelect_t cs) { - return (cs < CF_NUM_CHANNELS); + return (cs > 0 && cs <= CF_NUM_CHANNELS); } /************************************************************************/ /** - * @brief Checks if a channel identifier represents "all channels" + * @brief Gets the channel number as an integer * * @par Description - * checks if the given channel number matches the special all channels value + * For consistent representation of channel numbers in logs messages + * and other strings. * * @par Assumptions, External Events, and Notes: - * This only checks if it matches all channels. + * Format log messages with printf "%d" conversion * - * @retval true if value is valid/acceptable - * @retval false if value is invalid + * @returns channel number represented as "int" type */ -static inline bool CF_IsAllChannels(CF_ChannelSelect_t cs) +static inline int CF_ChannelSelect_AsInt(CF_ChannelSelect_t cs) { - return (cs == CF_ALL_CHANNELS); + return (cs); } /************************************************************************/ /** - * @brief Checks if a channel identifier represents "all channels" + * @brief Gets the channel number as an array index (0-based) * * @par Description - * checks if the given channel number matches the special all channels value + * For use when indexing the channel number in a another array such + * as configuration tables or performance logs, requiriing a 0-based index. * * @par Assumptions, External Events, and Notes: - * This only checks if it matches all channels. + * Format log messages with printf "%d" conversion * - * @retval true if value is valid/acceptable - * @retval false if value is invalid + * @returns channel number represented as "int" type */ -static inline bool CF_IsCompoundKey(CF_ChannelSelect_t cs) +static inline int CF_ChannelSelect_AsIndex(CF_ChannelSelect_t cs) { - return (cs == CF_COMPOUND_KEY); + return CF_ChannelSelect_AsInt(cs) - 1; } /************************************************************************/ /** - * @brief Gets the channel number as an integer + * @brief Gets the channel number from integer * * @par Description - * For consistent representation of channel numbers in logs messages - * and other strings. + * For intentional conversion from an integer value to a channel number * * @par Assumptions, External Events, and Notes: - * Format log messages with printf "%d" conversion + * this exists for special/corner cases only, should really not be + * needed in general. Prefer to use the APIs that invoke a subroutine + * using the standard selector logic. * - * @returns channel number represented as "int" type + * @returns channel number value */ -static inline int CF_ChannelSelect_AsInt(CF_ChannelSelect_t cs) +static inline CF_ChannelSelect_t CF_ChannelSelect_FromInt(int c) { - return (cs); + return (CF_ChannelSelect_t) { c }; } /************************************************************************/ /** - * @brief Gets the channel number from integer + * @brief Checks if a channel identifier represents "all channels" * * @par Description - * For intentional conversion from an integer value to a channel number + * checks if the given channel number matches the special all channels value * * @par Assumptions, External Events, and Notes: - * this exists for special/corner cases only, should really not be - * needed in general. Prefer to use the APIs that invoke a subroutine - * using the standard selector logic. + * This only checks if it matches all channels. * - * @returns channel number value + * @retval true if value is valid/acceptable + * @retval false if value is invalid */ -static inline CF_ChannelSelect_t CF_ChannelSelect_FromInt(int c) +static inline bool CF_IsAllChannels(CF_ChannelSelect_t cs) { - return (c); + return (cs == CF_ALL_CHANNELS); } /************************************************************************/ @@ -258,7 +258,8 @@ static inline CF_Channel_t *CF_GetChannelPtr(CF_ChannelSelect_t cs) { if (CF_IsValidChannel(cs)) { - return &CF_GetEngine()->channels[cs]; + /* the channel value from user interface should be 1-based */ + return &CF_GetEngine()->channels[CF_ChannelSelect_AsIndex(cs)]; } else { @@ -281,7 +282,8 @@ static inline CF_Channel_t *CF_GetChannelPtr(CF_ChannelSelect_t cs) static inline CF_ChannelSelect_t CF_GetChannelFromPtr(const CF_Channel_t *ChanPtr) { CF_Engine_t *engine_ptr = CF_GetEngine(); - return (CF_ChannelSelect_t) { (ChanPtr - engine_ptr->channels) }; + /* the channel value to user interface should be 1-based */ + return (CF_ChannelSelect_t) { 1 + (ChanPtr - engine_ptr->channels) }; } /************************************************************************/ diff --git a/fsw/src/cf_cfdp.c b/fsw/src/cf_cfdp.c index 8c216dc8..bb56fa41 100644 --- a/fsw/src/cf_cfdp.c +++ b/fsw/src/cf_cfdp.c @@ -1257,7 +1257,7 @@ static int32 CF_CFDP_DoEngineChannelInit(CF_Engine_t *engine_ptr, CF_Channel_t * CF_CListNode_t **list_head; int j; int k; - const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); + const int chan_idx = CF_ChannelSelect_AsIndex(CF_GetChannelFromPtr(chan)); char nbuf[64]; CFE_Status_t ret = CFE_SUCCESS; @@ -1273,7 +1273,7 @@ static int32 CF_CFDP_DoEngineChannelInit(CF_Engine_t *engine_ptr, CF_Channel_t * chan->sem_id = OS_OBJECT_ID_UNDEFINED; chan->tick_resume = NULL; - snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, chan_num); + snprintf(nbuf, sizeof(nbuf) - 1, "%s%d", CF_CHANNEL_PIPE_PREFIX, chan_idx); ret = CFE_SB_CreatePipe(&chan->pipe, chan->config.pipe_depth_input, nbuf); if (ret != CFE_SUCCESS) { @@ -1342,9 +1342,9 @@ static int32 CF_CFDP_DoEngineChannelInit(CF_Engine_t *engine_ptr, CF_Channel_t * list_head = CF_GetChunkListHead(chan, k); CF_ChunkListInit(&state->cw->chunks, - CF_DIR_MAX_CHUNKS[k][chan_num], + CF_DIR_MAX_CHUNKS[k][chan_idx], &engine_ptr->chunk_mem[state->chunk_mem_offset]); - state->chunk_mem_offset += CF_DIR_MAX_CHUNKS[k][chan_num]; + state->chunk_mem_offset += CF_DIR_MAX_CHUNKS[k][chan_idx]; CF_CList_InitNode(&state->cw->cl_node); CF_CList_InsertBack(list_head, &state->cw->cl_node); @@ -1417,7 +1417,7 @@ CFE_Status_t CF_CFDP_InitEngine(CF_Engine_t *engine_ptr) static void CF_CFDP_S_Tick_SendFileData(CF_Transaction_t *txn) { CF_Channel_t *chan = CF_GetChannelFromTxn(txn); - const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); /* for perf log */ + const int chan_idx = CF_ChannelSelect_AsIndex(CF_GetChannelFromPtr(chan)); /* for perf log */ uint32 last_outgoing_counter; CF_Assert(chan); @@ -1441,9 +1441,9 @@ static void CF_CFDP_S_Tick_SendFileData(CF_Transaction_t *txn) { last_outgoing_counter = chan->stat.outgoing_counter; - CFE_ES_PerfLogEntry(CF_PERF_ID_PDUSENT(chan_num)); + CFE_ES_PerfLogEntry(CF_PERF_ID_PDUSENT(chan_idx)); CF_CFDP_S_SubstateSendFileData(txn); - CFE_ES_PerfLogExit(CF_PERF_ID_PDUSENT(chan_num)); + CFE_ES_PerfLogExit(CF_PERF_ID_PDUSENT(chan_idx)); } while (last_outgoing_counter != chan->stat.outgoing_counter); } @@ -2297,7 +2297,7 @@ void CF_CFDP_SendEotPkt(CF_Transaction_t *txn) CFE_MSG_Init(CFE_MSG_PTR(EotPktPtr->TelemetryHeader), CFE_SB_ValueToMsgId(CF_EOT_TLM_MID), sizeof(*EotPktPtr)); - EotPktPtr->Payload.channel = CF_GetChannelFromPtr(CF_GetChannelFromTxn(txn)); + EotPktPtr->Payload.channel = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(CF_GetChannelFromTxn(txn))); EotPktPtr->Payload.direction = txn->history->dir; EotPktPtr->Payload.fnames = txn->history->fnames; EotPktPtr->Payload.state = txn->state; diff --git a/fsw/src/cf_cfdp_sbintf.c b/fsw/src/cf_cfdp_sbintf.c index 190cca15..c51f64a9 100644 --- a/fsw/src/cf_cfdp_sbintf.c +++ b/fsw/src/cf_cfdp_sbintf.c @@ -186,7 +186,7 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) { uint32 count = 0; int32 status; - const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); /* for perf log */ + const int chan_idx = CF_ChannelSelect_AsIndex(CF_GetChannelFromPtr(chan)); /* for perf log */ CFE_SB_Buffer_t *bufptr; CFE_MSG_Size_t msg_size; CFE_MSG_Type_t msg_type; @@ -205,7 +205,7 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) } ph = &engine_ptr->in.rx_pdudata; - CFE_ES_PerfLogEntry(CF_PERF_ID_PDURCVD(chan_num)); + CFE_ES_PerfLogEntry(CF_PERF_ID_PDURCVD(chan_idx)); CFE_MSG_GetSize(&bufptr->Msg, &msg_size); CFE_MSG_GetType(&bufptr->Msg, &msg_type); if (msg_size > CF_PDU_ENCAPSULATION_EXTRA_TRAILING_BYTES) @@ -230,6 +230,6 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) /* Identify and dispatch this PDU */ CF_CFDP_ReceivePdu(chan, ph); - CFE_ES_PerfLogExit(CF_PERF_ID_PDURCVD(chan_num)); + CFE_ES_PerfLogExit(CF_PERF_ID_PDURCVD(chan_idx)); } } diff --git a/fsw/src/cf_cmd.c b/fsw/src/cf_cmd.c index 742bee87..449240dd 100644 --- a/fsw/src/cf_cmd.c +++ b/fsw/src/cf_cmd.c @@ -39,66 +39,494 @@ #include -/* Helper struct for CF_DoChanAction() */ -typedef struct CF_ChanActionContext +/** + * Type used for dispatch table in generic handlers + * + * Currently this is always just a function pointer, but + * is declared as a union to permit other items in future use + */ +typedef union CF_GenericAction_TableEntry +{ + CF_GenericAction_Func_t fn; /**< Implementation to execute for this table entry */ + const void *object; /**< Generic Pointer to data object */ + +} CF_GenericAction_TableEntry_t; + +/** + * Helper functions for generic actions + * + * This defines _how_ to process the matched entry in the dispatch table + * If the entry is a function pointer, it may invoke the function, or if + * the entry is a data object it may call some other routine using + * that object. + * + * The chan pointer is passed through from the initial loop + * of applicable channels (e.g. when CF_ForEachChannel() is used) + * + * @param entry the dispatcher table entry + * @param ga pointer to the (base) context struct + * @param chan CFDP channel - passed through to function + * + * @returns CFE Status code. If an error is returned, dispatching will stop + * @retval #CFE_SUCCESS in normal operation, will continue dispatching + */ +typedef CFE_Status_t (*CF_GenericAction_HelperFn_t)(CF_GenericAction_TableEntry_t entry, + CF_GenericAction_Context_t *ga, + CF_Channel_t *chan); + +/** + * Intermediate context struct for use with CF_ForEachChannel() + * + * When operating across multiple channels via CF_ForEachChannel(), this + * stores the original callback and context, and a local intermediate function + * is used as the direct callback. This intermediate function then calls + * the originally-requested callback with the original context, combined + * with the channel pointer. + */ +typedef struct CF_ActionContext_FEC +{ + uint32 match_count; + CF_GenericAction_Func_t fn; + CF_GenericAction_Context_t *context; +} CF_ActionContext_FEC_t; + +/** + * Context object for use when matching transaction-based commands + * + * This is used for commands that operate on a transaction, via the #CF_Transaction_Payload_t + * command structure. The normal channel loop is combined with CF_TraverseAllTransactions() + * on each channel to find the applicable transaction(s). + */ +typedef struct +{ + CF_GenericAction_Context_t ga; + + CF_TraverseAllTransactions_fn_t action_cb; + void *action_arg; + + /* original params from request */ + bool use_ts_eid; + + CF_TransactionSeq_t ts; + CF_EntityId_t eid; + +} CF_GenericAction_TxnContext_t; + +/** + * Context object used with ResetCounters command + */ +typedef struct CF_DoResetFault_Context +{ + CF_GenericAction_Context_t ga; /* always first */ + + /* original params from request */ + CF_Reset_Enum_t user_resetsel; + +} CF_DoResetFault_Context_t; + +/** + * Context object used with WriteQueue command + */ +typedef struct CF_WriteQueue_FullContext +{ + CF_GenericAction_Context_t ga; /* always first */ + + /* file descriptor to write queue data to */ + osal_id_t fd; + + /* original params from request */ + CF_QueueSelect_Enum_t user_qsel; + CF_DirectionType_Enum_t user_dirsel; + +} CF_WriteQueue_FullContext_t; + +/** + * Intermediate context object used with WriteQueue command + * + * The write queue command dispatches on both queue type and direction + * The direction is dispatched first. This captures the original request + * info so that the direction handler can invoke the queue handler. + */ +typedef struct CF_WriteQueue_DirContext +{ + CF_GenericAction_Context_t ga; /* always first */ + CF_GenericAction_HelperFn_t q_action; /* next action (for queues) */ + CF_WriteQueue_FullContext_t *ctxt; +} CF_WriteQueue_DirContext_t; + +/** + * A context object used with purge queue commands + */ +typedef struct CF_DoPurgeQueue_Context +{ + CF_GenericAction_Context_t ga; /* always first */ + + /* original params from request */ + CF_QueueSelect_Enum_t user_qsel; + +} CF_DoPurgeQueue_Context_t; + +/** + * A context object used with actions requiring only a boolean argument + * + * This combines a boolean value with an output that indicates if it + * was a change or not. + */ +typedef struct CF_GenericAction_BoolArg +{ + CF_GenericAction_Context_t ga; /* always first */ + + bool barg; /* desired value to set in matched field(s) */ + uint32 noop_count; /* count where the requested value was already set, resulting in no change */ + +} CF_GenericAction_BoolArg_t; + +/** + * A context object used with enable/disable polling dir commands + */ +typedef struct CF_EnableDisablePollDir_Context +{ + CF_GenericAction_BoolArg_t barg; /* always first */ + + /* original params from request */ + CF_PollIdxSelect_t user_pollidx; + +} CF_EnableDisablePollDir_Context_t; + +/** + * A context object used with get/set parameter commands + */ +typedef struct CF_GetSetParam_Context { - CF_ChanAction_Status_t ret; - CF_ChanActionFn_t fn; - void *context; -} CF_ChanActionContext_t; + CF_GenericAction_Context_t ga; /* always first */ + + /* original params from request */ + bool is_set; + CF_GetSet_ValueID_t param_id; + uint32 value; + +} CF_GetSetParam_Context_t; /*---------------------------------------------------------------- * - * Local Helper Function, compatible with CF_ForEachChannel() - * Resets fault counters + * Local action helper function + * + * This does not invoke the action. It just checks if the action entry is + * valid, and increments the valid count. + * + * This is intended for pre-validating a command before doing any more + * expensive work. The ValidCount should be nonzero after using this. * *-----------------------------------------------------------------*/ -static int32 CF_DoResetFaultCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +static CFE_Status_t +CF_GenericAction_DoCheck(CF_GenericAction_TableEntry_t entry, CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - memset(&chan->stat.counters.fault, 0, sizeof(chan->stat.counters.fault)); + if (entry.fn != NULL) + { + /* this matched a valid action, increment the count */ + ++ga->ValidCount; + } + return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Local Helper Function, compatible with CF_ForEachChannel() - * Resets up counters + * Local helper function + * invokes the action entry for each valid entry + * at this stage empty entries are considered a no-op (successful) * *-----------------------------------------------------------------*/ -static int32 CF_DoResetUpCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +static CFE_Status_t +CF_GenericAction_DoInvokeAction(CF_GenericAction_TableEntry_t entry, CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - memset(&chan->stat.counters.recv, 0, sizeof(chan->stat.counters.recv)); - return CFE_SUCCESS; + CFE_Status_t ret; + + if (entry.fn == NULL) + { + /* + * note: if no-ops are considered an error, then CF_GenericAction_DoCheck() should + * be used to validate the request first. At this stage empty entries are benign. + */ + ret = CFE_SUCCESS; + } + else + { + ret = entry.fn(ga, chan); + if (ret == CFE_SUCCESS) + { + /* this count shows _real_ (non-noop) callbacks that returned success */ + ++ga->SuccessCount; + } + } + + return ret; } /*---------------------------------------------------------------- * - * Local Helper Function, compatible with CF_ForEachChannel() - * Resets down counters + * Local helper function + * Allows a generic action to be invoked through CF_ForEachChannel() * *-----------------------------------------------------------------*/ -static int32 CF_DoResetDownCount(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +static CFE_Status_t CF_GenericAction_DoChannel(CF_Engine_t *engine, CF_Channel_t *chan, void *arg) { - memset(&chan->stat.counters.sent, 0, sizeof(chan->stat.counters.sent)); + CF_ActionContext_FEC_t *dca_ctxt = arg; + + if (chan != NULL) + { + /* execute action operations on this channel, using original values */ + ++dca_ctxt->match_count; + dca_ctxt->fn(dca_ctxt->context, chan); + } + return CFE_SUCCESS; } /*---------------------------------------------------------------- * * Local helper function - * Invokes the requested action on a single channel - * compatible with CF_ForEachChannel() + * Call the handler function for every matched channel + * Returns the number of channels called + * + *-----------------------------------------------------------------*/ +static uint32 CF_GenericAction_DispatchChannel(CF_GenericAction_Func_t func, + CF_GenericAction_Context_t *context, + CF_ChannelSelect_t chan_select) +{ + CF_ActionContext_FEC_t dca_ctxt; + + memset(&dca_ctxt, 0, sizeof(dca_ctxt)); + + dca_ctxt.fn = func; + dca_ctxt.context = context; + + /* + * Currently this is a singleton so its always the same. + * If that ever changes this should be passed in indicating + * the CFDP engine to operate on. + */ + context->engine = CF_GetEngine(); + + /* this function is generic for any ground command that takes a single channel + * argument which must be less than CF_NUM_CHANNELS or 255 which is a special + * value that means apply command to all channels */ + if (CF_IsAllChannels(chan_select)) + { + /* apply to all channels */ + CF_ForEachChannel(context->engine, CF_GenericAction_DoChannel, &dca_ctxt); + } + else + { + /* apply to only the specified channel number */ + CF_GenericAction_DoChannel(context->engine, CF_GetChannelPtr(chan_select), &dca_ctxt); + } + + /* if successful, return a positive channel count match */ + return dca_ctxt.match_count; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * + * Same as CF_GenericAction_DispatchChannel() but sends an event if + * no channels were match in the process, meaning that the user-supplied + * channel number was invalid. The CF_CMD_CHAN_PARAM_ERR_EID event + * is generated in this case. + * + *-----------------------------------------------------------------*/ +static int32 CF_GenericAction_CheckAndDispatchChannel(const char *action_str, + CF_GenericAction_Func_t func, + CF_GenericAction_Context_t *context, + CF_ChannelSelect_t chan_select) +{ + int32 count; + + count = CF_GenericAction_DispatchChannel(func, context, chan_select); + + if (count == 0) + { + /* no channels were matched by the chan_select parameter */ + CFE_EVS_SendEvent(CF_CMD_CHAN_PARAM_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: %s: channel parameter out of range (%d)", + action_str, + CF_ChannelSelect_AsInt(chan_select)); + } + + return count; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Dispatch a generic action using common selector patterns. + * + * If the user selection is 0, treat it as "all" and loop through + * all entries in the map. Otherwise invoke the single specified + * handler from the map, or no handler at all if the selector was + * out of range. + * + * NOTE: the action in the map is not _directly_ invoked here. Rather, + * the given helper function is invoked with the map entry as a parameter. + * The action helper may choose to call the routine or do something else + * like count it. + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_GenericAction_DoDispatch(CF_GenericAction_Context_t *ga, + CF_GenericAction_HelperFn_t act_helper, + const CF_GenericAction_TableEntry_t *map_baseptr, + size_t map_size, + uint32 selector, + CF_Channel_t *chan) +{ + const CF_GenericAction_TableEntry_t *MapCurrPtr; + uint32 NumEntries; + CFE_Status_t ret; + + NumEntries = map_size / sizeof(*map_baseptr); + MapCurrPtr = map_baseptr; + ret = CFE_STATUS_RANGE_ERROR; + + if (selector != 0) + { + if (selector < NumEntries) + { + /* do just a single entry */ + MapCurrPtr += selector; + NumEntries = 1; + } + else + { + NumEntries = 0; + } + } + + while (NumEntries > 0) + { + ++ga->TotalCount; + ret = act_helper(*MapCurrPtr, ga, chan); + if (ret != CFE_SUCCESS) + { + break; + } + + ++MapCurrPtr; + --NumEntries; + } + + return ret; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Sets a single boolean while also checking if it was already set to the same value + * + *-----------------------------------------------------------------*/ +static void CF_GenericAction_DoSetBoolArg(CF_GenericAction_BoolArg_t *barg, bool *ref) +{ + ++barg->ga.TotalCount; + if (*ref == barg->barg) + { + /* it was already set to the requested value, nothing changed */ + ++barg->noop_count; + } + else + { + *ref = barg->barg; + } +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Invokes per-transaction callback + * + * This is an intermediate routine compatible with CF_TraverseAllTransactions() + * + *-----------------------------------------------------------------*/ +static void CF_GenericAction_DoSingleTxnActionImpl(CF_Transaction_t *txn, void *arg) +{ + CF_GenericAction_TxnContext_t *ctxt = arg; + + ++ctxt->ga.ValidCount; + ctxt->action_cb(txn, ctxt->action_arg); +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Finds a transaction by sequence and entity id * *-----------------------------------------------------------------*/ -static int32 CF_DoSingleChannelAction(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +CFE_Status_t CF_GenericAction_FindTxnActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanActionContext_t *ctxt = arg; + CF_GenericAction_TxnContext_t *ctxt = (CF_GenericAction_TxnContext_t *)ga; + CF_Transaction_t *txn; - ctxt->ret |= ctxt->fn(chan, ctxt->context); + if (ctxt->use_ts_eid) + { + /* perform action only on matching ts+eid */ + txn = CF_FindTransactionBySequenceNumber(chan, ctxt->ts, ctxt->eid); + if (txn != NULL) + { + /* got a match */ + CF_GenericAction_DoSingleTxnActionImpl(txn, ga); + } + } + else + { + /* perform action on this channel, all transactions */ + CF_TraverseAllTransactions(chan, CF_GenericAction_DoSingleTxnActionImpl, ga); + } return CFE_SUCCESS; } +/*---------------------------------------------------------------- + * + * Local helper function + * Common handler for routines that operate on a transaction + * + *-----------------------------------------------------------------*/ +int32 CF_GenericAction_CheckAndDispatchTxn(const char *action_str, + const CF_Transaction_Payload_t *data, + CF_TraverseAllTransactions_fn_t fn, + void *arg) +{ + CF_GenericAction_TxnContext_t ctxt; + int32 count; + + memset(&ctxt, 0, sizeof(ctxt)); + + ctxt.action_cb = fn; + ctxt.action_arg = arg; + ctxt.use_ts_eid = data->use_ts_eid; + ctxt.eid = data->eid; + ctxt.ts = data->ts; + + /* First dispatch based on chan_num like all other ops do */ + count = CF_GenericAction_CheckAndDispatchChannel(action_str, + CF_GenericAction_FindTxnActionImpl, + &ctxt.ga, + data->chan_num); + + if (count != 0 && ctxt.use_ts_eid && ctxt.ga.ValidCount == 0) + { + CFE_EVS_SendEvent(CF_CMD_TRANS_NOT_FOUND_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: %s cmd: failed to find transaction for (eid %lu, ts %lu)", + action_str, + (unsigned long)data->eid, + (unsigned long)data->ts); + } + + /* this should reflect the matched transaction count */ + return ctxt.ga.ValidCount; +} + /*---------------------------------------------------------------- * * Application-scope internal function @@ -120,21 +548,116 @@ CFE_Status_t CF_NoopCmd(const CF_NoopCmd_t *msg) return CFE_SUCCESS; } +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with generic action dispatch table + * Resets command counters + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ResetCounters_DoResetCommandCount(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with generic action dispatch table + * Resets fault counters + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ResetCounters_DoResetFaultCount(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + memset(&chan->stat.counters.fault, 0, sizeof(chan->stat.counters.fault)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with generic action dispatch table + * Resets up (rx) counters + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ResetCounters_DoResetUpCount(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + memset(&chan->stat.counters.recv, 0, sizeof(chan->stat.counters.recv)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with generic action dispatch table + * Resets down (tx) counters + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ResetCounters_DoResetDownCount(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + memset(&chan->stat.counters.sent, 0, sizeof(chan->stat.counters.sent)); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper Function + * Dispatches action for Reset counters command + * + *-----------------------------------------------------------------*/ +static CFE_Status_t +CF_ResetCounters_Dispatch(CF_DoResetFault_Context_t *ctxt, CF_GenericAction_HelperFn_t act_helper, CF_Channel_t *chan) +{ + static const CF_GenericAction_TableEntry_t CF_RESETCOUNTER_HANDLER_MAP[CF_Reset_MAX] = { + [CF_Reset_command] = { CF_ResetCounters_DoResetCommandCount }, + [CF_Reset_fault] = { CF_ResetCounters_DoResetFaultCount }, + [CF_Reset_up] = { CF_ResetCounters_DoResetUpCount }, + [CF_Reset_down] = { CF_ResetCounters_DoResetDownCount }, + }; + + return CF_GenericAction_DoDispatch(&ctxt->ga, + act_helper, + CF_RESETCOUNTER_HANDLER_MAP, + sizeof(CF_RESETCOUNTER_HANDLER_MAP), + ctxt->user_resetsel, + chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper Function, compatible with CF_ForEachChannel() + * Resets down counters + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_ResetCounters_ChanActionImpl(CF_Engine_t *engine, CF_Channel_t *chan, void *arg) +{ + return CF_ResetCounters_Dispatch(arg, CF_GenericAction_DoInvokeAction, chan); +} + /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_ResetCountersCmd(const CF_ResetCountersCmd_t *msg) { - const CF_ResetCountersCmd_Payload_t *data = &msg->Payload; - static const char *names[5] = { "all", "cmd", "fault", "up", "down" }; - /* 0=all, 1=cmd, 2=fault 3=up 4=down */ - bool acc = true; - CF_Engine_t *engine_ptr = CF_GetEngine(); + const CF_ResetCountersCmd_Payload_t *data = &msg->Payload; + CF_DoResetFault_Context_t ctxt; - if (data->ResetType > 4) + static const char *names[CF_Reset_MAX] = { [CF_Reset_all] = "all", + [CF_Reset_command] = "cmd", + [CF_Reset_fault] = "fault", + [CF_Reset_up] = "up", + [CF_Reset_down] = "down" }; + + memset(&ctxt, 0, sizeof(ctxt)); + + ctxt.user_resetsel = data->ResetType; + + /* checking the validity of parameters first. if something is bad + * we should do nothing at all and send the error event */ + CF_ResetCounters_Dispatch(&ctxt, CF_GenericAction_DoCheck, NULL); + + if (ctxt.ga.ValidCount == 0) { CFE_EVS_SendEvent(CF_CMD_RESET_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, @@ -149,39 +672,11 @@ CFE_Status_t CF_ResetCountersCmd(const CF_ResetCountersCmd_t *msg) "CF: Received RESET COUNTERS command: %s", names[data->ResetType]); - /* if the param is CF_Reset_command, or all counters */ - if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_command)) - { - /* command counters */ - memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); - acc = false; /* don't increment accept counter on command counter reset */ - } - - /* if the param is CF_Reset_fault, or all counters */ - if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_fault)) - { - /* fault counters */ - CF_ForEachChannel(engine_ptr, CF_DoResetFaultCount, NULL); - } - - /* if the param is CF_Reset_up, or all counters */ - if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_up)) - { - /* up counters */ - CF_ForEachChannel(engine_ptr, CF_DoResetUpCount, NULL); - } - - /* if the param is CF_Reset_down, or all counters */ - if ((data->ResetType == CF_Reset_all) || (data->ResetType == CF_Reset_down)) - { - /* down counters */ - CF_ForEachChannel(engine_ptr, CF_DoResetDownCount, NULL); - } + /* Incrementing the command counter FIRST -- this way, if the reset includes + * the command counter, then it will be left at 0 rather than 1. */ + ++CF_AppData.counters.cmd; - if (acc) - { - ++CF_AppData.counters.cmd; - } + CF_ForEachChannel(CF_GetEngine(), CF_ResetCounters_ChanActionImpl, &ctxt); } return CFE_SUCCESS; @@ -191,6 +686,7 @@ CFE_Status_t CF_ResetCountersCmd(const CF_ResetCountersCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) @@ -213,23 +709,28 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); ++CF_AppData.counters.err; - - /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ - return CFE_SUCCESS; - } - - ret = CF_CFDP_TxFile(tx->src_filename, tx->dst_filename, tx->cfdp_class, tx->keep, chan, tx->priority, tx->dest_id); - if (ret == CFE_SUCCESS) - { - CFE_EVS_SendEvent(CF_CMD_TX_FILE_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: file transfer successfully initiated"); - ++CF_AppData.counters.cmd; } else { - CFE_EVS_SendEvent(CF_CMD_TX_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: file transfer initiation failed"); - ++CF_AppData.counters.err; + ret = CF_CFDP_TxFile(tx->src_filename, + tx->dst_filename, + tx->cfdp_class, + tx->keep, + chan, + tx->priority, + tx->dest_id); + if (ret == CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_CMD_TX_FILE_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: file transfer successfully initiated"); + ++CF_AppData.counters.cmd; + } + else + { + CFE_EVS_SendEvent(CF_CMD_TX_FILE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: file transfer initiation failed"); + ++CF_AppData.counters.err; + } } return CFE_SUCCESS; @@ -239,6 +740,7 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) @@ -261,35 +763,123 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) (unsigned int)tx->cfdp_class, (unsigned int)tx->keep); ++CF_AppData.counters.err; + } + else + { + ret = CF_CFDP_PlaybackDir(tx->src_filename, + tx->dst_filename, + tx->cfdp_class, + tx->keep, + chan, + tx->priority, + tx->dest_id); + if (ret == CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: directory playback initiation successful"); + ++CF_AppData.counters.cmd; + } + else + { + CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: directory playback initiation failed"); + ++CF_AppData.counters.err; + } + } + + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Sets the "frozen" bool in every matched channel + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_FreezeThaw_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_GenericAction_DoSetBoolArg((CF_GenericAction_BoolArg_t *)ga, &chan->stat.frozen); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) +{ + CF_GenericAction_BoolArg_t barg; - /* This must return CFE_SUCCESS because the command is done (error counter was incremented, no more events) */ - return CFE_SUCCESS; + memset(&barg, 0, sizeof(barg)); + barg.barg = true; /* param is frozen, so true means freeze */ + + CF_GenericAction_CheckAndDispatchChannel("freeze", + CF_FreezeThaw_ChanActionImpl, + &barg.ga, + msg->Payload.ChannelSelect); + + if (barg.ga.TotalCount > 0) + { + CFE_EVS_SendEvent(CF_CMD_FREEZE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: freeze successful"); + ++CF_AppData.counters.cmd; + } + else + { + CFE_EVS_SendEvent(CF_CMD_FREEZE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: freeze cmd failed"); + ++CF_AppData.counters.err; } - ret = CF_CFDP_PlaybackDir(tx->src_filename, - tx->dst_filename, - tx->cfdp_class, - tx->keep, - chan, - tx->priority, - tx->dest_id); - if (ret == CFE_SUCCESS) + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) +{ + CF_GenericAction_BoolArg_t barg; + + memset(&barg, 0, sizeof(barg)); + barg.barg = false; /* param is frozen, so false means thaw */ + + CF_GenericAction_CheckAndDispatchChannel("thaw", + CF_FreezeThaw_ChanActionImpl, + &barg.ga, + msg->Payload.ChannelSelect); + + if (barg.ga.TotalCount > 0) { - CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: directory playback initiation successful"); + CFE_EVS_SendEvent(CF_CMD_THAW_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: thaw successful"); ++CF_AppData.counters.cmd; } else { - CFE_EVS_SendEvent(CF_CMD_PLAYBACK_DIR_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: directory playback initiation failed"); + CFE_EVS_SendEvent(CF_CMD_THAW_ERR_EID, CFE_EVS_EventType_ERROR, "CF: thaw cmd failed"); ++CF_AppData.counters.err; } return CFE_SUCCESS; } +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_CheckAndDispatchTxn() + * Sets the "suspended" bool in every matched transaction record + * + *-----------------------------------------------------------------*/ +static void CF_SuspRes_TxnActionImpl(CF_Transaction_t *txn, void *context) +{ + CF_Assert(txn); + CF_GenericAction_DoSetBoolArg(context, &txn->flags.com.suspended); +} /*---------------------------------------------------------------- * @@ -297,75 +887,199 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) * See description in cf_cmd.h for argument/return detail * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t -CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context) +void CF_SuspRes_CommonHandler(const char *action_str, const CF_Transaction_Payload_t *payload, bool is_suspend) { - CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_ChanActionContext_t local_ctxt; + CF_GenericAction_BoolArg_t args; + int count; - memset(&local_ctxt, 0, sizeof(local_ctxt)); - local_ctxt.fn = fn; - local_ctxt.context = context; + memset(&args, 0, sizeof(args)); + args.barg = is_suspend; - /* this function is generic for any ground command that takes a single channel - * argument which must be less than CF_NUM_CHANNELS or 255 which is a special - * value that means apply command to all channels */ - if (CF_IsAllChannels(chan_select)) + count = CF_GenericAction_CheckAndDispatchTxn(action_str, payload, CF_SuspRes_TxnActionImpl, &args); + + /* + * Note that this command may affect multiple transactions, depending on the value of the "chan" argument. + * When acting on multiple channels, the "same" output does not apply. In reality all it means is + * that one of the affected channels was already set that way. + */ + + if (count <= 0) { - /* apply to all channels */ - CF_ForEachChannel(engine_ptr, CF_DoSingleChannelAction, &local_ctxt); + /* No transaction was matched for the given combination of chan + eid + ts */ + CFE_EVS_SendEvent(CF_CMD_SUSPRES_CHAN_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: %s cmd: no transaction found", + action_str); + ++CF_AppData.counters.err; } - else if (CF_IsValidChannel(chan_select)) + else if (count == args.noop_count) { - CF_DoSingleChannelAction(engine_ptr, CF_GetChannelPtr(chan_select), &local_ctxt); + /* Success, but all matched transaction(s) were already set the same way, so nothing was done */ + CFE_EVS_SendEvent(CF_CMD_SUSPRES_SAME_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: %s cmd: setting suspend flag to current value of %d", + action_str, + (int)is_suspend); + ++CF_AppData.counters.cmd; } else { - /* bad parameter */ - CFE_EVS_SendEvent(CF_CMD_CHAN_PARAM_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: %s: channel parameter out of range. received %d", - errstr, - CF_ChannelSelect_AsInt(chan_select)); - local_ctxt.ret = CF_ChanAction_Status_ERROR; + CFE_EVS_SendEvent(CF_CMD_SUSPRES_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: %s cmd: set suspend flag to %d", + action_str, + (int)is_suspend); + ++CF_AppData.counters.cmd; } +} - return local_ctxt.ret; +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg) +{ + CF_SuspRes_CommonHandler("suspend", &msg->Payload, true); + return CFE_SUCCESS; } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg) +CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg) { - const CF_ChanAction_BoolArg_t *context = arg; + CF_SuspRes_CommonHandler("resume", &msg->Payload, false); + return CFE_SUCCESS; +} - /* no need to bounds check chan_num, done in caller */ - chan->stat.frozen = context->barg; - return CF_ChanAction_Status_SUCCESS; +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_CheckAndDispatchTxn() + * Cancels every matched transaction record + * + *-----------------------------------------------------------------*/ +static void CF_Cancel_TxnActionImpl(CF_Transaction_t *txn, void *ignored) +{ + CF_CFDP_CancelTransaction(txn); } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) +CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) +{ + int32 count; + + count = CF_GenericAction_CheckAndDispatchTxn("cancel", &msg->Payload, CF_Cancel_TxnActionImpl, NULL); + + if (count > 0) + { + CFE_EVS_SendEvent(CF_CMD_CANCEL_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: cancel transaction successfully initiated"); + ++CF_AppData.counters.cmd; + } + else + { + /* No transaction was matched for the given combination of chan + eid + ts */ + CFE_EVS_SendEvent(CF_CMD_CANCEL_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: cancel cmd: no transaction found"); + ++CF_AppData.counters.err; + } + + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_CheckAndDispatchTxn() + * Abandons every matched transaction record + * + *-----------------------------------------------------------------*/ +static void CF_Abandon_TxnActionImpl(CF_Transaction_t *txn, void *ignored) +{ + CF_CFDP_FinishTransaction(txn, false); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) +{ + int32 count; + + count = CF_GenericAction_CheckAndDispatchTxn("abandon", &msg->Payload, CF_Abandon_TxnActionImpl, NULL); + + if (count > 0) + { + CFE_EVS_SendEvent(CF_CMD_ABANDON_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: abandon successful"); + ++CF_AppData.counters.cmd; + } + else + { + /* No transaction was matched for the given combination of chan + eid + ts */ + CFE_EVS_SendEvent(CF_CMD_ABANDON_CHAN_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: abandon cmd: no transaction found"); + ++CF_AppData.counters.err; + } + + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Sets the boolean to the configured value in this channel + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_EnaDisaDequeue_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_GenericAction_DoSetBoolArg((CF_GenericAction_BoolArg_t *)ga, &chan->config.dequeue_enabled); + return CFE_SUCCESS; +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) { - CF_ChanAction_BoolArg_t barg = { 1 }; /* param is frozen, so 1 means freeze */ + CF_GenericAction_BoolArg_t barg; - if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(msg->Payload.ChannelSelect, "freeze", CF_DoFreezeThaw, &barg))) + memset(&barg, 0, sizeof(barg)); + barg.barg = true; + + CF_GenericAction_CheckAndDispatchChannel("enable_dequeue", + CF_EnaDisaDequeue_ChanActionImpl, + &barg.ga, + msg->Payload.ChannelSelect); + + if (barg.ga.TotalCount > 0) { - CFE_EVS_SendEvent(CF_CMD_FREEZE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: freeze successful"); + CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue enabled"); ++CF_AppData.counters.cmd; } else { - CFE_EVS_SendEvent(CF_CMD_FREEZE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: freeze cmd failed"); + CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: enable dequeue cmd failed"); ++CF_AppData.counters.err; } @@ -376,20 +1090,29 @@ CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) +CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) { - CF_ChanAction_BoolArg_t barg = { 0 }; /* param is frozen, so 0 means thawed */ + CF_GenericAction_BoolArg_t barg; - if (CF_ChanAction_Status_IS_SUCCESS(CF_DoChanAction(msg->Payload.ChannelSelect, "thaw", CF_DoFreezeThaw, &barg))) + memset(&barg, 0, sizeof(barg)); + barg.barg = false; + + CF_GenericAction_CheckAndDispatchChannel("disable_dequeue", + CF_EnaDisaDequeue_ChanActionImpl, + &barg.ga, + msg->Payload.ChannelSelect); + + if (barg.ga.TotalCount > 0) { - CFE_EVS_SendEvent(CF_CMD_THAW_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: thaw successful"); + CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue disabled"); ++CF_AppData.counters.cmd; } else { - CFE_EVS_SendEvent(CF_CMD_THAW_ERR_EID, CFE_EVS_EventType_ERROR, "CF: thaw cmd failed"); + CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: disable dequeue cmd failed"); ++CF_AppData.counters.err; } @@ -398,29 +1121,40 @@ CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Configures polling directory enable flag * *-----------------------------------------------------------------*/ -CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSeq_t ts, CF_EntityId_t eid) +static CFE_Status_t CF_EnaDisaPollDir_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - int i; - CF_Transaction_t *ret = NULL; + CF_LocalPdConfig_t *PdConfPtr; + uint32 num_pd; + CF_EnableDisablePollDir_Context_t *ctxt = (CF_EnableDisablePollDir_Context_t *)ga; + CFE_Status_t ret; - /* transaction sequence numbers are referenced with the tuple (eid, tsn) - * Even though these tuples are unique to a channel, they should be unique - * across the entire system. Meaning, it isn't correct to have the same - * EID re-using a TSN in the same system. So, in order to locate the transaction - * to suspend, we need to search across all channels for it. */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) + PdConfPtr = chan->config.polldir; + ret = CFE_SUCCESS; + + if (ctxt->user_pollidx == CF_ALL_POLLDIRS) + { + num_pd = CF_MAX_POLLING_DIR_PER_CHAN; + } + else if (ctxt->user_pollidx <= CF_MAX_POLLING_DIR_PER_CHAN) + { + PdConfPtr += (ctxt->user_pollidx - 1); /* this index is 1-based */ + num_pd = 1; + } + else { - CF_Channel_t *chan = CF_GetChannelPtr(CF_ChannelSelect_FromInt(i)); + ret = CFE_STATUS_VALIDATION_FAILURE; + num_pd = 0; + } - ret = CF_FindTransactionBySequenceNumber(chan, ts, eid); - if (ret) - { - break; - } + while (num_pd > 0) + { + CF_GenericAction_DoSetBoolArg(&ctxt->barg, &PdConfPtr->enabled); + ++PdConfPtr; + --num_pd; } return ret; @@ -428,187 +1162,236 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSe /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function + * Common implementation for enable/disable polling dir command * *-----------------------------------------------------------------*/ -int32 CF_TsnChanAction(const CF_Transaction_Payload_t *data, - const char *cmdstr, - CF_TsnChanAction_fn_t fn, - void *context) +static CFE_Status_t +CF_EnaDisaPollDir_CommonHandler(const char *action_str, const CF_PollDirSelect_Payload_t *payload, bool is_enable) { - CF_Transaction_t *txn; - CF_Channel_t *chan; - int32 ret = -1; + CF_EnableDisablePollDir_Context_t ctxt; + CFE_Status_t status; + int32 count; - if (CF_IsCompoundKey(data->chan_num)) - { - /* special value 254 means to use the compound key (data->eid, data->ts) to find the transaction - * to act upon */ - txn = CF_FindTransactionBySequenceNumberAllChannels(data->ts, data->eid); - if (txn) - { - fn(txn, context); - ret = 1; /* because one transaction was matched - this should return a count */ - } - else - { - CFE_EVS_SendEvent(CF_CMD_TRANS_NOT_FOUND_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: %s cmd: failed to find transaction for (eid %lu, ts %lu)", - cmdstr, - (unsigned long)data->eid, - (unsigned long)data->ts); - } - } - else if (CF_IsAllChannels(data->chan_num)) + memset(&ctxt, 0, sizeof(ctxt)); + ctxt.user_pollidx = payload->PollDirIndx; + ctxt.barg.barg = is_enable; + + count = CF_GenericAction_CheckAndDispatchChannel(action_str, + CF_EnaDisaPollDir_ChanActionImpl, + &ctxt.barg.ga, + payload->ChannelSelect); + + if (ctxt.barg.ga.TotalCount != 0) { - /* perform action on all channels, all transactions */ - ret = CF_TraverseAllTransactions_All_Channels(fn, context); + status = CFE_SUCCESS; } else { - chan = CF_GetChannelPtr(data->chan_num); - if (chan != NULL) - { - /* perform action on a specific channel, all transactions */ - ret = CF_TraverseAllTransactions(chan, fn, context); - } - else + status = CFE_STATUS_VALIDATION_FAILURE; + + /* should only be sent if the channel was valid, as an event was already sent if the channel was bad */ + if (count != 0) { - CFE_EVS_SendEvent(CF_CMD_TSN_CHAN_INVALID_ERR_EID, + CFE_EVS_SendEvent(CF_CMD_POLLDIR_INVALID_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: %s cmd: invalid channel %d", - cmdstr, - CF_ChannelSelect_AsInt(data->chan_num)); + "CF: enable/disable polldir: invalid polldir %d on channel %d", + (int)payload->PollDirIndx, + CF_ChannelSelect_AsInt(payload->ChannelSelect)); } } - return ret; + return status; } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -void CF_DoSuspRes_Txn(CF_Transaction_t *txn, CF_ChanAction_SuspResArg_t *context) +CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg) { - CF_Assert(txn); - if (txn->flags.com.suspended == context->action) + CFE_Status_t ret; + + ret = CF_EnaDisaPollDir_CommonHandler("enable_polldir", &msg->Payload, true); + + if (ret == CFE_SUCCESS) { - context->same = 1; + CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_INF_EID, + CFE_EVS_EventType_INFORMATION, + "CF: enabled polling directory"); + ++CF_AppData.counters.cmd; } else { - txn->flags.com.suspended = context->action; + CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: enable polling directory cmd failed"); + ++CF_AppData.counters.err; } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) +CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg) { - /* ok to not bounds check action, because the caller is using it in two places with constant values 0 or 1 */ - static const char *msgstr[] = { "resume", "suspend" }; - CF_ChanAction_SuspResArg_t args = { 0, action }; - int ret = CF_TsnChanAction(payload, msgstr[action], (CF_TsnChanAction_fn_t)CF_DoSuspRes_Txn, &args); + CFE_Status_t ret; - /* - * Note that this command may affect multiple transactions, depending on the value of the "chan" argument. - * When acting on multiple channels, the "same" output does not apply. In reality all it means is - * that one of the affected channels was already set that way. - */ + ret = CF_EnaDisaPollDir_CommonHandler("disable_polldir", &msg->Payload, false); - if (ret == 1 && args.same) + if (ret == CFE_SUCCESS) { - /* A single transaction was mached, and it was already set the same way */ - CFE_EVS_SendEvent(CF_CMD_SUSPRES_SAME_INF_EID, + CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_INF_EID, CFE_EVS_EventType_INFORMATION, - "CF: %s cmd: setting suspend flag to current value of %d", - msgstr[action], - action); + "CF: disabled polling directory"); ++CF_AppData.counters.cmd; } - else if (ret <= 0) + else { - /* No transaction was matched for the given combination of chan + eid + ts */ - CFE_EVS_SendEvent(CF_CMD_SUSPRES_CHAN_ERR_EID, + CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: %s cmd: no transaction found", - msgstr[action]); + "CF: disable polling directory cmd failed"); ++CF_AppData.counters.err; } - else - { - CFE_EVS_SendEvent(CF_CMD_SUSPRES_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: %s cmd: setting suspend flag to %d", - msgstr[action], - action); - ++CF_AppData.counters.cmd; - } + + return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_CList_Traverse() + * Resets the history for every node * *-----------------------------------------------------------------*/ -CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg) +static CF_CListTraverse_Status_t CF_PurgeQueue_ResetHistoryImpl(CF_CListNode_t *node, void *arg) +{ + CF_Channel_t *chan = arg; + CF_History_t *history = container_of(node, CF_History_t, cl_node); + CF_ResetHistory(chan, history); /* ok to reset transaction since it's in PEND it hasn't started yet */ + return CF_CLIST_CONT; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_CList_Traverse() + * Resets the history for every node + * + *-----------------------------------------------------------------*/ +static CF_CListTraverse_Status_t CF_PurgeQueue_FinishTransactionImpl(CF_CListNode_t *node, void *ignored) +{ + CF_Transaction_t *txn = container_of(node, CF_Transaction_t, cl_node); + CF_CFDP_FinishTransaction(txn, false); + return CF_CLIST_CONT; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Purges the history queue for this channel + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_PurgeQueue_DoHistoryQ(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_DoSuspRes(&msg->Payload, 1); + CF_CList_Traverse(chan->qs[CF_QueueIdx_HIST], CF_PurgeQueue_ResetHistoryImpl, chan); return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Purges the pending queue for this channel * *-----------------------------------------------------------------*/ -CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg) +static CFE_Status_t CF_PurgeQueue_DoPendingQ(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_DoSuspRes(&msg->Payload, 0); + CF_CList_Traverse(chan->qs[CF_QueueIdx_PEND], CF_PurgeQueue_FinishTransactionImpl, NULL); return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, dispatch table for Purge Queue command + * Calls the appropriate routine(s) based on specified queue * *-----------------------------------------------------------------*/ -void CF_Cancel_TxnCmd(CF_Transaction_t *txn, void *ignored) +static CFE_Status_t CF_PurgeQueue_Dispatcher(CF_DoPurgeQueue_Context_t *ctxt, + CF_GenericAction_HelperFn_t act_helper, + + CF_Channel_t *chan) { - CF_CFDP_CancelTransaction(txn); + static const CF_GenericAction_TableEntry_t CF_PURGEQ_HANDLER_MAP[CF_QueueSelect_MAX] = { + [CF_QueueSelect_Pending] = { CF_PurgeQueue_DoPendingQ }, + [CF_QueueSelect_History] = { CF_PurgeQueue_DoHistoryQ }, + }; + + return CF_GenericAction_DoDispatch(&ctxt->ga, + act_helper, + CF_PURGEQ_HANDLER_MAP, + sizeof(CF_PURGEQ_HANDLER_MAP), + ctxt->user_qsel, + chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Calls the appropriate routine(s) based on specified queue(s) + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_PurgeQueue_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + return CF_PurgeQueue_Dispatcher((CF_DoPurgeQueue_Context_t *)ga, CF_GenericAction_DoInvokeAction, chan); } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) +CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) { - if (CF_TsnChanAction(&msg->Payload, "cancel", CF_Cancel_TxnCmd, NULL) > 0) + CF_DoPurgeQueue_Context_t ctxt; + int32 count; + + memset(&ctxt, 0, sizeof(ctxt)); + ctxt.user_qsel = msg->Payload.QueueSelect; + + count = CF_GenericAction_CheckAndDispatchChannel("purge_queue", + CF_PurgeQueue_ChanActionImpl, + &ctxt.ga, + msg->Payload.ChannelSelect); + + /* If this matched channels but NOT any queues, send the arg err event */ + if (count != 0 && ctxt.ga.TotalCount == 0) { - CFE_EVS_SendEvent(CF_CMD_CANCEL_INF_EID, + CFE_EVS_SendEvent(CF_CMD_PURGE_ARG_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: purge queue invalid arg %d", + (int)msg->Payload.QueueSelect); + } + + if (ctxt.ga.TotalCount != 0) + { + CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, - "CF: cancel transaction successfully initiated"); + "CF: %u queue(s) purged", + (unsigned int)ctxt.ga.TotalCount); ++CF_AppData.counters.cmd; } else { - /* No transaction was matched for the given combination of chan + eid + ts */ - CFE_EVS_SendEvent(CF_CMD_CANCEL_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: cancel cmd: no transaction found"); + CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: purge queue cmd failed"); ++CF_AppData.counters.err; } @@ -617,482 +1400,593 @@ CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Writes Rx Active Queue data * *-----------------------------------------------------------------*/ -void CF_Abandon_TxnCmd(CF_Transaction_t *txn, void *ignored) +static CFE_Status_t CF_WriteQueue_DoRxActive(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_CFDP_FinishTransaction(txn, false); + CF_WriteQueue_FullContext_t *ctxt = (CF_WriteQueue_FullContext_t *)ga; + CFE_Status_t ret; + + ret = CF_WriteTxnQueueDataToFile(ctxt->fd, chan, CF_QueueIdx_RX); + if (ret != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_RX_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue failed on CF_QueueIdx_RX data"); + } + + return ret; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Writes Rx History Queue data * *-----------------------------------------------------------------*/ -CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) +static CFE_Status_t CF_WriteQueue_DoRxHistory(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - if (CF_TsnChanAction(&msg->Payload, "abandon", CF_Abandon_TxnCmd, NULL) > 0) - { - CFE_EVS_SendEvent(CF_CMD_ABANDON_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: abandon successful"); - ++CF_AppData.counters.cmd; - } - else + CF_WriteQueue_FullContext_t *ctxt = (CF_WriteQueue_FullContext_t *)ga; + CFE_Status_t ret; + + ret = CF_WriteHistoryQueueDataToFile(ctxt->fd, chan, CF_Direction_RX); + if (ret != CFE_SUCCESS) { - /* No transaction was matched for the given combination of chan + eid + ts */ - CFE_EVS_SendEvent(CF_CMD_ABANDON_CHAN_ERR_EID, + CFE_EVS_SendEvent(CF_CMD_WQ_WRITEHIST_RX_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: abandon cmd: no transaction found"); - ++CF_AppData.counters.err; + "CF: write queue failed on history RX data"); } - return CFE_SUCCESS; + return ret; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Writes Tx Active Queue data * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg) +static CFE_Status_t CF_WriteQueue_DoTxActive(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - const CF_ChanAction_BoolArg_t *context = arg; + CF_WriteQueue_FullContext_t *ctxt = (CF_WriteQueue_FullContext_t *)ga; + CFE_Status_t ret; + + ret = CF_WriteTxnQueueDataToFile(ctxt->fd, chan, CF_QueueIdx_TX); + if (ret != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_TX_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue failed on CF_QueueIdx_TX data"); + } - /* no need to bounds check chan_num, done in caller */ - chan->config.dequeue_enabled = context->barg; - return CF_ChanAction_Status_SUCCESS; + return ret; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Writes Tx Pending Queue data * *-----------------------------------------------------------------*/ -CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg) +static CFE_Status_t CF_WriteQueue_DoTxPending(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_BoolArg_t barg = { 1 }; + CF_WriteQueue_FullContext_t *ctxt = (CF_WriteQueue_FullContext_t *)ga; + CFE_Status_t ret; - if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(msg->Payload.ChannelSelect, "enable_dequeue", CF_DoEnableDisableDequeue, &barg))) + ret = CF_WriteTxnQueueDataToFile(ctxt->fd, chan, CF_QueueIdx_PEND); + if (ret != CFE_SUCCESS) { - CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue enabled"); - ++CF_AppData.counters.cmd; + CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_PEND_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue failed on CF_QueueIdx_PEND data"); } - else + + return ret; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Writes Tx History Queue data + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueue_DoTxHistory(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_WriteQueue_FullContext_t *ctxt = (CF_WriteQueue_FullContext_t *)ga; + CFE_Status_t ret; + + ret = CF_WriteHistoryQueueDataToFile(ctxt->fd, chan, CF_Direction_TX); + if (ret != CFE_SUCCESS) { - CFE_EVS_SendEvent(CF_CMD_ENABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: enable dequeue cmd failed"); - ++CF_AppData.counters.err; + CFE_EVS_SendEvent(CF_CMD_WQ_WRITEHIST_TX_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue failed on CF_QueueIdx_TX data"); } - return CFE_SUCCESS; + return ret; +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Dispatches write queue actions for the Rx direction (uploads) + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueueCmd_DoProcessRxQ(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_WriteQueue_DirContext_t *dir_ctxt = (CF_WriteQueue_DirContext_t *)ga; + CF_WriteQueue_FullContext_t *ctxt = dir_ctxt->ctxt; /* this is the original */ + + static const CF_GenericAction_TableEntry_t CF_WRITEQ_RX_HANDLER_MAP[CF_QueueSelect_MAX] = { + [CF_QueueSelect_Active] = { CF_WriteQueue_DoRxActive }, + [CF_QueueSelect_History] = { CF_WriteQueue_DoRxHistory }, + }; + + return CF_GenericAction_DoDispatch(&ctxt->ga, + dir_ctxt->q_action, + CF_WRITEQ_RX_HANDLER_MAP, + sizeof(CF_WRITEQ_RX_HANDLER_MAP), + ctxt->user_qsel, + chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Dispatches write queue actions for the Tx direction (downloads) + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueueCmd_DoProcessTxQ(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_WriteQueue_DirContext_t *dir_ctxt = (CF_WriteQueue_DirContext_t *)ga; + CF_WriteQueue_FullContext_t *ctxt = dir_ctxt->ctxt; /* this is the original */ + + static const CF_GenericAction_TableEntry_t CF_WRITEQ_TX_HANDLER_MAP[CF_QueueSelect_MAX] = { + [CF_QueueSelect_Active] = { CF_WriteQueue_DoTxActive }, + [CF_QueueSelect_Pending] = { CF_WriteQueue_DoTxPending }, + [CF_QueueSelect_History] = { CF_WriteQueue_DoTxHistory }, + }; + + return CF_GenericAction_DoDispatch(&ctxt->ga, + dir_ctxt->q_action, + CF_WRITEQ_TX_HANDLER_MAP, + sizeof(CF_WRITEQ_TX_HANDLER_MAP), + ctxt->user_qsel, + chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper function, dispatches write queue command based on direction + * Calls the appropriate routine(s) based on specified direction(s) + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueueCmd_DirectionDispatch(CF_WriteQueue_FullContext_t *ctxt, + CF_GenericAction_HelperFn_t act_helper, + CF_Channel_t *chan) +{ + CF_WriteQueue_DirContext_t dir_ctxt; + + static const CF_GenericAction_TableEntry_t CF_WRITEQ_DIR_HANDLER_MAP[CF_DirectionType_MAX] = { + [CF_DirectionType_up] = { CF_WriteQueueCmd_DoProcessRxQ }, + [CF_DirectionType_down] = { CF_WriteQueueCmd_DoProcessTxQ }, + }; + + /* save the params to pass thru to the next level (queue) */ + memset(&dir_ctxt, 0, sizeof(dir_ctxt)); + dir_ctxt.q_action = act_helper; + dir_ctxt.ctxt = ctxt; + + return CF_GenericAction_DoDispatch(&dir_ctxt.ga, + CF_GenericAction_DoInvokeAction, + CF_WRITEQ_DIR_HANDLER_MAP, + sizeof(CF_WRITEQ_DIR_HANDLER_MAP), + ctxt->user_dirsel, + chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Invokes the write queue action for matched directions on this channel + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueueCmd_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + return CF_WriteQueueCmd_DirectionDispatch((CF_WriteQueue_FullContext_t *)ga, CF_GenericAction_DoInvokeAction, chan); +} + +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * Invokes the check action for matched directions on this channel + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_WriteQueueCmd_CheckChannelAction(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + return CF_WriteQueueCmd_DirectionDispatch((CF_WriteQueue_FullContext_t *)ga, CF_GenericAction_DoCheck, chan); } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ -CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg) +CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) { - CF_ChanAction_BoolArg_t barg = { 0 }; + const CF_WriteQueue_Payload_t *wq = &msg->Payload; + + CF_WriteQueue_FullContext_t write_context; + CFE_Status_t status; + int32 count; + + memset(&write_context, 0, sizeof(write_context)); + + write_context.user_dirsel = wq->dir_type; + write_context.user_qsel = wq->queue; + + status = CFE_STATUS_VALIDATION_FAILURE; + + /* + * Do a pre-check of the arguments. This is done on this command because it opens a file. + * We should not open the file unless the basic command args are OK, because it would leave + * a zero-byte file in the filesystem if it fails. It also has a non-insignificant cost. + */ + count = CF_GenericAction_CheckAndDispatchChannel("write queue", + CF_WriteQueueCmd_CheckChannelAction, + &write_context.ga, + wq->chan_num); + + if (count != 0) + { + /* start by checking the request -- it should match at least one valid q-write impl */ + if (write_context.ga.ValidCount == 0) + { + /* the dir/queue combo did not map to any valid combo */ + CFE_EVS_SendEvent(CF_CMD_WQ_ARGS_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue invalid command parameters"); + } + else + { + /* so far so good, now do the actual work */ + /* PTFO: queues can be large. may want to split this work up across the state machine and take several + * wakeups to complete */ + status = CF_WrappedOpenCreate(&write_context.fd, + wq->filename, + OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, + OS_WRITE_ONLY); + if (status != OS_SUCCESS) + { + CFE_EVS_SendEvent(CF_CMD_WQ_OPEN_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: write queue failed to open file %s", + wq->filename); + } + else + { + /* now repeat the loop and actually do the write */ + /* zero out the counts again so we can check for failures */ + count = write_context.ga.ValidCount; + memset(&write_context.ga, 0, sizeof(write_context.ga)); + + CF_GenericAction_DispatchChannel(CF_WriteQueueCmd_ChanActionImpl, &write_context.ga, wq->chan_num); + CF_WrappedClose(write_context.fd); + + if (write_context.ga.SuccessCount != count) + { + /* the number of successful writes did not match what it should have been */ + /* this is just so we increment the error count, not the command count */ + status = CFE_STATUS_EXTERNAL_RESOURCE_FAIL; + } + } + } + } - if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(msg->Payload.ChannelSelect, "disable_dequeue", CF_DoEnableDisableDequeue, &barg))) + if (status == CFE_SUCCESS) { - CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: dequeue disabled"); ++CF_AppData.counters.cmd; + CFE_EVS_SendEvent(CF_CMD_WQ_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: write queue successful"); } else { - CFE_EVS_SendEvent(CF_CMD_DISABLE_DEQUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: disable dequeue cmd failed"); ++CF_AppData.counters.err; + /* all pertinent event(s) should have already been sent */ } + /* all relevant events have been sent and status has been logged, so work is done - return SUCCESS */ return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper Function for all get/set parameter operations + * This performs the actual get/set and issues the corresponding event * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg) +static CFE_Status_t CF_GetSet_DoParam(CF_GetSetParam_Context_t *ctxt, + CF_Channel_t *chan, + const char *printable_name, + void *param_ptr, + size_t param_sz) { - int i; - const CF_ChanAction_BoolMsgArg_t *context; - const CF_PollDirSelect_Payload_t *payload; - CF_ChanAction_Status_t ret; + uint32 saved_value; + CF_ChannelSelect_t chan_num; + uint16 event_id; + char msg_buffer[32]; - context = arg; - payload = context->opaque_data; - ret = CF_ChanAction_Status_SUCCESS; + saved_value = 0; + chan_num = CF_GetChannelFromPtr(chan); - /* no need to bounds check chan_num, done in caller */ - if (payload->PollDirIndx == CF_ALL_POLLDIRS) + switch (param_sz) { - /* all polldirs in channel */ - for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i) - chan->config.polldir[i].enabled = context->barg; + case sizeof(uint32): + saved_value = *((uint32 *)param_ptr); + break; + case sizeof(uint16): + saved_value = *((uint16 *)param_ptr); + break; + default: /* uint8 is the only other possibility */ + saved_value = *((uint8 *)param_ptr); + break; } - else if (payload->PollDirIndx < CF_MAX_POLLING_DIR_PER_CHAN) + + if (ctxt->is_set) { - chan->config.polldir[payload->PollDirIndx].enabled = context->barg; + switch (param_sz) + { + case sizeof(uint32): + *((uint32 *)param_ptr) = ctxt->value; + break; + case sizeof(uint16): + *((uint16 *)param_ptr) = ctxt->value; + break; + default: /* uint8 is the only other possibility */ + *((uint8 *)param_ptr) = ctxt->value; + break; + } + + event_id = CF_CMD_GETSET1_INF_EID; + snprintf(msg_buffer, + sizeof(msg_buffer), + "changed %u -> %u", + (unsigned int)saved_value, + (unsigned int)ctxt->value); } else { - CFE_EVS_SendEvent(CF_CMD_POLLDIR_INVALID_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: enable/disable polldir: invalid polldir %d on channel %d", - (int)payload->PollDirIndx, - CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan))); - ret = CF_ChanAction_Status_ERROR; + event_id = CF_CMD_GETSET2_INF_EID; + snprintf(msg_buffer, sizeof(msg_buffer), "value = %u", (unsigned int)saved_value); } - return ret; + CFE_EVS_SendEvent(event_id, + CFE_EVS_EventType_INFORMATION, + "CF: channel %d parameter id %s %s", + CF_ChannelSelect_AsInt(chan_num), + printable_name, + msg_buffer); + + return CFE_SUCCESS; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * For invalid parameters * *-----------------------------------------------------------------*/ -CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg) +static CFE_Status_t CF_GetSet_Do_Invalid(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_BoolMsgArg_t barg = { &msg->Payload, 1 }; - - if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(msg->Payload.ChannelSelect, "enable_polldir", CF_DoEnableDisablePolldir, &barg))) - { - CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: enabled polling directory"); - ++CF_AppData.counters.cmd; - } - else - { - CFE_EVS_SendEvent(CF_CMD_ENABLE_POLLDIR_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: enable polling directory cmd failed"); - ++CF_AppData.counters.err; - } - - return CFE_SUCCESS; + return CFE_STATUS_NOT_IMPLEMENTED; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg) +static CFE_Status_t CF_GetSet_Do_ticks_per_second(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_BoolMsgArg_t barg = { &msg->Payload, 0 }; - - if (CF_ChanAction_Status_IS_SUCCESS( - CF_DoChanAction(msg->Payload.ChannelSelect, "disable_polldir", CF_DoEnableDisablePolldir, &barg))) - { - CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: disabled polling directory"); - ++CF_AppData.counters.cmd; - } - else - { - CFE_EVS_SendEvent(CF_CMD_DISABLE_POLLDIR_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: disable polling directory cmd failed"); - ++CF_AppData.counters.err; - } - - return CFE_SUCCESS; + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CF_Engine_t *engine = ga->engine; + + return CF_GetSet_DoParam(ctxt, + chan, + "ticks_per_second", + &engine->config.ticks_per_second, + sizeof(engine->config.ticks_per_second)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CF_CListTraverse_Status_t CF_PurgeHistory(CF_CListNode_t *node, void *arg) +static CFE_Status_t CF_GetSet_Do_rx_crc_calc_bytes_per_wakeup(CF_GenericAction_Context_t *ga, + + CF_Channel_t *chan) { - CF_Channel_t *chan = arg; - CF_History_t *history = container_of(node, CF_History_t, cl_node); - CF_ResetHistory(chan, history); /* ok to reset transaction since it's in PEND it hasn't started yet */ - return CF_CLIST_CONT; + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CF_Engine_t *engine = ga->engine; + + return CF_GetSet_DoParam(ctxt, + chan, + "rx_crc_calc_bytes_per_wakeup", + &engine->config.rx_crc_calc_bytes_per_wakeup, + sizeof(engine->config.rx_crc_calc_bytes_per_wakeup)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignored) +static CFE_Status_t CF_GetSet_Do_ack_timer_s(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_Transaction_t *txn = container_of(node, CF_Transaction_t, cl_node); - CF_CFDP_FinishTransaction(txn, false); - return CF_CLIST_CONT; + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + + return CF_GetSet_DoParam(ctxt, chan, "ack_timer_s", &chan->config.ack_timer_s, sizeof(chan->config.ack_timer_s)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg) +static CFE_Status_t CF_GetSet_Do_nak_timer_s(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_Status_t ret; - const CF_ChanAction_MsgArg_t *context; - const CF_QueueSelect_Payload_t *payload; - - bool pend = false; - bool hist = false; - - context = arg; - payload = context->opaque_data; - ret = CF_ChanAction_Status_SUCCESS; - - switch (payload->QueueSelect) - { - case CF_QueueSelect_Pending: - pend = true; - break; - - case CF_QueueSelect_History: - hist = true; - break; - - case CF_QueueSelect_All: - pend = true; - hist = true; - break; - - default: - CFE_EVS_SendEvent(CF_CMD_PURGE_ARG_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: purge queue invalid arg %d", - (int)payload->QueueSelect); - ret = CF_ChanAction_Status_ERROR; - break; - } - - if (pend) - { - CF_CList_Traverse(chan->qs[CF_QueueIdx_PEND], CF_PurgeTransaction, NULL); - } + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; - if (hist) - { - CF_CList_Traverse(chan->qs[CF_QueueIdx_HIST], CF_PurgeHistory, chan); - } - - return ret; + return CF_GetSet_DoParam(ctxt, chan, "nak_timer_s", &chan->config.nak_timer_s, sizeof(chan->config.nak_timer_s)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) +static CFE_Status_t CF_GetSet_Do_inactivity_timer_s(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_MsgArg_t arg = { &msg->Payload }; - CF_ChanAction_Status_t status; - - status = CF_DoChanAction(msg->Payload.ChannelSelect, "purge_queue", CF_DoPurgeQueue, &arg); - - if (CF_ChanAction_Status_IS_SUCCESS(status)) - { - CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: queue purged"); - ++CF_AppData.counters.cmd; - } - else - { - CFE_EVS_SendEvent(CF_CMD_PURGE_QUEUE_ERR_EID, CFE_EVS_EventType_ERROR, "CF: purge queue cmd failed"); - ++CF_AppData.counters.err; - } + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; - return CFE_SUCCESS; + return CF_GetSet_DoParam(ctxt, + chan, + "inactivity_timer_s", + &chan->config.inactivity_timer_s, + sizeof(chan->config.inactivity_timer_s)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg) +static CFE_Status_t CF_GetSet_Do_outgoing_file_chunk_size(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - const CF_WriteQueue_Payload_t *wq = &msg->Payload; + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CF_Engine_t *engine = ga->engine; + CFE_Status_t ret; - CF_Channel_t *chan = CF_GetChannelPtr(wq->chan); - osal_id_t fd = OS_OBJECT_ID_UNDEFINED; - bool success = true; - int32 ret; - - /* check the commands for validity */ - if (chan == NULL) - { - CFE_EVS_SendEvent(CF_CMD_WQ_CHAN_ERR_EID, CFE_EVS_EventType_ERROR, "CF: write queue invalid channel arg"); - ++CF_AppData.counters.err; - success = false; - } - /* only invalid combination is up direction, pending queue */ - else if ((wq->type == CF_Type_up) && (wq->queue == CF_QueueSelect_Pending)) + if (ctxt->is_set && (ctxt->value == 0 || ctxt->value > sizeof(CF_CFDP_PduFileDataContent_t))) { - CFE_EVS_SendEvent(CF_CMD_WQ_ARGS_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue invalid command parameters"); - ++CF_AppData.counters.err; - success = false; + ret = CFE_STATUS_VALIDATION_FAILURE; } else { - /* PTFO: queues can be large. may want to split this work up across the state machine and take several wakeups - * to complete */ - ret = CF_WrappedOpenCreate(&fd, wq->filename, OS_FILE_FLAG_CREATE | OS_FILE_FLAG_TRUNCATE, OS_WRITE_ONLY); - if (ret < 0) - { - CFE_EVS_SendEvent(CF_CMD_WQ_OPEN_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to open file %s", - wq->filename); - ++CF_AppData.counters.err; - success = false; - } + ret = CF_GetSet_DoParam(ctxt, + chan, + "outgoing_file_chunk_size", + &engine->config.outgoing_file_chunk_size, + sizeof(engine->config.outgoing_file_chunk_size)); } - /* if type is type_up, or all types */ - if (success && ((wq->type == CF_Type_all) || (wq->type == CF_Type_up))) - { - /* process uplink queue data */ - if ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Active)) - { - ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_RX); - if (ret) - { - CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_RX_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to write CF_QueueIdx_RX data"); - CF_WrappedClose(fd); - ++CF_AppData.counters.err; - success = false; - } - } + return ret; +} - if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_History))) - { - ret = CF_WriteHistoryQueueDataToFile(fd, chan, CF_Direction_RX); - if (ret) - { - CFE_EVS_SendEvent(CF_CMD_WQ_WRITEHIST_RX_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to write history RX data"); - CF_WrappedClose(fd); - ++CF_AppData.counters.err; - success = false; - } - } - } +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_GetSet_Do_ack_limit(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; - /* if type is type_down, or all types */ - if (success && ((wq->type == CF_Type_all) || (wq->type == CF_Type_down))) - { - /* process downlink queue data */ - if ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Active)) - { - ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_TX); - if (ret) - { - CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_TX_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to write CF_QueueIdx_TX data"); - CF_WrappedClose(fd); - ++CF_AppData.counters.err; - success = false; - } - } + return CF_GetSet_DoParam(ctxt, chan, "ack_limit", &chan->config.ack_limit, sizeof(chan->config.ack_limit)); +} - if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_Pending))) - { - /* write pending queue */ - ret = CF_WriteTxnQueueDataToFile(fd, chan, CF_QueueIdx_PEND); - if (ret) - { - CFE_EVS_SendEvent(CF_CMD_WQ_WRITEQ_PEND_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to write pending queue"); - CF_WrappedClose(fd); - ++CF_AppData.counters.err; - success = false; - } - } +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_GetSet_Do_nak_limit(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; - if (success && ((wq->queue == CF_QueueSelect_All) || (wq->queue == CF_QueueSelect_History))) - { - /* write history queue */ - ret = CF_WriteHistoryQueueDataToFile(fd, chan, CF_Direction_TX); - if (ret) - { - CFE_EVS_SendEvent(CF_CMD_WQ_WRITEHIST_TX_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: write queue failed to write CF_QueueIdx_TX data"); - CF_WrappedClose(fd); - ++CF_AppData.counters.err; - success = false; - } - } - } + return CF_GetSet_DoParam(ctxt, chan, "nak_limit", &chan->config.nak_limit, sizeof(chan->config.nak_limit)); +} - if (success) - { - CFE_EVS_SendEvent(CF_CMD_WQ_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: write queue successful"); - ++CF_AppData.counters.cmd; - } +/*---------------------------------------------------------------- + * + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() + * + *-----------------------------------------------------------------*/ +static CFE_Status_t CF_GetSet_Do_local_eid(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) +{ + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CF_Engine_t *engine = ga->engine; - return CFE_SUCCESS; + return CF_GetSet_DoParam(ctxt, chan, "local_eid", &engine->config.local_eid, sizeof(engine->config.local_eid)); } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper function, compatible with CF_GenericAction_DispatchChannel() * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan /* ignored */) +static CFE_Status_t CF_GetSet_Do_chan_max_outgoing_messages_per_wakeup(CF_GenericAction_Context_t *ga, + + CF_Channel_t *chan) { - CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; - if (val > sizeof(CF_CFDP_PduFileDataContent_t)) + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CFE_Status_t ret; + + /* must have a nonzero limit or a synch semaphore */ + if (ctxt->is_set && ctxt->value == 0 && chan->config.sem_name[0] == 0) + { + ret = CFE_STATUS_VALIDATION_FAILURE; + } + else { - ret = CF_ChanAction_Status_ERROR; /* failed */ + ret = CF_GetSet_DoParam(ctxt, + chan, + "max_outgoing_messages_per_wakeup", + &chan->config.max_outgoing_messages_per_wakeup, + sizeof(chan->config.max_outgoing_messages_per_wakeup)); } + return ret; } /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper Function * *-----------------------------------------------------------------*/ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) +static CFE_Status_t CF_GetSetParam_ChanActionImpl(CF_GenericAction_Context_t *ga, CF_Channel_t *chan) { - CF_ChanAction_Status_t ret = CF_ChanAction_Status_SUCCESS; + CF_GetSetParam_Context_t *ctxt = (CF_GetSetParam_Context_t *)ga; + CFE_Status_t ret; + + static const CF_GenericAction_TableEntry_t CF_GETSETPARAM_HANDLER_MAP[CF_GetSet_ValueID_MAX] = { + [0] = { CF_GetSet_Do_Invalid }, + [CF_GetSet_ValueID_ticks_per_second] = { CF_GetSet_Do_ticks_per_second }, + [CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup] = { CF_GetSet_Do_rx_crc_calc_bytes_per_wakeup }, + [CF_GetSet_ValueID_ack_timer_s] = { CF_GetSet_Do_ack_timer_s }, + [CF_GetSet_ValueID_nak_timer_s] = { CF_GetSet_Do_nak_timer_s }, + [CF_GetSet_ValueID_inactivity_timer_s] = { CF_GetSet_Do_inactivity_timer_s }, + [CF_GetSet_ValueID_outgoing_file_chunk_size] = { CF_GetSet_Do_outgoing_file_chunk_size }, + [CF_GetSet_ValueID_ack_limit] = { CF_GetSet_Do_ack_limit }, + [CF_GetSet_ValueID_nak_limit] = { CF_GetSet_Do_nak_limit }, + [CF_GetSet_ValueID_local_eid] = { CF_GetSet_Do_local_eid }, + [CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup] = { CF_GetSet_Do_chan_max_outgoing_messages_per_wakeup }, + }; - if (!val && !chan->config.sem_name[0]) + ret = CF_GenericAction_DoDispatch(&ctxt->ga, + CF_GenericAction_DoInvokeAction, + CF_GETSETPARAM_HANDLER_MAP, + sizeof(CF_GETSETPARAM_HANDLER_MAP), + ctxt->param_id, + chan); + + if (ret == CFE_STATUS_VALIDATION_FAILURE) { - /* can't have unlimited messages and no semaphore */ - ret = CF_ChanAction_Status_ERROR; /* failed */ + ++ctxt->ga.ErrorCount; } return ret; @@ -1100,186 +1994,70 @@ CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) /*---------------------------------------------------------------- * - * Application-scope internal function - * See description in cf_cmd.h for argument/return detail + * Local Helper Function + * Common implementation for Get Param and Set Param commands * *-----------------------------------------------------------------*/ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num) +static void +CF_GetSetParam_CommonHandler(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num) { - CFE_Status_t status = CF_ERROR; - bool valid_set; - struct - { - void *ptr; - size_t size; - CF_ChanAction_Status_t (*fn)(uint32, CF_Channel_t *); - } item; + int32 count; + CF_GetSetParam_Context_t ctxt; - CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + memset(&ctxt, 0, sizeof(ctxt)); + ctxt.is_set = is_set; + ctxt.param_id = param_id; + ctxt.value = value; - if (chan == NULL) - { - CFE_EVS_SendEvent(CF_CMD_GETSET_CHAN_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: invalid configuration channel id %d received", - CF_ChannelSelect_AsInt(chan_num)); - ++CF_AppData.counters.err; - return; - } - - valid_set = false; - memset(&item, 0, sizeof(item)); - - switch (param_id) - { - case CF_GetSet_ValueID_ticks_per_second: - item.ptr = &engine_ptr->config.ticks_per_second; - item.size = sizeof(engine_ptr->config.ticks_per_second); - break; - case CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup: - item.ptr = &engine_ptr->config.rx_crc_calc_bytes_per_wakeup; - item.size = sizeof(engine_ptr->config.rx_crc_calc_bytes_per_wakeup); - break; - case CF_GetSet_ValueID_ack_timer_s: - item.ptr = &chan->config.ack_timer_s; - item.size = sizeof(chan->config.ack_timer_s); - break; - case CF_GetSet_ValueID_nak_timer_s: - item.ptr = &chan->config.nak_timer_s; - item.size = sizeof(chan->config.nak_timer_s); - break; - case CF_GetSet_ValueID_inactivity_timer_s: - item.ptr = &chan->config.inactivity_timer_s; - item.size = sizeof(chan->config.inactivity_timer_s); - break; - case CF_GetSet_ValueID_outgoing_file_chunk_size: - item.ptr = &engine_ptr->config.outgoing_file_chunk_size; - item.size = sizeof(engine_ptr->config.outgoing_file_chunk_size); - item.fn = CF_ValidateChunkSizeCmd; - break; - case CF_GetSet_ValueID_ack_limit: - item.ptr = &chan->config.ack_limit; - item.size = sizeof(chan->config.ack_limit); - break; - case CF_GetSet_ValueID_nak_limit: - item.ptr = &chan->config.nak_limit; - item.size = sizeof(chan->config.nak_limit); - break; - case CF_GetSet_ValueID_local_eid: - item.ptr = &engine_ptr->config.local_eid; - item.size = sizeof(engine_ptr->config.local_eid); - break; - case CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup: - item.ptr = &chan->config.max_outgoing_messages_per_wakeup; - item.size = sizeof(chan->config.max_outgoing_messages_per_wakeup); - item.fn = CF_ValidateMaxOutgoingCmd; - break; - default: - break; - }; + count = CF_GenericAction_CheckAndDispatchChannel("param", CF_GetSetParam_ChanActionImpl, &ctxt.ga, chan_num); - if (item.size == 0) + /* if anything happened, the overall command was successful + * (note this is unlikely to have some channels work and some not) */ + if (ctxt.ga.SuccessCount != 0) { - CFE_EVS_SendEvent(CF_CMD_GETSET_PARAM_ERR_EID, - CFE_EVS_EventType_ERROR, - "CF: invalid configuration parameter id %d received", - param_id); + ++CF_AppData.counters.cmd; } - else if (is_set) + else { - if (item.fn) + ++CF_AppData.counters.err; + + /* check if the failure was due to key, NOT channel ID */ + if (count != 0) { - if (CF_ChanAction_Status_IS_SUCCESS(item.fn(value, chan))) - { - valid_set = true; - } - else + /* this counter is incremented for CFE_STATUS_VALIDATION_FAILURE specifically */ + if (ctxt.ga.ErrorCount != 0) { + /* the failure is due to a validation error */ CFE_EVS_SendEvent(CF_CMD_GETSET_VALIDATE_ERR_EID, CFE_EVS_EventType_ERROR, - "CF: validation for parameter id %d failed", - param_id); - } - } - else - { - valid_set = true; - } - - if (valid_set) - { - status = CFE_SUCCESS; - - CFE_EVS_SendEvent(CF_CMD_GETSET1_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: setting parameter id %d to %lu", - param_id, - (unsigned long)value); - - /* Store value based on its size */ - if (item.size == sizeof(uint32)) - { - *((uint32 *)item.ptr) = value; - } - else if (item.size == sizeof(uint16)) - { - *((uint16 *)item.ptr) = value; + "CF: bad value %u for parameter id %d", + (unsigned int)value, + (int)param_id); } else { - /* uint8 is the only other option */ - *((uint8 *)item.ptr) = value; + /* the failure must be due to a bad parameter key */ + CFE_EVS_SendEvent(CF_CMD_GETSET_PARAM_ERR_EID, + CFE_EVS_EventType_ERROR, + "CF: invalid configuration parameter id %d received", + (int)param_id); } } } - else - { - status = CFE_SUCCESS; - - /* Read value depending on its size */ - if (item.size == sizeof(uint32)) - { - value = *((const uint32 *)item.ptr); - } - else if (item.size == sizeof(uint16)) - { - value = *((const uint16 *)item.ptr); - } - else - { - /* uint8 is the only other option */ - value = *((const uint8 *)item.ptr); - } - - CFE_EVS_SendEvent(CF_CMD_GETSET2_INF_EID, - CFE_EVS_EventType_INFORMATION, - "CF: parameter id %d = %lu", - param_id, - (unsigned long)value); - } - - if (status == CFE_SUCCESS) - { - ++CF_AppData.counters.cmd; - } - else - { - ++CF_AppData.counters.err; - } } /*---------------------------------------------------------------- * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg) { const CF_SetParam_Payload_t *cmd = &msg->Payload; - CF_GetSetParamCmd(true, cmd->key, cmd->value, cmd->chan_num); + CF_GetSetParam_CommonHandler(true, cmd->key, cmd->value, cmd->chan_num); return CFE_SUCCESS; } @@ -1288,13 +2066,14 @@ CFE_Status_t CF_SetParamCmd(const CF_SetParamCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) { const CF_GetParam_Payload_t *cmd = &msg->Payload; - CF_GetSetParamCmd(false, cmd->key, 0, cmd->chan_num); + CF_GetSetParam_CommonHandler(false, cmd->key, 0, cmd->chan_num); return CFE_SUCCESS; } @@ -1303,15 +2082,16 @@ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) { - CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Engine_t *engine = CF_GetEngine(); - if (!engine_ptr->enabled) + if (!engine->enabled) { - if (CF_CFDP_InitEngine(engine_ptr) == CFE_SUCCESS) + if (CF_CFDP_InitEngine(engine) == CFE_SUCCESS) { CFE_EVS_SendEvent(CF_CMD_ENABLE_ENGINE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: enabled CFDP engine"); ++CF_AppData.counters.cmd; @@ -1339,13 +2119,14 @@ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) * * Application-scope internal function * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) { - CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Engine_t *engine = CF_GetEngine(); - if (engine_ptr->enabled) + if (engine->enabled) { CF_CFDP_DisableEngine(); CFE_EVS_SendEvent(CF_CMD_DISABLE_ENGINE_INF_EID, CFE_EVS_EventType_INFORMATION, "CF: disabled CFDP engine"); @@ -1369,11 +2150,11 @@ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) * Compatible with CF_ForEachChannel() * *-----------------------------------------------------------------*/ -static int32 CF_DoHkStats(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) +static int32 CF_SendHk_DoChannelStats(CF_Engine_t *engine, CF_Channel_t *chan, void *arg) { CF_HkChannel_Data_t *out_chan_hk; CF_HkPacket_t *hk = arg; - const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)); + const int chan_num = CF_ChannelSelect_AsInt(CF_GetChannelFromPtr(chan)) - 1; int q_idx; out_chan_hk = &hk->Payload.channel_hk[chan_num]; @@ -1394,11 +2175,12 @@ static int32 CF_DoHkStats(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg * * Application-scope internal function * See description in cf_app.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) { - CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Engine_t *engine = CF_GetEngine(); CFE_SB_Buffer_t *sb_buf; CF_HkPacket_t *hk; @@ -1410,7 +2192,7 @@ CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) hk = (void *)&sb_buf->Msg; hk->Payload.counters = CF_AppData.counters; - CF_ForEachChannel(engine_ptr, CF_DoHkStats, hk); + CF_ForEachChannel(engine, CF_SendHk_DoChannelStats, hk); /* return value ignored */ CFE_SB_TransmitBuffer(sb_buf, true); @@ -1423,6 +2205,7 @@ CFE_Status_t CF_SendHkCmd(const CF_SendHkCmd_t *msg) * * Application-scope internal function * See description in cf_app.h for argument/return detail + * This is the entry point function invoked from the SB command handler * *-----------------------------------------------------------------*/ CFE_Status_t CF_WakeupCmd(const CF_WakeupCmd_t *msg) diff --git a/fsw/src/cf_cmd.h b/fsw/src/cf_cmd.h index 08fce712..b17d1c34 100644 --- a/fsw/src/cf_cmd.h +++ b/fsw/src/cf_cmd.h @@ -30,75 +30,32 @@ #include "cf_app.h" #include "cf_utils.h" -typedef enum -{ - CF_ChanAction_Status_SUCCESS = 0, - CF_ChanAction_Status_ERROR = -1 -} CF_ChanAction_Status_t; - -/** - * Checks if the channel action was successful - */ -static inline bool CF_ChanAction_Status_IS_SUCCESS(CF_ChanAction_Status_t stat) -{ - return (stat == CF_ChanAction_Status_SUCCESS); -} - /** - * @brief A callback function for use with CF_DoChanAction() + * @brief Generic action base struct * - * @param chan The CF channel pointer - * @param context Opaque object passed through from initial call + * A common context struct that is used when looping through + * many channels/transactions/queues/directions etc. This + * is just basic counters. The struct should be extended + * for additional context info (this should appear first in extensions) */ -typedef CF_ChanAction_Status_t (*CF_ChanActionFn_t)(CF_Channel_t *chan, void *context); - -/** - * @brief An object to use with channel-scope actions requiring only a boolean argument - */ -typedef struct CF_ChanAction_BoolArg +typedef struct { - bool barg; -} CF_ChanAction_BoolArg_t; - -/** - * @brief A callback to use with transaction actions - * - * For now this is the same as CF_TraverseAllTransactions_fn_t - */ -typedef CF_TraverseAllTransactions_fn_t CF_TsnChanAction_fn_t; + CF_Engine_t *engine; /* The engine being operated on (currently always the same singleton) */ + int32 TotalCount; /* total number of callbacks, including no-ops */ + int32 SuccessCount; /* count of callbacks where return status is CFE_SUCCESS */ + int32 ValidCount; /* General purpose counter - Incremented in the callback based on selected conditions */ + int32 ErrorCount; /* General purpose counter - Incremented in the callback based on selected conditions */ +} CF_GenericAction_Context_t; /** - * @brief An object to use with channel-scope actions for suspend/resume + * @brief Callback function for generic actions * - * This combines a boolean action arg with an output that indicates if it - * was a change or not. - */ -typedef struct CF_ChanAction_SuspResArg -{ - int same; /**< out param -- indicates at least one action was set to its current value */ - bool action; -} CF_ChanAction_SuspResArg_t; - -/** - * @brief An object to use with channel-scope actions that require the message value + * This will be invoked for every channel match * - * This combines a boolean action arg with the command message value + * @param ga pointer to the (base) context struct + * @param chan CFDP channel - passed through to function */ -typedef struct CF_ChanAction_BoolMsgArg -{ - const void *opaque_data; - bool barg; -} CF_ChanAction_BoolMsgArg_t; - -/** - * @brief An object to use with channel-scope actions that require the message value - * - * This combines a boolean action arg with the command message value - */ -typedef struct CF_ChanAction_MsgArg -{ - const void *opaque_data; -} CF_ChanAction_MsgArg_t; +typedef CFE_Status_t (*CF_GenericAction_Func_t)(CF_GenericAction_Context_t *ga, CF_Channel_t *chan); /************************************************************************/ /** @brief Send CF housekeeping packet @@ -187,42 +144,6 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg); */ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg); -/************************************************************************/ -/** @brief Common logic for all channel-based commands. - * - * @par Description - * All the commands that act on channels or have the special - * "all channels" parameter come through this function. This puts - * all common logic in one place. It does not handle the command - * accept or reject counters. - * - * @par Assumptions, External Events, and Notes: - * cmd must not be NULL, errstr must not be NULL, fn must be a valid function, context may be NULL. - * - * @param chan_select Channel selector value from command (validated within this function) - * @param errstr String to be included in the EVS event if command should fail - * @param fn Callback action function to invoke for each affected channel - * @param context Opaque pointer to pass through to callback (not used in this function) - * - * @returns The return value from the given action function. - * @retval CF_ChanAction_Status_ERROR on error - */ -CF_ChanAction_Status_t -CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context); - -/************************************************************************/ -/** @brief Channel action to set the frozen bit for a channel. - * - * @par Assumptions, External Events, and Notes: - * context must not be NULL. - * - * @param chan channel pointer (must not be NULL) - * @param arg context pointer to object, must be CF_ChanAction_BoolArg_t* - * - * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. - */ -CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg); - /************************************************************************/ /** @brief Freeze a channel. * @@ -243,71 +164,6 @@ CFE_Status_t CF_FreezeCmd(const CF_FreezeCmd_t *msg); */ CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg); -/************************************************************************/ -/** @brief Search for a transaction across all channels. - * - * @par Assumptions, External Events, and Notes: - * None - * - * @param ts Transaction sequence number to find - * @param eid Entity ID of the transaction - * - * @returns Pointer to the transaction, if found - * @retval NULL if transaction not found - * - */ -CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSeq_t ts, CF_EntityId_t eid); - -/************************************************************************/ -/** @brief Common logic for all transaction sequence number and channel commands. - * - * @par Description - * All the commands that on a transaction on a particular channel come - * through this function. This puts all common logic in one place. It - * does handle the command accept or reject counters. - * - * @par Assumptions, External Events, and Notes: - * cmd must not be NULL, fn must be a valid function, context may be NULL. - * - * @param data Pointer to payload being processed - * @param cmdstr String to include in any generated EVS events - * @param fn Callback function to invoke for each matched transaction - * @param context Opaque object to pass through to the callback - * - * @returns returns the number of transactions acted upon - * - */ -int32 CF_TsnChanAction(const CF_Transaction_Payload_t *data, - const char *cmdstr, - CF_TsnChanAction_fn_t fn, - void *context); - -/************************************************************************/ -/** @brief Set the suspended bit in a transaction. - * - * @par Assumptions, External Events, and Notes: - * txn must not be NULL. context must not be NULL. - * - * @param txn Pointer to the transaction object - * @param context Pointer to CF_ChanAction_SuspResArg_t structure from initial call - */ -void CF_DoSuspRes_Txn(CF_Transaction_t *txn, CF_ChanAction_SuspResArg_t *context); - -/************************************************************************/ -/** @brief Handle transaction suspend and resume commands. - * - * @par Description - * This is called for both suspend and resume ground commands. - * It uses the CF_TsnChanAction() function to perform the command. - * - * @par Assumptions, External Events, and Notes: - * payload must not be NULL. - * - * @param payload Pointer to the command message - * @param action Action to take (suspend or resume) - */ -void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action); - /************************************************************************/ /** @brief Handle transaction suspend command. * @@ -328,19 +184,6 @@ CFE_Status_t CF_SuspendCmd(const CF_SuspendCmd_t *msg); */ CFE_Status_t CF_ResumeCmd(const CF_ResumeCmd_t *msg); -/************************************************************************/ -/** @brief tsn chan action to cancel a transaction. - * - * This helper function is used with CF_TsnChanAction() to cancel matched transactions - * - * @par Assumptions, External Events, and Notes: - * txn must not be NULL. - * - * @param txn Pointer to transaction object - * @param ignored Not used by this function - */ -void CF_Cancel_TxnCmd(CF_Transaction_t *txn, void *ignored); - /************************************************************************/ /** @brief Handle a cancel ground command. * @@ -351,19 +194,6 @@ void CF_Cancel_TxnCmd(CF_Transaction_t *txn, void *ignored); */ CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg); -/************************************************************************/ -/** @brief tsn chan action to abandon a transaction. - * - * This helper function is used with CF_TsnChanAction() to abandon matched transactions - * - * @par Assumptions, External Events, and Notes: - * txn must not be NULL. - * - * @param txn Pointer to transaction object - * @param ignored Not used by this function - */ -void CF_Abandon_TxnCmd(CF_Transaction_t *txn, void *ignored); - /************************************************************************/ /** @brief Handle an abandon ground command. * @@ -374,20 +204,6 @@ void CF_Abandon_TxnCmd(CF_Transaction_t *txn, void *ignored); */ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg); -/************************************************************************/ -/** @brief Sets the dequeue enable/disable flag for a channel. - * - * @par Assumptions, External Events, and Notes: - * context must not be NULL. - * - * @param chan channel pointer (must not be NULL) - * @param arg context pointer to object, must be CF_ChanAction_BoolArg_t* - * - * @returns Always succeeds, so returns CF_ChanAction_Status_SUCCESS. - * - */ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg); - /************************************************************************/ /** @brief Handle an enable dequeue ground command. * @@ -408,21 +224,6 @@ CFE_Status_t CF_EnableDequeueCmd(const CF_EnableDequeueCmd_t *msg); */ CFE_Status_t CF_DisableDequeueCmd(const CF_DisableDequeueCmd_t *msg); -/************************************************************************/ -/** @brief Sets the enable/disable flag for the specified polling directory. - * - * @par Assumptions, External Events, and Notes: - * context must not be NULL. - * - * @param chan channel pointer (must not be NULL) - * @param arg context pointer to object, must be CF_ChanAction_BoolMsgArg_t* - * - * @returns success/fail status code - * @retval CF_ChanAction_Status_SUCCESS if successful - * @retval CF_ChanAction_Status_ERROR if failed - */ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg); - /************************************************************************/ /** @brief Enable a polling dir ground command. * @@ -443,55 +244,6 @@ CFE_Status_t CF_EnableDirPollingCmd(const CF_EnableDirPollingCmd_t *msg); */ CFE_Status_t CF_DisableDirPollingCmd(const CF_DisableDirPollingCmd_t *msg); -/************************************************************************/ -/** @brief Purge the history queue for the given channel. - * - * This helper function is used in conjunction with CF_CList_Traverse() - * - * @par Assumptions, External Events, and Notes: - * node must not be NULL. chan must not be NULL. - * - * @param node Current list node being traversed - * @param arg Channel pointer passed through as opaque object, must be CF_Channel_t* - * - * @returns Always #CF_CLIST_CONT to process all entries - */ -CF_CListTraverse_Status_t CF_PurgeHistory(CF_CListNode_t *node, void *arg); - -/************************************************************************/ -/** @brief Purge the pending transaction queue. - * - * This helper function is used in conjunction with CF_CList_Traverse() - * - * @par Assumptions, External Events, and Notes: - * node must not be NULL. - * - * @param node Current list node being traversed - * @param ignored Not used by this implementation - * - * @returns Always #CF_CLIST_CONT to process all entries - */ -CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignored); - -/************************************************************************/ -/** @brief Channel action command to perform purge queue operations. - * - * @par Description - * Determines from the command parameters which queues to traverse - * and purge state. - * - * @par Assumptions, External Events, and Notes: - * None - * - * @param chan CF channel pointer (must not be NULL) - * @param arg Pointer to purge queue command - * - * @returns integer status code indicating success or failure - * @retval CF_ChanAction_Status_SUCCESS if successful - * @retval CF_ChanAction_Status_ERROR on error - */ -CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg); - /************************************************************************/ /** @brief Ground command to purge either the history or pending queues. * @@ -512,58 +264,6 @@ CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg); */ CFE_Status_t CF_WriteQueueCmd(const CF_WriteQueueCmd_t *msg); -/************************************************************************/ -/** @brief Checks if the value is less than or equal to the max PDU size. - * - * @par Assumptions, External Events, and Notes: - * None - * - * @param val Size of chunk to test - * @param chan Ignored by this implementation - * - * @returns status code indicating if check passed - * @retval CF_ChanAction_Status_SUCCESS if successful (val is less than or equal to max PDU) - * @retval CF_ChanAction_Status_ERROR if failed (val is greater than max PDU) - * - */ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan); - -/************************************************************************/ -/** @brief Checks if the value is within allowable range as outgoing packets per wakeup - * - * @par Assumptions, External Events, and Notes: - * None - * - * @param val Number to test - * @param chan CF channel pointer - * - * @returns status code indicating if check passed - * @retval CF_ChanAction_Status_SUCCESS if successful (val is allowable as max packets per wakeup) - * @retval CF_ChanAction_Status_ERROR if failed (val is not allowed) - * - */ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan); - -/************************************************************************/ -/** @brief Perform a configuration get/set operation. - * - * For a set, this sets the value within the CF configuration - * For a get, this generates an EVS event with the requested information - * - * @par Description - * Combine get and set in one function with common logic. - * - * @par Assumptions, External Events, and Notes: - * None - * - * @param is_set Whether to get (false) or set (true) - * @param param_id Parameter ID - * @param value Value to get/set - * @param chan_num Channel selector from original command (Validated within this function) - * - */ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num); - /************************************************************************/ /** @brief Ground command to set a configuration parameter. * diff --git a/fsw/src/cf_utils.c b/fsw/src/cf_utils.c index 2633522e..c315dac6 100644 --- a/fsw/src/cf_utils.c +++ b/fsw/src/cf_utils.c @@ -478,42 +478,6 @@ int32 CF_TraverseAllTransactions(CF_Channel_t *chan, CF_TraverseAllTransactions_ return args.counter; } -/*---------------------------------------------------------------- - * - * Local helper function - * Invokes CF_TraverseAllTransactions() for a single channel within the CFDP engine - * Compatible with CF_ForEachChannel() - * - *-----------------------------------------------------------------*/ -static int32 CF_DoTraverseAllTransactions(CF_Engine_t *engine_ptr, CF_Channel_t *chan, void *arg) -{ - CF_TraverseAllTransactions_State_t *state = arg; - - state->ret += CF_TraverseAllTransactions(chan, state->fn, state->context); - - return CFE_SUCCESS; -} - -/*---------------------------------------------------------------- - * - * Application-scope internal function - * See description in cf_utils.h for argument/return detail - * - *-----------------------------------------------------------------*/ -int32 CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context) -{ - CF_TraverseAllTransactions_State_t state; - - memset(&state, 0, sizeof(state)); - - state.fn = fn; - state.context = context; - - CF_ForEachChannel(CF_GetEngine(), CF_DoTraverseAllTransactions, &state); - - return state.ret; -} - /*---------------------------------------------------------------- * * Application-scope internal function @@ -608,6 +572,12 @@ CFE_Status_t CF_WrappedLseek(osal_id_t fd, off_t offset, int mode) * Application-scope internal function * See description in cf_utils.h for argument/return detail * + * NOTE: this function ranks high on the cyclic complexity scale + * simply due to its use of a switch/case statement with a fairly + * high number of cases. But there are only 3 distinct actions + * in the switch, but the scoring is based on the number of cases, + * not the number of different actions. + * *-----------------------------------------------------------------*/ CF_CFDP_ConditionCode_t CF_TxnStatus_To_ConditionCode(CF_TxnStatus_t txn_stat) { diff --git a/fsw/src/cf_utils.h b/fsw/src/cf_utils.h index a2e8c8e7..476b26d8 100644 --- a/fsw/src/cf_utils.h +++ b/fsw/src/cf_utils.h @@ -342,19 +342,6 @@ void CF_InsertSortPrio(CF_Transaction_t *txn, CF_QueueIdx_t queue); */ int32 CF_TraverseAllTransactions(CF_Channel_t *chan, CF_TraverseAllTransactions_fn_t fn, void *context); -/************************************************************************/ -/** @brief Traverses all transactions on all channels and performs an operation on them. - * - * @par Assumptions, External Events, and Notes: - * fn must be a valid function. context must not be NULL. - * - * @param fn Callback to invoke for all traversed transactions - * @param context Opaque object to pass to all callbacks - * - * @returns Number of transactions traversed - */ -int32 CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context); - /************************************************************************/ /** @brief List traversal function performs operation on every active transaction. * diff --git a/unit-test/cf_cfdp_dispatch_tests.c b/unit-test/cf_cfdp_dispatch_tests.c index 9f49941e..85632154 100644 --- a/unit-test/cf_cfdp_dispatch_tests.c +++ b/unit-test/cf_cfdp_dispatch_tests.c @@ -44,7 +44,7 @@ static void UT_CFDP_Dispatch_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Transaction_t ut_transaction; CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; + CF_Channel_t *local_channel_p = UT_CFDP_CHANNEL_PTR; /* * always clear all objects, regardless of what was asked for. diff --git a/unit-test/cf_cfdp_r_tests.c b/unit-test/cf_cfdp_r_tests.c index 1fc9699b..6c7fd16b 100644 --- a/unit-test/cf_cfdp_r_tests.c +++ b/unit-test/cf_cfdp_r_tests.c @@ -54,7 +54,7 @@ static void UT_CFDP_R_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Transaction_t ut_transaction; CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; + CF_Channel_t *local_channel_p = UT_CFDP_CHANNEL_PTR; /* * always clear all objects, regardless of what was asked for. diff --git a/unit-test/cf_cfdp_s_tests.c b/unit-test/cf_cfdp_s_tests.c index 2e7d8fc8..7d248635 100644 --- a/unit-test/cf_cfdp_s_tests.c +++ b/unit-test/cf_cfdp_s_tests.c @@ -77,7 +77,7 @@ static void UT_CFDP_S_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Transaction_t ut_transaction; CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; + CF_Channel_t *local_channel_p = UT_CFDP_CHANNEL_PTR; /* * always clear all objects, regardless of what was asked for. diff --git a/unit-test/cf_cfdp_sbintf_tests.c b/unit-test/cf_cfdp_sbintf_tests.c index 7340b88a..33490c6e 100644 --- a/unit-test/cf_cfdp_sbintf_tests.c +++ b/unit-test/cf_cfdp_sbintf_tests.c @@ -111,7 +111,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Transaction_t ut_transaction; CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; + CF_Channel_t *local_channel_p = UT_CFDP_CHANNEL_PTR; /* * always clear all objects, regardless of what was asked for. diff --git a/unit-test/cf_cfdp_tests.c b/unit-test/cf_cfdp_tests.c index 68504049..71748555 100644 --- a/unit-test/cf_cfdp_tests.c +++ b/unit-test/cf_cfdp_tests.c @@ -80,7 +80,7 @@ static void UT_CFDP_SetupBasicTestState(UT_CF_Setup_t setup, static CF_Transaction_t ut_transaction; CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *local_channel_p = &engine_ptr->channels[UT_CFDP_CHANNEL_IDX]; + CF_Channel_t *local_channel_p = UT_CFDP_CHANNEL_PTR; /* * always clear all objects, regardless of what was asked for. diff --git a/unit-test/cf_cmd_tests.c b/unit-test/cf_cmd_tests.c index c851467f..9af77064 100644 --- a/unit-test/cf_cmd_tests.c +++ b/unit-test/cf_cmd_tests.c @@ -53,7 +53,7 @@ CF_EntityId_t Any_CF_EntityId_t(void) /* uint8 used for Any_cf_polldir likely there will never be that many polldirs */ CF_PollIdxSelect_t Any_cf_polldir(void) { - return Any_uint8_LessThan(CF_MAX_POLLING_DIR_PER_CHAN); + return 1 + Any_uint8_LessThan(CF_MAX_POLLING_DIR_PER_CHAN); } /* bool_arg_t_barg should only be 0 or 1 (Boolean) */ @@ -85,7 +85,7 @@ typedef struct void *context; } CF_TsnChanAction_fn_t_context_t; -CF_ChanAction_Status_t Chan_action_fn_t(CF_Channel_t *chan_ptr, void *context) +CFE_Status_t Chan_action_fn_t(CF_Channel_t *chan_ptr, void *context) { /* This one does not need to save its context, just call default so count works */ return UT_DEFAULT_IMPL(Chan_action_fn_t); @@ -392,7 +392,7 @@ void Test_CF_ResetCountersCmd_tests_WhenCommandByteIs_all_AndResetAllMemValuesSe /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_STUB_COUNT(CF_ForEachChannel, 3); + UtAssert_STUB_COUNT(CF_ForEachChannel, 1); UT_CF_AssertEventID(CF_RESET_INF_EID); UtAssert_ZERO(CF_AppData.counters.cmd); @@ -429,6 +429,7 @@ void Test_CF_TxFileCmd(void) /* nominal, all zero should pass checks, just calls CF_CFDP_TxFile */ memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = CF_CFDP_Class_1; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); @@ -437,6 +438,7 @@ void Test_CF_TxFileCmd(void) UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = CF_CFDP_Class_2; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); @@ -446,6 +448,7 @@ void Test_CF_TxFileCmd(void) /* out of range arguments: bad class */ UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = 10; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); @@ -453,34 +456,48 @@ void Test_CF_TxFileCmd(void) UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = -10; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); - /* out of range arguments: bad channel */ + /* out of range arguments: bad channel (nonzero) */ UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); - msg->chan_num = CF_NUM_CHANNELS; + msg->chan_num = CF_ChannelSelect_FromInt(CF_NUM_CHANNELS + 1); UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); - /* out of range arguments: bad keep */ + /* out of range arguments: bad channel (0) */ UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); - msg->keep = 15; + msg->chan_num = CF_ChannelSelect_FromInt(0); + msg->cfdp_class = CF_CFDP_Class_1; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 4); + /* out of range arguments: bad keep */ + UT_CF_ResetEventCapture(); + memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; + msg->keep = 15; + UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); + UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 5); + /* CF_CFDP_TxFile fails*/ UT_CF_ResetEventCapture(); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_TxFile), -1); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; UtAssert_VOIDCALL(CF_TxFileCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_TX_FILE_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 5); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 6); } /******************************************************************************* @@ -501,17 +518,20 @@ void Test_CF_PlaybackDirCmd(void) /* nominal, all zero should pass checks, just calls CF_CFDP_PlaybackDir */ memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = CF_CFDP_Class_1; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = CF_CFDP_Class_2; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); /* out of range arguments: bad class */ memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = 10; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); @@ -519,6 +539,7 @@ void Test_CF_PlaybackDirCmd(void) UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; msg->cfdp_class = -10; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); @@ -527,7 +548,7 @@ void Test_CF_PlaybackDirCmd(void) /* out of range arguments: bad channel */ UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); - msg->chan_num = CF_NUM_CHANNELS; + msg->chan_num = CF_ChannelSelect_FromInt(CF_NUM_CHANNELS + 1); UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); @@ -535,7 +556,8 @@ void Test_CF_PlaybackDirCmd(void) /* out of range arguments: bad keep */ UT_CF_ResetEventCapture(); memset(msg, 0, sizeof(*msg)); - msg->keep = 15; + msg->chan_num = UT_CFDP_CHANNEL; + msg->keep = 15; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_BAD_PARAM_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 4); @@ -544,209 +566,12 @@ void Test_CF_PlaybackDirCmd(void) UT_CF_ResetEventCapture(); UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_PlaybackDir), -1); memset(msg, 0, sizeof(*msg)); + msg->chan_num = UT_CFDP_CHANNEL; UtAssert_VOIDCALL(CF_PlaybackDirCmd(&utbuf)); UT_CF_AssertEventID(CF_CMD_PLAYBACK_DIR_ERR_EID); UtAssert_UINT32_EQ(CF_AppData.counters.err, 5); } -/******************************************************************************* -** -** CF_DoChanAction tests -** -*******************************************************************************/ - -void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = CF_ALL_CHANNELS; - - UT_SetDeferredRetcode(UT_KEY(Chan_action_fn_t), 1, 1); - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS | 1); -} - -void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAll_fn_return_1_Return_1(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = CF_ALL_CHANNELS; - - UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 1); - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS | 1); -} - -void Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = CF_ALL_CHANNELS; - - UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 0); - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} - -void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = Any_cf_chan_num(); - - UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 1); - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, 1); -} - -void Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = Any_cf_chan_num(); - - UT_SetDefaultReturnValue(UT_KEY(Chan_action_fn_t), 0); - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, 0); -} - -void Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendEvent_(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - data = CF_NUM_CHANNELS; - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 0); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); - - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); -} - -void Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent(void) -{ - /* Arrange */ - CF_ChannelSelect_t data; - const char *arg_errstr = "CANNOT TEST SENT TO SEND EVENT"; - CF_ChanActionFn_t arg_fn = &Chan_action_fn_t; - int context; - void *arg_context = &context; - CF_ChanAction_Status_t local_result; - - /* force CF_ALL_CHANNELS to not be a selection possibility */ - data = CF_ALL_CHANNELS - 2; - - /* Act */ - local_result = CF_DoChanAction(data, arg_errstr, arg_fn, arg_context); - - /* Assert */ - UtAssert_STUB_COUNT(Chan_action_fn_t, 0); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); - - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); -} - -/******************************************************************************* -** -** CF_DoFreezeThaw tests -** -*******************************************************************************/ - -void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) -{ - /* Arrange */ - CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - CF_ChanAction_BoolArg_t context; - CF_ChanAction_Status_t local_result; - - context.barg = Any_bool_arg_t_barg(); - - /* set frozen to opposite to ensure change was done - not required for test, - * but it is helpful for verification that the function did the change */ - chan->stat.frozen = !context.barg; - - /* Act */ - local_result = CF_DoFreezeThaw(chan, &context); - - /* Assert */ - UtAssert_True(chan->stat.frozen == context.barg, - "CF_DoFreezeThaw set frozen to %d and should be %d (context->barg))", - chan->stat.frozen, - context.barg); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} - /************************************************************************** ** ** CF_FreezeCmd tests @@ -756,17 +581,15 @@ void Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0(void) void Test_CF_FreezeCmd_Set_frozen_To_1_AndAcceptCommand(void) { /* Arrange */ - CF_FreezeCmd_t utbuf; - CF_ChannelSelect_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_Channel_t *chan; + CF_FreezeCmd_t utbuf; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan; memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = Any_cf_chan_num(); - chan = CF_GetChannelPtr(data->ChannelSelect); - chan->stat.frozen = false; + chan = UT_CFDP_CHANNEL_PTR; + chan->stat.frozen = false; CF_AppData.counters.cmd = initial_hk_cmd_counter; @@ -796,7 +619,7 @@ void Test_CF_FreezeCmd_Set_frozen_To_1_AndRejectCommand(void) memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = CF_NUM_CHANNELS + 1; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; CF_AppData.counters.cmd = 0; @@ -859,7 +682,7 @@ void Test_CF_ThawCmd_Set_frozen_To_0_AndRejectCommand(void) memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = CF_NUM_CHANNELS + 1; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; CF_AppData.counters.cmd = 0; @@ -874,590 +697,290 @@ void Test_CF_ThawCmd_Set_frozen_To_0_AndRejectCommand(void) /******************************************************************************* ** -** CF_FindTransactionBySequenceNumberAllChannels tests +** CF_SuspendCmd tests ** *******************************************************************************/ -void Test_CF_FindTransactionBySequenceNumberAllChannels_WhenNoTransactionFoundReturn_NULL(void) +void Test_CF_SuspendCmd_InvalidChannel(void) { /* Arrange */ - CF_TransactionSeq_t arg_ts = Any_CF_TransactionSeq_t(); - CF_EntityId_t arg_eid = Any_CF_EntityId_t(); - CF_Transaction_t *local_result; - CF_Transaction_t *expected_result = NULL; - CF_Engine_t *engine_ptr = CF_GetEngine(); - - CF_FindTransactionBySequenceNumber_context_t context_CF_CFDP_FTBSN; + CF_SuspendCmd_t utbuf; - context_CF_CFDP_FTBSN.forced_return = NULL; + memset(&utbuf, 0, sizeof(utbuf)); - UT_SetDataBuffer(UT_KEY(CF_FindTransactionBySequenceNumber), - &context_CF_CFDP_FTBSN, - sizeof(context_CF_CFDP_FTBSN), - false); + /* Set to invalid channel */ + utbuf.Payload.chan_num = UT_CFDP_INVALID_CHANNEL; /* Act */ - local_result = CF_FindTransactionBySequenceNumberAllChannels(arg_ts, arg_eid); + CF_SuspendCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, CF_NUM_CHANNELS); - UtAssert_ADDRESS_EQ(context_CF_CFDP_FTBSN.chan, engine_ptr->channels); - UtAssert_UINT32_EQ(context_CF_CFDP_FTBSN.transaction_sequence_number, arg_ts); - UtAssert_UINT32_EQ(context_CF_CFDP_FTBSN.src_eid, arg_eid); - UtAssert_ADDRESS_EQ(local_result, expected_result); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UT_CF_AssertEventID(CF_CMD_SUSPRES_CHAN_ERR_EID); + + /* Assert incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } -void Test_CF_FindTransactionBySequenceNumberAllChannels_Return_TransactionFound(void) +void Test_CF_SuspendCmd_Success(void) { - /* Arrange */ - CF_TransactionSeq_t arg_ts = Any_CF_TransactionSeq_t(); - CF_EntityId_t arg_eid = Any_CF_EntityId_t(); - uint8 number_transaction_match = Any_uint8_LessThan(CF_NUM_CHANNELS); - CF_Transaction_t return_value; - CF_Transaction_t *local_result; - CF_Transaction_t *expected_result = &return_value; - int i = 0; - - CF_FindTransactionBySequenceNumber_context_t contexts_CF_CFDP_FTBSN[CF_NUM_CHANNELS]; - - /* set non-matching transactions */ - for (i = 0; i < number_transaction_match; ++i) - { - contexts_CF_CFDP_FTBSN[i].forced_return = NULL; - } - /* set matching transaction */ - contexts_CF_CFDP_FTBSN[i].forced_return = &return_value; + CF_SuspendCmd_t utbuf; + CF_Transaction_t txn; - UT_SetDataBuffer(UT_KEY(CF_FindTransactionBySequenceNumber), - &contexts_CF_CFDP_FTBSN, - sizeof(contexts_CF_CFDP_FTBSN), - false); + memset(&txn, 0, sizeof(txn)); + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + + /* This needs to invoke the callback thru CF_TraverseAllTransactions */ + UT_SetHandlerFunction(UT_KEY(CF_TraverseAllTransactions), UT_AltHandler_CF_TraverseAllTransactions_InvokeCb, &txn); /* Act */ - local_result = CF_FindTransactionBySequenceNumberAllChannels(arg_ts, arg_eid); + CF_SuspendCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, number_transaction_match + 1); - for (i = 0; i < number_transaction_match; ++i) - { - UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_GetChannelPtr(CF_ChannelSelect_FromInt(i))); - UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].transaction_sequence_number, arg_ts); - UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].src_eid, arg_eid); - } - UtAssert_ADDRESS_EQ(contexts_CF_CFDP_FTBSN[i].chan, CF_GetChannelPtr(CF_ChannelSelect_FromInt(i))); - UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].transaction_sequence_number, arg_ts); - UtAssert_UINT32_EQ(contexts_CF_CFDP_FTBSN[i].src_eid, arg_eid); - UtAssert_ADDRESS_EQ(local_result, expected_result); + UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_SUSPRES_INF_EID); } /******************************************************************************* ** -** CF_TsnChanAction tests +** CF_ResumeCmd tests ** *******************************************************************************/ -void Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotFoundAndReturn_neg1_Fail(void) +void Test_CF_ResumeCmd_InvalidChannel(void) { - /* Arrange */ - CF_Transaction_Payload_t utbuf; - CF_Transaction_Payload_t *arg_cmd = &utbuf; - char cmdstr[10]; /* 10 is arbitrary */ - const char arg_cmdstr[10]; /* 10 is arbitrary */ - CF_TsnChanAction_fn_t arg_fn = &Dummy_CF_TsnChanAction_fn_t; - int context; - void *arg_context = &context; - int i = 0; - - CF_FindTransactionBySequenceNumber_context_t contexts_CF_CFDP_FTBSN[CF_NUM_CHANNELS]; + CF_ResumeCmd_t utbuf; memset(&utbuf, 0, sizeof(utbuf)); - AnyRandomStringOfLettersOfLengthCopy(cmdstr, 10); - memcpy((char *)arg_cmdstr, &cmdstr, 10); - arg_cmd->chan_num = CF_COMPOUND_KEY; - - /* Arrange unstubbable: CF_FindTransactionBySequenceNumberAllChannels */ - /* set non-matching transactions */ - for (i = 0; i < CF_NUM_CHANNELS; ++i) - { - contexts_CF_CFDP_FTBSN[i].forced_return = NULL; - } - - UT_SetDataBuffer(UT_KEY(CF_FindTransactionBySequenceNumber), - &contexts_CF_CFDP_FTBSN, - sizeof(contexts_CF_CFDP_FTBSN), - false); + /* Invalid channel */ + utbuf.Payload.chan_num = UT_CFDP_INVALID_CHANNEL; /* Act */ - UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), -1); + CF_ResumeCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_TRANS_NOT_FOUND_ERR_EID); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UT_CF_AssertEventID(CF_CMD_SUSPRES_CHAN_ERR_EID); - UtAssert_STUB_COUNT(Dummy_CF_TsnChanAction_fn_t, 0); + /* Assert incremented counter */ + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } -void Test_CF_TsnChanAction_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionFoundRun_fn_AndReturn_CFE_SUCCESS(void) +void Test_CF_ResumeCmd_SuccessSame(void) { - /* Arrange */ - CF_Transaction_Payload_t utbuf; - CF_Transaction_Payload_t *arg_cmd = &utbuf; - char cmdstr[10]; /* 10 is arbitrary */ - const char arg_cmdstr[10]; /* 10 is arbitrary */ - CF_TsnChanAction_fn_t arg_fn = &Dummy_CF_TsnChanAction_fn_t; - int context; - void *arg_context = &context; - CF_Transaction_t txn; - CF_TsnChanAction_fn_t_context_t context_CF_TsnChanAction_fn_t; + CF_ResumeCmd_t utbuf; + CF_Transaction_t txn; + memset(&txn, 0, sizeof(txn)); memset(&utbuf, 0, sizeof(utbuf)); - AnyRandomStringOfLettersOfLengthCopy(cmdstr, 10); - memcpy((char *)arg_cmdstr, &cmdstr, 10); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; - arg_cmd->chan_num = CF_COMPOUND_KEY; + /* This needs to invoke the callback thru CF_TraverseAllTransactions */ + UT_SetHandlerFunction(UT_KEY(CF_TraverseAllTransactions), UT_AltHandler_CF_TraverseAllTransactions_InvokeCb, &txn); - UT_SetDataBuffer(UT_KEY(Dummy_CF_TsnChanAction_fn_t), - &context_CF_TsnChanAction_fn_t, - sizeof(context_CF_TsnChanAction_fn_t), - false); + /* Act */ + CF_ResumeCmd(&utbuf); - /* Arrange unstubbable: CF_FindTransactionBySequenceNumberAllChannels */ - CF_FindTransactionBySequenceNumber_context_t context_CF_CFDP_FTBSN; + /* Assert */ + UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_SUSPRES_SAME_INF_EID); +} - /* set matching transaction */ - context_CF_CFDP_FTBSN.forced_return = &txn; +/******************************************************************************* +** +** CF_CancelCmd tests +** +*******************************************************************************/ - UT_SetDataBuffer(UT_KEY(CF_FindTransactionBySequenceNumber), - &context_CF_CFDP_FTBSN, - sizeof(context_CF_CFDP_FTBSN), - false); +void Test_CF_CancelCmd_Success(void) +{ + CF_CancelCmd_t utbuf; + CF_Transaction_t txn; + + memset(&txn, 0, sizeof(txn)); + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + + /* This needs to invoke the callback thru CF_TraverseAllTransactions */ + UT_SetHandlerFunction(UT_KEY(CF_TraverseAllTransactions), UT_AltHandler_CF_TraverseAllTransactions_InvokeCb, &txn); /* Act */ - UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), 1); + CF_CancelCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_STUB_COUNT(Dummy_CF_TsnChanAction_fn_t, 1); - UtAssert_ADDRESS_EQ(context_CF_TsnChanAction_fn_t.txn, &txn); - UtAssert_ADDRESS_EQ(context_CF_TsnChanAction_fn_t.context, arg_context); + UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_CANCEL_INF_EID); } -void Test_CF_TsnChanAction_cmd_chan_Eq_CF_ALL_CHANNELS_Return_CF_TraverseAllTransactions_All_Channels(void) +void Test_CF_CancelCmd_SuccessSingleTxn(void) { - /* Arrange */ - CF_Transaction_Payload_t utbuf; - CF_Transaction_Payload_t *arg_cmd = &utbuf; - char cmdstr[10]; /* 10 is arbitrary */ - const char arg_cmdstr[10]; /* 10 is arbitrary */ - CF_TsnChanAction_fn_t arg_fn = &Dummy_CF_TsnChanAction_fn_t; - int context; - void *arg_context = &context; - int expected_result = Any_int(); - CF_TraverseAllTransactions_All_Channels_context_t context_CF_TATAC; + CF_CancelCmd_t utbuf; + CF_Transaction_t txn; + memset(&txn, 0, sizeof(txn)); memset(&utbuf, 0, sizeof(utbuf)); - AnyRandomStringOfLettersOfLengthCopy(cmdstr, 10); - memcpy((char *)arg_cmdstr, &cmdstr, 10); - - context_CF_TATAC.forced_return = expected_result; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.use_ts_eid = true; - arg_cmd->chan_num = CF_ALL_CHANNELS; - - UT_SetDataBuffer(UT_KEY(CF_TraverseAllTransactions_All_Channels), - &context_CF_TATAC, - sizeof(context_CF_TATAC), - false); + /* This needs to return a valid pointer from CF_FindTransactionBySequenceNumber */ + UT_SetHandlerFunction(UT_KEY(CF_FindTransactionBySequenceNumber), + UT_AltHandler_CF_FindTransactionBySequenceNumber, + &txn); /* Act */ - UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), expected_result); + CF_CancelCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_CANCEL_INF_EID); } -void Test_CF_TsnChanAction_cmd_chan_IsASingleChannel(void) +void Test_CF_CancelCmd_Failure(void) { - /* Arrange */ - CF_Transaction_Payload_t cmd; - int result = 1; - - memset(&cmd, 0, sizeof(cmd)); + CF_CancelCmd_t utbuf; - UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), result); + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; /* Act */ - UtAssert_INT32_EQ(CF_TsnChanAction(&cmd, NULL, NULL, NULL), result); + CF_CancelCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); + UT_CF_AssertEventID(CF_CMD_CANCEL_CHAN_ERR_EID); } -void Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid(void) +void Test_CF_CancelCmd_FailSingleTxn(void) { - /* Arrange */ - CF_Transaction_Payload_t utbuf; - CF_Transaction_Payload_t *arg_cmd = &utbuf; - const char arg_cmdstr[1] = ""; - CF_TsnChanAction_fn_t arg_fn = &Dummy_CF_TsnChanAction_fn_t; - int context; - void *arg_context = &context; + CF_CancelCmd_t utbuf; + CF_Transaction_t txn; + memset(&txn, 0, sizeof(txn)); memset(&utbuf, 0, sizeof(utbuf)); - arg_cmd->chan_num = CF_NUM_CHANNELS + 1; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.use_ts_eid = true; + + /* Note: default behavior of CF_FindTransactionBySequenceNumber() is to return NULL */ /* Act */ - UtAssert_INT32_EQ(CF_TsnChanAction(arg_cmd, arg_cmdstr, arg_fn, arg_context), -1); + CF_CancelCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_TSN_CHAN_INVALID_ERR_EID); + UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); + UT_CF_AssertEventID(CF_CMD_TRANS_NOT_FOUND_ERR_EID); + UT_CF_AssertEventID(CF_CMD_CANCEL_CHAN_ERR_EID); } /******************************************************************************* ** -** CF_DoSuspRes_Txn tests +** CF_AbandonCmd tests ** *******************************************************************************/ -void Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action(void) +void Test_CF_AbandonCmd_Success(void) { - /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - CF_ChanAction_SuspResArg_t context; - CF_ChanAction_SuspResArg_t *arg_context = &context; + CF_AbandonCmd_t utbuf; + CF_Transaction_t txn; - /* set same to 0 to ensure change was done - not required for test, - * but it is helpful for verification that the function did the change */ - arg_context->same = 0; - arg_context->action = AnyCoinFlip(); + memset(&txn, 0, sizeof(txn)); + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; - arg_t->flags.com.suspended = arg_context->action; + /* This needs to invoke the callback thru CF_TraverseAllTransactions */ + UT_SetHandlerFunction(UT_KEY(CF_TraverseAllTransactions), UT_AltHandler_CF_TraverseAllTransactions_InvokeCb, &txn); /* Act */ - CF_DoSuspRes_Txn(arg_t, arg_context); + CF_AbandonCmd(&utbuf); /* Assert */ - UtAssert_True(arg_context->same == 1, - "CF_DoSuspRes_Txn set context->same to %d and should be 1 (direct set)", - arg_context->same); + UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_ABANDON_INF_EID); } -void Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action(void) +void Test_CF_AbandonCmd_SuccessSingleTxn(void) { - /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - CF_ChanAction_SuspResArg_t context; - CF_ChanAction_SuspResArg_t *arg_context = &context; + CF_AbandonCmd_t utbuf; + CF_Transaction_t txn; - /* set same to 0 to ensure change was done - not required for test, - * but it is helpful for verification that the function did the change */ - arg_context->same = 0; - arg_context->action = AnyCoinFlip(); + memset(&txn, 0, sizeof(txn)); + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.use_ts_eid = true; - arg_t->flags.com.suspended = !arg_context->action; + /* This needs to return a valid pointer from CF_FindTransactionBySequenceNumber */ + UT_SetHandlerFunction(UT_KEY(CF_FindTransactionBySequenceNumber), + UT_AltHandler_CF_FindTransactionBySequenceNumber, + &txn); /* Act */ - CF_DoSuspRes_Txn(arg_t, arg_context); + CF_AbandonCmd(&utbuf); /* Assert */ - UtAssert_True(arg_t->flags.com.suspended == arg_context->action, - "CF_DoSuspRes_Txn set arg_t->flags.com.suspended to %d and should be %d (context->action)", - arg_t->flags.com.suspended, - arg_context->action); + UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_ABANDON_INF_EID); } -/******************************************************************************* -** -** CF_DoSuspRes tests -** -*******************************************************************************/ - -static void UT_AltHandler_CF_TraverseAllTransactions_SetSuspResArg(void *UserObj, - UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context) +void Test_CF_AbandonCmd_Failure(void) { - CF_ChanAction_SuspResArg_t *context = UT_Hook_GetArgValueByName(Context, "context", CF_ChanAction_SuspResArg_t *); - CF_ChanAction_SuspResArg_t *utargs = UserObj; - - if (context != NULL && utargs != NULL) - { - /* Update the caller-supplied context with the UT-supplied value */ - /* only "same" flag is an output, action is an input */ - context->same = utargs->same; - } -} + CF_AbandonCmd_t utbuf; -void Test_CF_DoSuspRes(void) -{ - /* Test case for: - * void CF_DoSuspRes(CF_Transaction_Payload_t *cmd, uint8 action) - */ + memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; - CF_Transaction_Payload_t utbuf; - CF_Transaction_Payload_t *cmd = &utbuf; - CF_ChanAction_SuspResArg_t utargs; + /* Nominally returns number of transactions acted on, force failure */ + UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), 0); - memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); - memset(&utargs, 0, sizeof(utargs)); - memset(cmd, 0, sizeof(*cmd)); + /* Act */ + CF_AbandonCmd(&utbuf); - /* nominal */ - /* With no setup, CF_TsnChanAction() invokes CF_TraverseAllTransactions stub, which returns 0 */ - /* this should increment the reject counter because it did not match any transactions */ - UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 0)); + /* Assert */ + UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); - - /* set up to match 1 transaction, should be accepted, but should not generate an event */ - UT_CF_ResetEventCapture(); - UT_SetDeferredRetcode(UT_KEY(CF_TraverseAllTransactions), 1, 1); - UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 1)); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_SUSPRES_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); - - /* Output the CF_ChanAction_SuspResArg_t back to the caller, to set the "same" flag to 1 */ - /* this gets the case where it attempts to set to the same value, and is rejected due to that */ - UT_CF_ResetEventCapture(); - UT_SetDeferredRetcode(UT_KEY(CF_TraverseAllTransactions), 1, 1); - utargs.same = 1; - UT_SetHandlerFunction(UT_KEY(CF_TraverseAllTransactions), - UT_AltHandler_CF_TraverseAllTransactions_SetSuspResArg, - &utargs); - UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 0)); - UT_CF_AssertEventID(CF_CMD_SUSPRES_SAME_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); - - /* Output the CF_ChanAction_SuspResArg_t back to the caller, to set the "same" flag to 1 */ - /* however this time CF_TraverseAllTransactions reports it matched multiple transactions, so it should NOT reject it - */ - UT_CF_ResetEventCapture(); - UT_SetDeferredRetcode(UT_KEY(CF_TraverseAllTransactions), 1, 10); - UtAssert_VOIDCALL(CF_DoSuspRes(cmd, 1)); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_SUSPRES_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 3); -} - -/******************************************************************************* -** -** CF_SuspendCmd tests -** -*******************************************************************************/ - -/* Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1 */ -void Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1(void) -{ - /* Arrange */ - CF_SuspendCmd_t utbuf; - - memset(&utbuf, 0, sizeof(utbuf)); - - /* Set to invalid channel */ - utbuf.Payload.chan_num = CF_NUM_CHANNELS; - - /* Act */ - CF_SuspendCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_TSN_CHAN_INVALID_ERR_EID); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[1], CF_CMD_SUSPRES_CHAN_ERR_EID); - - /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); -} - -/******************************************************************************* -** -** CF_ResumeCmd tests -** -*******************************************************************************/ - -/* Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0 */ -void Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0(void) -{ - CF_ResumeCmd_t utbuf; - - memset(&utbuf, 0, sizeof(utbuf)); - - /* Invalid channel */ - utbuf.Payload.chan_num = CF_NUM_CHANNELS; - - /* Act */ - CF_ResumeCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_TSN_CHAN_INVALID_ERR_EID); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[1], CF_CMD_SUSPRES_CHAN_ERR_EID); - - /* Assert incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); -} - -/******************************************************************************* -** -** CF_Cancel_TxnCmd tests -** -*******************************************************************************/ - -void Test_CF_Cancel_TxnCmd_Call_CF_CFDP_CancelTransaction_WithGiven_t(void) -{ - /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - void *arg_ignored = NULL; - CF_Transaction_t *context_CF_CFDP_CancelTransaction; - - UT_SetDataBuffer(UT_KEY(CF_CFDP_CancelTransaction), - &context_CF_CFDP_CancelTransaction, - sizeof(context_CF_CFDP_CancelTransaction), - false); - - /* Act */ - CF_Cancel_TxnCmd(arg_t, arg_ignored); - - /* Assert */ - UtAssert_ADDRESS_EQ(context_CF_CFDP_CancelTransaction, arg_t); -} - -/******************************************************************************* -** -** CF_CancelCmd tests -** -*******************************************************************************/ - -void Test_CF_CancelCmd_Success(void) -{ - CF_CancelCmd_t utbuf; - - memset(&utbuf, 0, sizeof(utbuf)); - - /* Nominally returns number of transactions affected, cause failure */ - UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), 1); - - /* Act */ - CF_CancelCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_CANCEL_INF_EID); -} - -void Test_CF_CancelCmd_Failure(void) -{ - CF_CancelCmd_t utbuf; - - memset(&utbuf, 0, sizeof(utbuf)); - - /* Nominally returns number of transactions affected, cause failure */ - UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), 0); - - /* Act */ - CF_CancelCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); - UT_CF_AssertEventID(CF_CMD_CANCEL_CHAN_ERR_EID); -} - -/******************************************************************************* -** -** CF_Abandon_TxnCmd tests -** -*******************************************************************************/ - -void Test_CF_Abandon_TxnCmd_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0(void) -{ - /* Arrange */ - CF_Transaction_t txn; - CF_Transaction_t *arg_t = &txn; - void *arg_ignored = NULL; - - /* Act */ - CF_Abandon_TxnCmd(arg_t, arg_ignored); - - /* Assert */ - UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); -} - -/******************************************************************************* -** -** CF_AbandonCmd tests -** -*******************************************************************************/ - -void Test_CF_AbandonCmd_Success(void) -{ - CF_AbandonCmd_t utbuf; - - memset(&utbuf, 0, sizeof(utbuf)); - - /* Nominally returns number of transactions affected, cause failure */ - UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), 1); - - /* Act */ - CF_AbandonCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_ABANDON_INF_EID); + UT_CF_AssertEventID(CF_CMD_ABANDON_CHAN_ERR_EID); } -void Test_CF_AbandonCmd_Failure(void) +void Test_CF_AbandonCmd_FailSingleTxn(void) { - CF_AbandonCmd_t utbuf; + CF_AbandonCmd_t utbuf; + CF_Transaction_t txn; + memset(&txn, 0, sizeof(txn)); memset(&utbuf, 0, sizeof(utbuf)); + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.use_ts_eid = true; - /* Nominally returns number of transactions acted on, force failure */ - UT_SetDefaultReturnValue(UT_KEY(CF_TraverseAllTransactions), 0); + /* Note: default behavior of CF_FindTransactionBySequenceNumber() is to return NULL */ /* Act */ CF_AbandonCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CF_TraverseAllTransactions, 1); + UtAssert_STUB_COUNT(CF_FindTransactionBySequenceNumber, 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); + UT_CF_AssertEventID(CF_CMD_TRANS_NOT_FOUND_ERR_EID); UT_CF_AssertEventID(CF_CMD_ABANDON_CHAN_ERR_EID); } -/******************************************************************************* -** -** CF_DoEnableDisableDequeue tests -** -*******************************************************************************/ - -void Test_CF_DoEnableDisableDequeue_Set_chan_num_EnabledFlagTo_context_barg(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_ChanAction_BoolArg_t context; - CF_ChanAction_BoolArg_t *arg_context = &context; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - - context.barg = Any_bool_arg_t_barg(); - - /* Act */ - CF_DoEnableDisableDequeue(chan, arg_context); - - /* Assert */ - UtAssert_True(chan->config.dequeue_enabled == context.barg, - "Channel %u dequeue_enabled is %u and should be %u (context->barg)", - CF_ChannelSelect_AsInt(chan_num), - chan->config.dequeue_enabled, - context.barg); -} - /******************************************************************************* ** ** CF_EnableDequeueCmd tests @@ -1511,7 +1034,7 @@ void Test_CF_EnableDequeueCmd_Failure(void) memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = CF_NUM_CHANNELS + 1; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; CF_AppData.counters.err = 0; @@ -1574,7 +1097,7 @@ void Test_CF_DisableDequeueCmd_Failure(void) memset(&utbuf, 0, sizeof(utbuf)); /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = CF_NUM_CHANNELS + 1; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; CF_AppData.counters.err = 0; @@ -1589,149 +1112,80 @@ void Test_CF_DisableDequeueCmd_Failure(void) /******************************************************************************* ** -** CF_DoEnableDisablePolldir tests +** CF_EnablePolldirCmd tests ** *******************************************************************************/ -void Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannelEnabledTo_context_barg(void) +void Test_CF_EnablePolldirCmd_InvalidChannel(void) { /* Arrange */ - CF_PollDirSelect_Payload_t utbuf; - CF_PollDirSelect_Payload_t *data = &utbuf; - CF_ChanAction_BoolMsgArg_t context; - CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 expected_enabled; - uint8 current_polldir = 0; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - - memset(&utbuf, 0, sizeof(utbuf)); - - data->PollDirIndx = CF_ALL_POLLDIRS; - - context.opaque_data = data; - context.barg = Any_bool_arg_t_barg(); - expected_enabled = context.barg; - - /* Act */ - local_result = CF_DoEnableDisablePolldir(chan, arg_context); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; + CF_LocalPdConfig_t *PdConfig; - /* Assert */ - for (current_polldir = 0; current_polldir < CF_MAX_POLLING_DIR_PER_CHAN; ++current_polldir) - { - UtAssert_True(chan->config.polldir[current_polldir].enabled == expected_enabled, - "Channel %u Polldir %u set to %u and should be %u (context->barg)", - CF_ChannelSelect_AsInt(chan_num), - current_polldir, - chan->config.polldir[current_polldir].enabled, - expected_enabled); - } - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} + CF_EnableDirPollingCmd_t utbuf; -void Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_context_ChannelEnabledTo_context_barg(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 polldir = Any_cf_polldir(); - CF_PollDirSelect_Payload_t utbuf; - CF_PollDirSelect_Payload_t *data = &utbuf; - CF_ChanAction_BoolMsgArg_t context; - CF_ChanAction_BoolMsgArg_t *arg_context = &context; - uint8 expected_enabled; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + PdConfig = &chan->config.polldir[CF_MAX_POLLING_DIR_PER_CHAN - 1]; - data->PollDirIndx = polldir; + PdConfig->enabled = false; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; + data->PollDirIndx = CF_ALL_POLLDIRS; - context.opaque_data = data; - context.barg = Any_bool_arg_t_barg(); - expected_enabled = context.barg; + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ - local_result = CF_DoEnableDisablePolldir(chan, arg_context); + CF_EnableDirPollingCmd(&utbuf); /* Assert */ - UtAssert_True(chan->config.polldir[polldir].enabled == expected_enabled, - "Channel %u Polldir %u set to %u and should be %u (context->barg)", - CF_ChannelSelect_AsInt(chan_num), - polldir, - chan->config.polldir[polldir].enabled, - expected_enabled); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); + UtAssert_BOOL_FALSE(PdConfig->enabled); + UtAssert_UINT16_EQ(CF_AppData.counters.err, initial_hk_err_counter + 1); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UT_CF_AssertEventID(CF_CMD_ENABLE_POLLDIR_ERR_EID); } -void Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_AndSendEvent(void) +void Test_CF_EnablePolldirCmd_AllPollDirs(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_PollDirSelect_Payload_t utbuf; - CF_PollDirSelect_Payload_t *data = &utbuf; - CF_ChanAction_BoolMsgArg_t context; - CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; + CF_LocalPdConfig_t *PdConfig; - memset(&utbuf, 0, sizeof(utbuf)); - - data->PollDirIndx = CF_MAX_POLLING_DIR_PER_CHAN; - - context.opaque_data = data; - context.barg = Any_bool_arg_t_barg(); - - /* Act */ - local_result = CF_DoEnableDisablePolldir(chan, arg_context); - - /* Assert */ - UT_CF_AssertEventID(CF_CMD_POLLDIR_INVALID_ERR_EID); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); -} + CF_EnableDirPollingCmd_t utbuf; -void Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_PollDirSelect_Payload_t utbuf; - CF_PollDirSelect_Payload_t *data = &utbuf; - CF_ChanAction_BoolMsgArg_t context; - CF_ChanAction_BoolMsgArg_t *arg_context = &context; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + PdConfig = &chan->config.polldir[CF_MAX_POLLING_DIR_PER_CHAN - 1]; - data->PollDirIndx = CF_MAX_POLLING_DIR_PER_CHAN; + PdConfig->enabled = false; + data->ChannelSelect = UT_CFDP_CHANNEL; + data->PollDirIndx = CF_ALL_POLLDIRS; - context.opaque_data = data; - context.barg = Any_bool_arg_t_barg(); + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ - local_result = CF_DoEnableDisablePolldir(chan, arg_context); + CF_EnableDirPollingCmd(&utbuf); /* Assert */ - UT_CF_AssertEventID(CF_CMD_POLLDIR_INVALID_ERR_EID); + UtAssert_BOOL_TRUE(PdConfig->enabled); + UtAssert_UINT16_EQ(CF_AppData.counters.cmd, initial_hk_cmd_counter + 1); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); + UT_CF_AssertEventID(CF_CMD_ENABLE_POLLDIR_INF_EID); } -/******************************************************************************* -** -** CF_EnablePolldirCmd tests -** -*******************************************************************************/ - void Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 polldir = Any_cf_polldir(); - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 polldir = Any_cf_polldir(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_LocalPdConfig_t *PdConfig; CF_EnableDirPollingCmd_t utbuf; @@ -1739,6 +1193,7 @@ void Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess(void) uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + PdConfig = &chan->config.polldir[polldir - 1]; /* Arrange unstubbable: CF_DoChanAction */ data->ChannelSelect = chan_num; @@ -1753,11 +1208,11 @@ void Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess(void) /* Assert */ /* Assert for CF_DoEnableDisablePolldir */ - UtAssert_True(chan->config.polldir[polldir].enabled == 1, + UtAssert_True(PdConfig->enabled == 1, "Channel %u Polldir %u set to %u and should be 1 (context->barg)", CF_ChannelSelect_AsInt(chan_num), polldir, - chan->config.polldir[polldir].enabled); + PdConfig->enabled); /* Assert for incremented counter */ UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), "CF_AppData.counters.cmd is %d and should be 1 more than %d", @@ -1770,7 +1225,7 @@ void Test_CF_EnablePolldirCmd_FailWhenActionFail(void) { /* Arrange */ CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); + uint8 error_polldir = 1 + CF_MAX_POLLING_DIR_PER_CHAN; CF_EnableDirPollingCmd_t utbuf; CF_PollDirSelect_Payload_t *data = &utbuf.Payload; @@ -1805,62 +1260,23 @@ void Test_CF_EnablePolldirCmd_FailWhenActionFail(void) ** *******************************************************************************/ -void Test_CF_DisablePolldirCmd_SuccessWhenActionSuccess(void) +void Test_CF_DisablePolldirCmd_InvalidChannel(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 polldir = Any_cf_polldir(); - - CF_DisableDirPollingCmd_t utbuf; - CF_PollDirSelect_Payload_t *data = &utbuf.Payload; - uint16 initial_hk_cmd_counter = Any_uint16(); - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; + CF_LocalPdConfig_t *PdConfig; - memset(&utbuf, 0, sizeof(utbuf)); + CF_DisableDirPollingCmd_t utbuf; - /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = chan_num; - - /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->PollDirIndx = polldir; - - CF_AppData.counters.cmd = initial_hk_cmd_counter; - - /* Act */ - CF_DisableDirPollingCmd(&utbuf); - - /* Assert */ - /* Assert for CF_DoEnableDisablePolldir */ - UtAssert_True(chan->config.polldir[polldir].enabled == 0, - "Channel %u Polldir %u set to %u and should be 0 (context->barg)", - CF_ChannelSelect_AsInt(chan_num), - polldir, - chan->config.polldir[polldir].enabled); - /* Assert for incremented counter */ - UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), - "CF_AppData.counters.cmd is %d and should be 1 more than %d", - CF_AppData.counters.cmd, - initial_hk_cmd_counter); - UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_INF_EID); -} - -void Test_CF_DisablePolldirCmd_FailWhenActionFail(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 error_polldir = Any_uint8_BetweenInclusive(CF_MAX_POLLING_DIR_PER_CHAN, CF_ALL_CHANNELS - 1); - - CF_DisableDirPollingCmd_t utbuf; CF_PollDirSelect_Payload_t *data = &utbuf.Payload; uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + PdConfig = &chan->config.polldir[CF_MAX_POLLING_DIR_PER_CHAN - 1]; - /* Arrange unstubbable: CF_DoChanAction */ - data->ChannelSelect = chan_num; - - /* Arrange unstubbable: CF_DoEnableDisablePolldir */ - data->PollDirIndx = error_polldir; + PdConfig->enabled = true; + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; + data->PollDirIndx = CF_ALL_POLLDIRS; CF_AppData.counters.err = initial_hk_err_counter; @@ -1868,252 +1284,151 @@ void Test_CF_DisablePolldirCmd_FailWhenActionFail(void) CF_DisableDirPollingCmd(&utbuf); /* Assert */ - /* Assert for CF_DoEnableDisablePolldir */ - /* Assert for incremented counter*/ - UtAssert_True(CF_AppData.counters.err == (uint16)(initial_hk_err_counter + 1), - "CF_AppData.counters.err is %d and should be 1 more than %d", - CF_AppData.counters.err, - initial_hk_err_counter); - UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_ERR_EID); -} + UtAssert_BOOL_TRUE(PdConfig->enabled); + UtAssert_UINT16_EQ(CF_AppData.counters.err, initial_hk_err_counter + 1); -/******************************************************************************* -** -** CF_PurgeHistory tests -** -*******************************************************************************/ - -void Test_CF_PurgeHistory_Call_CF_CFDP_ResetHistory_AndReturn_CLIST_CONT(void) -{ - /* Arrange */ - CF_History_t history; - CF_CListNode_t *arg_n = &history.cl_node; - CF_Channel_t chan; - CF_Channel_t *arg_c = &chan; - CF_CListTraverse_Status_t local_result; - CF_CFDP_ResetHistory_context_t context_CF_CFDP_ResetHistory; - - UT_SetDataBuffer(UT_KEY(CF_ResetHistory), - &context_CF_CFDP_ResetHistory, - sizeof(context_CF_CFDP_ResetHistory), - false); - - /* Act */ - local_result = CF_PurgeHistory(arg_n, arg_c); - - /* Assert */ - UtAssert_ADDRESS_EQ(context_CF_CFDP_ResetHistory.chan, arg_c); - UtAssert_ADDRESS_EQ(context_CF_CFDP_ResetHistory.history, &history); - UtAssert_True(local_result == CF_CLIST_CONT, - "CF_PurgeHistory returned %d and should be %d (CF_CLIST_CONT)", - local_result, - CF_CLIST_CONT); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_ERR_EID); } -/******************************************************************************* -** -** CF_PurgeTransaction tests -** -*******************************************************************************/ - -void Test_CF_PurgeTransaction_Call_CF_CFDP_ResetTransaction_AndReturn_CLIST_CONT(void) +void Test_CF_DisablePolldirCmd_AllPollDirs(void) { /* Arrange */ - CF_Transaction_t txn; - CF_CListNode_t *arg_n = &txn.cl_node; - int ignored; - void *arg_ignored = &ignored; - - /* Act */ - UtAssert_INT32_EQ(CF_PurgeTransaction(arg_n, arg_ignored), CF_CLIST_CONT); - - /* Assert */ - UtAssert_STUB_COUNT(CF_CFDP_FinishTransaction, 1); -} + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; + CF_LocalPdConfig_t *PdConfig; -/******************************************************************************* -** -** CF_DoPurgeQueue tests -** -*******************************************************************************/ + CF_DisableDirPollingCmd_t utbuf; -void Test_CF_DoPurgeQueue_PendOnly(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_QueueSelect_Payload_t utbuf; - CF_QueueSelect_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_CListNode_t start; - CF_CListNode_t *expected_start = &start; - CF_ChanAction_Status_t local_result; - CF_CList_Traverse_POINTER_context_t context_CF_CList_Traverse; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + PdConfig = &chan->config.polldir[CF_MAX_POLLING_DIR_PER_CHAN - 1]; - data->ChannelSelect = chan_num; - data->QueueSelect = CF_QueueSelect_Pending; /* pend */ - UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), - UT_AltHandler_CF_CList_Traverse_POINTER, - &context_CF_CList_Traverse); + PdConfig->enabled = true; + data->ChannelSelect = UT_CFDP_CHANNEL; + data->PollDirIndx = CF_ALL_POLLDIRS; - chan->qs[CF_QueueIdx_PEND] = expected_start; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ - local_result = CF_DoPurgeQueue(chan, &msgarg); + CF_DisableDirPollingCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CF_CList_Traverse, 1); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse.start, expected_start); - UtAssert_True(context_CF_CList_Traverse.fn == CF_PurgeTransaction, - "context_CF_CList_Traverse.fn == CF_PurgeTransaction"); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse.context, NULL); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} - -void Test_CF_DoPurgeQueue_HistoryOnly(void) -{ - /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_QueueSelect_Payload_t utbuf; - CF_QueueSelect_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_CListNode_t start; - CF_CListNode_t *expected_start = &start; - CF_ChanAction_Status_t local_result; - CF_CList_Traverse_POINTER_context_t context_CF_CList_Traverse; - - memset(&utbuf, 0, sizeof(utbuf)); - - data->ChannelSelect = chan_num; - data->QueueSelect = CF_QueueSelect_History; /* history */ - - /* set correct context type for CF_CList_Traverse stub */ - UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), - UT_AltHandler_CF_CList_Traverse_POINTER, - &context_CF_CList_Traverse); - - chan->qs[CF_QueueIdx_HIST] = expected_start; + UtAssert_BOOL_FALSE(PdConfig->enabled); + UtAssert_UINT16_EQ(CF_AppData.counters.cmd, initial_hk_cmd_counter + 1); - /* Act */ - local_result = CF_DoPurgeQueue(chan, &msgarg); - - /* Assert */ - UtAssert_STUB_COUNT(CF_CList_Traverse, 1); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse.start, expected_start); - UtAssert_True(context_CF_CList_Traverse.fn == (CF_CListFn_t)CF_PurgeHistory, - "context_CF_CList_Traverse.fn == (CF_CListFn_t )CF_PurgeHistory"); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse.context, chan); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); + UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_INF_EID); } -void Test_CF_DoPurgeQueue_Both(void) +void Test_CF_DisablePolldirCmd_SuccessWhenActionSuccess(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_QueueSelect_Payload_t utbuf; - CF_QueueSelect_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); - CF_CListNode_t pend_start; - CF_CListNode_t *expected_pend_start = &pend_start; - CF_CListNode_t history_start; - CF_CListNode_t *expected_history_start = &history_start; - CF_ChanAction_Status_t local_result; - CF_CList_Traverse_POINTER_context_t context_CF_CList_Traverse[2]; + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 polldir = Any_cf_polldir(); + + CF_DisableDirPollingCmd_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_cmd_counter = Any_uint16(); + CF_Channel_t *chan = CF_GetChannelPtr(chan_num); memset(&utbuf, 0, sizeof(utbuf)); + /* Arrange unstubbable: CF_DoChanAction */ data->ChannelSelect = chan_num; - data->QueueSelect = CF_QueueSelect_All; /* both */ - /* set correct context type for CF_CList_Traverse stub */ - /* this must use data buffer hack to pass multiple contexts */ - UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_POINTER, NULL); - UT_SetDataBuffer(UT_KEY(CF_CList_Traverse), context_CF_CList_Traverse, sizeof(context_CF_CList_Traverse), false); + /* Arrange unstubbable: CF_DoEnableDisablePolldir */ + data->PollDirIndx = polldir; - chan->qs[CF_QueueIdx_PEND] = expected_pend_start; - chan->qs[CF_QueueIdx_HIST] = expected_history_start; + CF_AppData.counters.cmd = initial_hk_cmd_counter; /* Act */ - local_result = CF_DoPurgeQueue(chan, &msgarg); + CF_DisableDirPollingCmd(&utbuf); /* Assert */ - UtAssert_STUB_COUNT(CF_CList_Traverse, 2); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse[0].start, expected_pend_start); - UtAssert_True(context_CF_CList_Traverse[0].fn == CF_PurgeTransaction, - "context_CF_CList_Traverse[0].fn == CF_PurgeTransaction"); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse[0].context, NULL); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse[1].start, expected_history_start); - UtAssert_True(context_CF_CList_Traverse[1].fn == (CF_CListFn_t)CF_PurgeHistory, - "context_CF_CList_Traverse[1].fn == (CF_CListFn_t )CF_PurgeHistory"); - UtAssert_ADDRESS_EQ(context_CF_CList_Traverse[1].context, chan); - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); + /* Assert for CF_DoEnableDisablePolldir */ + UtAssert_True(chan->config.polldir[polldir].enabled == 0, + "Channel %u Polldir %u set to %u and should be 0 (context->barg)", + CF_ChannelSelect_AsInt(chan_num), + polldir, + chan->config.polldir[polldir].enabled); + /* Assert for incremented counter */ + UtAssert_True(CF_AppData.counters.cmd == (uint16)(initial_hk_cmd_counter + 1), + "CF_AppData.counters.cmd is %d and should be 1 more than %d", + CF_AppData.counters.cmd, + initial_hk_cmd_counter); + UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_INF_EID); } -void Test_CF_DoPurgeQueue_GivenBad_data_byte_1_SendEventAndReturn_neg1(void) +void Test_CF_DisablePolldirCmd_FailWhenActionFail(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_QueueSelect_Payload_t utbuf; - CF_QueueSelect_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_ChannelSelect_t chan_num = Any_cf_chan_num(); + uint8 error_polldir = 1 + CF_MAX_POLLING_DIR_PER_CHAN; + + CF_DisableDirPollingCmd_t utbuf; + CF_PollDirSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); + /* Arrange unstubbable: CF_DoChanAction */ data->ChannelSelect = chan_num; - data->QueueSelect = 10; /* Invalid */ + + /* Arrange unstubbable: CF_DoEnableDisablePolldir */ + data->PollDirIndx = error_polldir; + + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ - local_result = CF_DoPurgeQueue(chan, &msgarg); + CF_DisableDirPollingCmd(&utbuf); /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_PURGE_ARG_ERR_EID); - UtAssert_STUB_COUNT(CF_CList_Traverse, 0); + /* Assert for CF_DoEnableDisablePolldir */ + /* Assert for incremented counter*/ + UtAssert_True(CF_AppData.counters.err == (uint16)(initial_hk_err_counter + 1), + "CF_AppData.counters.err is %d and should be 1 more than %d", + CF_AppData.counters.err, + initial_hk_err_counter); + UT_CF_AssertEventID(CF_CMD_DISABLE_POLLDIR_ERR_EID); } -void Test_CF_DoPurgeQueue_AnyGivenBad_data_byte_1_SendEventAndReturn_neg1(void) +/******************************************************************************* +** +** CF_PurgeQueueCmd tests +** +*******************************************************************************/ + +void Test_CF_PurgeQueueCmd_InvalidChannel(void) { /* Arrange */ - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - CF_QueueSelect_Payload_t utbuf; - CF_QueueSelect_Payload_t *data = &utbuf; - CF_ChanAction_MsgArg_t msgarg = { data }; - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + CF_PurgeQueueCmd_t utbuf; + CF_QueueSelect_Payload_t *data = &utbuf.Payload; + uint16 initial_hk_err_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); - data->ChannelSelect = chan_num; - data->QueueSelect = Any_uint8_GreaterThan(CF_QueueSelect_All); + data->ChannelSelect = UT_CFDP_INVALID_CHANNEL; + + CF_AppData.counters.err = initial_hk_err_counter; /* Act */ - local_result = CF_DoPurgeQueue(chan, &msgarg); + CF_PurgeQueueCmd(&utbuf); /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_PURGE_ARG_ERR_EID); - UtAssert_STUB_COUNT(CF_CList_Traverse, 0); -} + UtAssert_UINT16_EQ(CF_AppData.counters.err, initial_hk_err_counter + 1); -/******************************************************************************* -** -** CF_PurgeQueueCmd tests -** -*******************************************************************************/ + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 2); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UT_CF_AssertEventID(CF_CMD_PURGE_QUEUE_ERR_EID); +} void Test_CF_PurgeQueueCmd_FailWhenActionFail(void) { /* Arrange */ CF_ChannelSelect_t chan_num = Any_cf_chan_num(); - uint8 error_purge = CF_QueueSelect_All + 1; /* Shortest return from CF_DoPurgeQueue */ + uint8 error_purge = 0xAA; /* Shortest return from CF_DoPurgeQueue */ CF_PurgeQueueCmd_t utbuf; CF_QueueSelect_Payload_t *data = &utbuf.Payload; uint16 initial_hk_err_counter = Any_uint16(); @@ -2138,6 +1453,7 @@ void Test_CF_PurgeQueueCmd_FailWhenActionFail(void) "CF_AppData.counters.err is %d and should be 1 more than %d", CF_AppData.counters.err, initial_hk_err_counter); + UT_CF_AssertEventID(CF_CMD_PURGE_ARG_ERR_EID); UT_CF_AssertEventID(CF_CMD_PURGE_QUEUE_ERR_EID); } @@ -2155,6 +1471,9 @@ void Test_CF_PurgeQueueCmd_SuccessWhenActionSuccess(void) CF_AppData.counters.cmd = 0; + /* this causes the callback to be invoked */ + UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_InvokeCb, NULL); + /* Act */ CF_PurgeQueueCmd(&utbuf); @@ -2182,31 +1501,7 @@ void Test_CF_WriteQueueCmd_When_chan_Eq_CF_NUM_CAHNNELS_SendEventAndRejectComman memset(&utbuf, 0, sizeof(utbuf)); /* invalid channel */ - wq->chan = CF_NUM_CHANNELS; - - CF_AppData.counters.err = initial_hk_err_counter; - - /* Act */ - CF_WriteQueueCmd(&utbuf); - - /* Assert */ - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_WQ_CHAN_ERR_EID); - /* Assert for incremented counter */ - UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); -} - -void Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRejectCommand(void) -{ - /* Arrange */ - CF_WriteQueueCmd_t utbuf; - CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - uint16 initial_hk_err_counter = Any_uint16(); - - memset(&utbuf, 0, sizeof(utbuf)); - - /* invalid channel */ - wq->chan = CF_NUM_CHANNELS + 1; + wq->chan_num = UT_CFDP_INVALID_CHANNEL; CF_AppData.counters.err = initial_hk_err_counter; @@ -2215,8 +1510,7 @@ void Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRej /* Assert */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UT_CF_AssertEventID(CF_CMD_WQ_CHAN_ERR_EID); - + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.err, (initial_hk_err_counter + 1) & 0xFFFF); } @@ -2231,11 +1525,11 @@ void Test_CF_WriteQueueCmd_WhenUpAndPendingQueueSendEventAndRejectCommand(void) memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* invalid combination up direction, pending queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_Pending; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_Pending; CF_AppData.counters.err = initial_hk_err_counter; @@ -2262,11 +1556,11 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_Is_type_up_And_queue_ memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination up direction, NOT pending queue */ - wq->type = CF_Type_up; - wq->queue = Any_queue_Except_q_pend(); /* 0 is q_pend */ + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_Active; /* invalid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2305,11 +1599,11 @@ void Test_CF_WriteQueueCmd_When_CF_WrappedCreat_Fails_type_IsNot_type_up_And_que memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination down direction, pending queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_Pending; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_Pending; /* invalid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); @@ -2343,7 +1637,6 @@ void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); uint16 initial_hk_err_counter = Any_uint16(); @@ -2351,22 +1644,15 @@ void Test_CF_WriteQueueCmd_When_wq_IsAllAnd_queue_IsAll_fd_Is_0_Call_CF_WrappedC memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_all; - wq->queue = CF_QueueSelect_All; + wq->dir_type = CF_DirectionType_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = 0; - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteTxnQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, @@ -2395,7 +1681,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); int32 context_CF_WrappedClose_fd; @@ -2404,22 +1689,15 @@ void Test_CF_WriteQueueCmd_When_CF_WriteTxnQueueDataToFile_FailsAnd_wq_IsUpAnd_q memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_Active; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteTxnQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, @@ -2450,7 +1728,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); int32 context_CF_WrappedClose_fd; @@ -2459,22 +1736,15 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsUpA memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_History; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteHistoryQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteHistoryQueueDataToFile), &context_CF_WriteHistoryQueueDataToFile, @@ -2505,7 +1775,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); int32 context_CF_WrappedClose_fd; @@ -2514,22 +1783,15 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryDataToFile_FailsOnFirstCallAnd_wq memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_Active; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteTxnQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, @@ -2560,7 +1822,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteTxnQueueDataToFile_context_t context_CF_WriteTxnQueueDataToFile; int32 forced_return_CF_WriteTxnQueueDataToFile = Any_int32_Except(0); int32 context_CF_WrappedClose_fd; @@ -2569,22 +1830,15 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_Pending; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteTxnQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteTxnQueueDataToFile), &context_CF_WriteTxnQueueDataToFile, @@ -2615,7 +1869,6 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; CF_WriteHistoryQueueDataToFile_context_t context_CF_WriteHistoryQueueDataToFile; int32 forced_return_CF_WriteHistoryQueueDataToFile = Any_int32_Except(0); int32 context_CF_WrappedClose_fd; @@ -2624,22 +1877,15 @@ void Test_CF_WriteQueueCmd_When_CF_WriteHistoryQueueDataToFile_FailsAnd_wq_IsDow memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_History; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* invalid result from CF_WriteHistoryQueueDataToFile */ UT_SetDataBuffer(UT_KEY(CF_WriteHistoryQueueDataToFile), &context_CF_WriteHistoryQueueDataToFile, @@ -2669,30 +1915,22 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_all; - wq->queue = CF_QueueSelect_All; + wq->dir_type = CF_DirectionType_all; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -2709,7 +1947,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_All(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 2); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2720,29 +1958,21 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_all; - wq->queue = CF_QueueSelect_History; + wq->dir_type = CF_DirectionType_all; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); @@ -2756,7 +1986,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_History(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 2); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2767,29 +1997,21 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_all; - wq->queue = CF_QueueSelect_Active; + wq->dir_type = CF_DirectionType_all; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -2803,7 +2025,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Active(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2814,29 +2036,21 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_all; - wq->queue = CF_QueueSelect_Pending; + wq->dir_type = CF_DirectionType_all; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -2850,7 +2064,7 @@ void Test_CF_WriteQueueCmd_Success_type_AllAnd_q_Pend(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2861,30 +2075,22 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_All; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -2901,7 +2107,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_All(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2912,29 +2118,21 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteHistoryQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_History; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteHistoryQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteHistoryQueueDataToFile), forced_return_CF_WriteHistoryQueueDataToFile); @@ -2948,7 +2146,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_History(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -2959,29 +2157,21 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_up; - wq->queue = CF_QueueSelect_Active; + wq->dir_type = CF_DirectionType_up; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -2995,7 +2185,7 @@ void Test_CF_WriteQueueCmd_Success_type_UpAnd_q_Active(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -3008,29 +2198,21 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_All(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_All; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_All; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -3044,7 +2226,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_All(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -3055,29 +2237,21 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_History; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_History; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -3091,7 +2265,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_History(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 1); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -3102,29 +2276,21 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_Active; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_Active; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -3138,7 +2304,7 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Active(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } @@ -3149,29 +2315,21 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) CF_WriteQueueCmd_t utbuf; CF_WriteQueue_Payload_t *wq = &utbuf.Payload; - CF_WrappedOpenCreate_context_t context_CF_WrappedOpenCreate; - int32 forced_return_CF_WriteTxnQueueDataToFile = 0; - uint16 initial_hk_cmd_counter = Any_uint16(); + int32 forced_return_CF_WriteTxnQueueDataToFile = 0; + uint16 initial_hk_cmd_counter = Any_uint16(); memset(&utbuf, 0, sizeof(utbuf)); /* valid channel */ - wq->chan = Any_cf_chan_num(); + wq->chan_num = Any_cf_chan_num(); /* valid combination all direction, all queue */ - wq->type = CF_Type_down; - wq->queue = CF_QueueSelect_Pending; + wq->dir_type = CF_DirectionType_down; + wq->queue = CF_QueueSelect_Pending; /* valid result from CF_WrappedCreat */ strncpy(wq->filename, AnyRandomStringOfLettersOfLength(10), 10); - context_CF_WrappedOpenCreate.forced_return = Any_int_Positive(); - - UT_SetDataBuffer(UT_KEY(CF_WrappedOpenCreate), - &context_CF_WrappedOpenCreate, - sizeof(context_CF_WrappedOpenCreate), - false); - /* valid result from CF_WriteTxnQueueDataToFile */ UT_SetDefaultReturnValue(UT_KEY(CF_WriteTxnQueueDataToFile), forced_return_CF_WriteTxnQueueDataToFile); @@ -3185,249 +2343,251 @@ void Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend(void) UtAssert_STUB_COUNT(CF_WriteHistoryQueueDataToFile, 0); UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_WQ_INF_EID); - UtAssert_STUB_COUNT(CF_WrappedClose, 0); + UtAssert_STUB_COUNT(CF_WrappedClose, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, (initial_hk_cmd_counter + 1) & 0xFFFF); } /******************************************************************************* ** -** CF_ValidateChunkSizeCmd tests +** CF_SetParamCmd tests ** *******************************************************************************/ -void Test_CF_ValidateChunkSizeCmd_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1(void) +void Test_CF_SetParamCmd_Nominal(void) { - /* Arrange */ - size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t) + 1; - CF_ChanAction_Status_t local_result; + CF_SetParamCmd_t utbuf; + CF_GetSet_ValueID_t param_id; + uint16 expected_count; + CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); + memset(&utbuf, 0, sizeof(utbuf)); + expected_count = 0; - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); -} + /* Nominal: "set" for each parameter. 0 is reserved, valid values start at 1. */ + for (param_id = 1; (int)param_id < CF_GetSet_ValueID_MAX; ++param_id) + { + UT_CF_ResetEventCapture(); + utbuf.Payload.key = param_id; + utbuf.Payload.value = 1 + param_id; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + + /* run the function under test */ + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); -void Test_CF_ValidateChunkSizeCmd_Any_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1(void) + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, ++expected_count); + } + + /* each of the config parameters should have actually been set to a different value */ + UtAssert_UINT32_EQ(engine_ptr->config.ticks_per_second, 1 + CF_GetSet_ValueID_ticks_per_second); + UtAssert_UINT32_EQ(engine_ptr->config.rx_crc_calc_bytes_per_wakeup, + 1 + CF_GetSet_ValueID_rx_crc_calc_bytes_per_wakeup); + UtAssert_UINT32_EQ(chan->config.ack_timer_s, 1 + CF_GetSet_ValueID_ack_timer_s); + UtAssert_UINT32_EQ(chan->config.nak_timer_s, 1 + CF_GetSet_ValueID_nak_timer_s); + UtAssert_UINT32_EQ(chan->config.inactivity_timer_s, 1 + CF_GetSet_ValueID_inactivity_timer_s); + UtAssert_UINT32_EQ(engine_ptr->config.outgoing_file_chunk_size, 1 + CF_GetSet_ValueID_outgoing_file_chunk_size); + UtAssert_UINT32_EQ(chan->config.ack_limit, 1 + CF_GetSet_ValueID_ack_limit); + UtAssert_UINT32_EQ(chan->config.nak_limit, 1 + CF_GetSet_ValueID_nak_limit); + UtAssert_UINT32_EQ(engine_ptr->config.local_eid, 1 + CF_GetSet_ValueID_local_eid); + UtAssert_UINT32_EQ(chan->config.max_outgoing_messages_per_wakeup, + 1 + CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup); +} + +void Test_CF_SetParamCmd_BadParam(void) { - /* Arrange */ - uint32 arg_val = Any_uint32_GreaterThan(sizeof(CF_CFDP_PduFileDataContent_t)); - CF_ChanAction_Status_t local_result; + CF_SetParamCmd_t utbuf; - /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); + memset(&utbuf, 0, sizeof(utbuf)); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); + /* Bad param ID (0)*/ + utbuf.Payload.key = 0; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); + + /* Bad param ID (high)*/ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = CF_GetSet_ValueID_MAX; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); + + /* Bad channel ID */ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = 1; + utbuf.Payload.chan_num = UT_CFDP_INVALID_CHANNEL; + + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); } -void Test_CF_ValidateChunkSizeCmd_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0(void) +void Test_CF_SetParamCmd_ValidateChunkSize(void) { - /* Arrange */ - size_t arg_val = sizeof(CF_CFDP_PduFileDataContent_t); - CF_ChanAction_Status_t local_result; + CF_SetParamCmd_t utbuf; - /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); + memset(&utbuf, 0, sizeof(utbuf)); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} + /* Validation fail, chunk size 0 */ + utbuf.Payload.key = CF_GetSet_ValueID_outgoing_file_chunk_size; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.value = 0; + + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET_VALIDATE_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); + + /* Validation fail, chunk size too high */ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = CF_GetSet_ValueID_outgoing_file_chunk_size; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.value = 100 + sizeof(CF_CFDP_PduFileDataContent_t); + + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET_VALIDATE_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); -void Test_CF_ValidateChunkSizeCmd_val_LessThanOrEqSizeOf_pdu_fd_data_t_SuccessAndReturn_0(void) -{ - /* Arrange */ - uint32 arg_val = Any_uint32_LessThan_or_EqualTo(sizeof(CF_CFDP_PduFileDataContent_t)); - CF_ChanAction_Status_t local_result; + /* Validation success, chunk size max */ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = CF_GetSet_ValueID_outgoing_file_chunk_size; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + utbuf.Payload.value = sizeof(CF_CFDP_PduFileDataContent_t); - /* Act */ - local_result = CF_ValidateChunkSizeCmd(arg_val, NULL); + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); } -/******************************************************************************* -** -** CF_ValidateMaxOutgoingCmd tests -** -*******************************************************************************/ - -void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_IsNot_0_Return_0_Success(void) +void Test_CF_SetParamCmd_ValidateMaxMsgs(void) { - /* Arrange */ - uint32 arg_val = Any_uint32_Except(0); - CF_ChanAction_Status_t local_result; + /* this test case specifically targets the additional validation for chan_max_outgoing_messages_per_wakeup */ + CF_SetParamCmd_t utbuf; + CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, NULL); + memset(&utbuf, 0, sizeof(utbuf)); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} + utbuf.Payload.key = CF_GetSet_ValueID_chan_max_outgoing_messages_per_wakeup; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; -void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_But_sem_name_IsNot_NULL_Return_0_Success(void) -{ - /* Arrange */ - uint32 arg_val = 0; - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + /* Validation fail: unlimited msgs with no sem */ + chan->config.sem_name[0] = 0; - memset(chan->config.sem_name, (char)Any_uint8_Except(0), 1); + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); - /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, chan); + UT_CF_AssertEventID(CF_CMD_GETSET_VALIDATE_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_SUCCESS); -} + /* Validation success: unlimited msgs with sem */ + UT_CF_ResetEventCapture(); + chan->config.sem_name[0] = 'a'; -void Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Return_1_Fail(void) -{ - /* Arrange */ - uint32 arg_val = 0; - CF_ChannelSelect_t chan_num = Any_cf_chan_num(); /* Any_cf_chan_num used here because value matters to this test */ - CF_ChanAction_Status_t local_result; - CF_Channel_t *chan = CF_GetChannelPtr(chan_num); + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); + + UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); - memset(chan->config.sem_name, (char)0, 1); + /* Validation success: limited msgs with sem */ + UT_CF_ResetEventCapture(); + chan->config.sem_name[0] = 'a'; + utbuf.Payload.value = 10; - /* Act */ - local_result = CF_ValidateMaxOutgoingCmd(arg_val, chan); + UtAssert_VOIDCALL(CF_SetParamCmd(&utbuf)); - /* Assert */ - UtAssert_INT32_EQ(local_result, CF_ChanAction_Status_ERROR); + UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 2); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } /******************************************************************************* ** -** CF_GetSetParamCmd tests +** CF_GetParamCmd tests ** *******************************************************************************/ -void Test_CF_GetSetParamCmd(void) +void Test_CF_GetParamCmd_Nominal(void) { - /* Test cases for: - * void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_Channel_t *chan_ptr); - */ - - /* Arrange */ + CF_GetParamCmd_t utbuf; CF_GetSet_ValueID_t param_id; uint16 expected_count; - CF_Engine_t *engine_ptr = CF_GetEngine(); - CF_Channel_t *chan = UT_CFDP_CHANNEL_PTR; - memset(&CF_AppData.counters, 0, sizeof(CF_AppData.counters)); + memset(&utbuf, 0, sizeof(utbuf)); expected_count = 0; - /* Nominal: "set" for each parameter */ - for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id) + /* Nominal: "get" for each parameter */ + for (param_id = 1; (int)param_id < CF_GetSet_ValueID_MAX; ++param_id) { UT_CF_ResetEventCapture(); - UtAssert_VOIDCALL(CF_GetSetParamCmd(true, param_id, 1 + param_id, UT_CFDP_CHANNEL)); - UT_CF_AssertEventID(CF_CMD_GETSET1_INF_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, ++expected_count); - } - /* each of the config parameters should have actually been set to a different value */ - UtAssert_UINT32_EQ(engine_ptr->config.ticks_per_second, 1); - UtAssert_UINT32_EQ(engine_ptr->config.rx_crc_calc_bytes_per_wakeup, 2); - UtAssert_UINT32_EQ(chan->config.ack_timer_s, 3); - UtAssert_UINT32_EQ(chan->config.nak_timer_s, 4); - UtAssert_UINT32_EQ(chan->config.inactivity_timer_s, 5); - UtAssert_UINT32_EQ(engine_ptr->config.outgoing_file_chunk_size, 6); - UtAssert_UINT32_EQ(chan->config.ack_limit, 7); - UtAssert_UINT32_EQ(chan->config.nak_limit, 8); - UtAssert_UINT32_EQ(engine_ptr->config.local_eid, 9); - UtAssert_UINT32_EQ(chan->config.max_outgoing_messages_per_wakeup, 10); + utbuf.Payload.key = param_id; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; - /* Nominal: "get" for each parameter */ - for (param_id = 0; param_id < CF_GetSet_ValueID_MAX; ++param_id) - { - UT_CF_ResetEventCapture(); - UtAssert_VOIDCALL(CF_GetSetParamCmd(false, param_id, 1, UT_CFDP_CHANNEL)); + UtAssert_VOIDCALL(CF_GetParamCmd(&utbuf)); + + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); UT_CF_AssertEventID(CF_CMD_GETSET2_INF_EID); UtAssert_UINT32_EQ(CF_AppData.counters.cmd, ++expected_count); } - - /* Bad param ID */ - UT_CF_ResetEventCapture(); - UtAssert_VOIDCALL(CF_GetSetParamCmd(false, CF_GetSet_ValueID_MAX, 0, UT_CFDP_CHANNEL)); - UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); - - /* Bad channel ID */ - UT_CF_ResetEventCapture(); - UtAssert_VOIDCALL(CF_GetSetParamCmd(false, 0, 0, CF_NUM_CHANNELS + 1)); - UT_CF_AssertEventID(CF_CMD_GETSET_CHAN_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); - - /* Validation fail */ - UT_CF_ResetEventCapture(); - UtAssert_VOIDCALL(CF_GetSetParamCmd(true, - CF_GetSet_ValueID_outgoing_file_chunk_size, - 100 + sizeof(CF_CFDP_PduFileDataContent_t), - UT_CFDP_CHANNEL)); - UT_CF_AssertEventID(CF_CMD_GETSET_VALIDATE_ERR_EID); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); } -/******************************************************************************* -** -** CF_SetParamCmd tests -** -*******************************************************************************/ - -void Test_CF_SetParamCmd_Call_CF_GetSetParamCmd_With_cmd_key_And_cmd_value(void) +void Test_CF_GetParamCmd_BadParam(void) { - /* Arrange */ - CF_SetParamCmd_t utbuf; - CF_Engine_t *engine_ptr = CF_GetEngine(); + CF_GetParamCmd_t utbuf; memset(&utbuf, 0, sizeof(utbuf)); - utbuf.Payload.key = CF_GetSet_ValueID_ticks_per_second; - utbuf.Payload.value = 1; + /* Bad param ID (0)*/ + utbuf.Payload.key = 0; utbuf.Payload.chan_num = UT_CFDP_CHANNEL; - /* Act */ - CF_SetParamCmd(&utbuf); + UtAssert_VOIDCALL(CF_GetParamCmd(&utbuf)); - /* Assert */ - UtAssert_UINT32_EQ(engine_ptr->config.ticks_per_second, utbuf.Payload.value); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_GETSET1_INF_EID); - /* Assert for incremented counter() */ - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); -} + UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); -/******************************************************************************* -** -** CF_GetParamCmd tests -** -*******************************************************************************/ + /* Bad param ID (high)*/ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = CF_GetSet_ValueID_MAX; + utbuf.Payload.chan_num = UT_CFDP_CHANNEL; -void Test_CF_GetParamCmd_Call_CF_GetSetParamCmd_With_cmd_data_byte_0_AndConstantValue_0(void) -{ - /* Arrange */ - CF_GetParamCmd_t utbuf; + UtAssert_VOIDCALL(CF_GetParamCmd(&utbuf)); - memset(&utbuf, 0, sizeof(utbuf)); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); + UT_CF_AssertEventID(CF_CMD_GETSET_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 2); - utbuf.Payload.key = CF_GetSet_ValueID_ticks_per_second; - utbuf.Payload.chan_num = UT_CFDP_CHANNEL; + /* Bad channel ID */ + UT_CF_ResetEventCapture(); + utbuf.Payload.key = 1; + utbuf.Payload.chan_num = UT_CFDP_INVALID_CHANNEL; - /* Act */ - CF_GetParamCmd(&utbuf); + UtAssert_VOIDCALL(CF_GetParamCmd(&utbuf)); - /* Assert */ - /* Note actual value not tested, just flow */ UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); - UtAssert_UINT32_EQ(UT_CF_CapturedEventIDs[0], CF_CMD_GETSET2_INF_EID); - /* Assert for incremented counter() */ - UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 1); + UT_CF_AssertEventID(CF_CMD_CHAN_PARAM_ERR_EID); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 3); } /******************************************************************************* @@ -3467,15 +2627,14 @@ void Test_CF_EnableEngineCmd_WithEngineNotEnableFailsInitSendEventAndIncrementEr { /* Arrange */ CF_EnableEngineCmd_t utbuf; - uint32 forced_return_CF_CFDP_InitEngine = Any_uint32_Except(CF_ChanAction_Status_SUCCESS); - uint16 initial_hk_err_counter = Any_uint16(); - CF_Engine_t *engine_ptr = CF_GetEngine(); + uint16 initial_hk_err_counter = Any_uint16(); + CF_Engine_t *engine_ptr = CF_GetEngine(); memset(&utbuf, 0, sizeof(utbuf)); engine_ptr->enabled = false; - UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), forced_return_CF_CFDP_InitEngine); + UT_SetDefaultReturnValue(UT_KEY(CF_CFDP_InitEngine), CFE_STATUS_EXTERNAL_RESOURCE_FAIL); CF_AppData.counters.err = initial_hk_err_counter; @@ -3685,46 +2844,6 @@ void add_CF_PlaybackDirCmd_tests(void) UtTest_Add(Test_CF_PlaybackDirCmd, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "CF_PlaybackDirCmd"); } -void add_CF_DoChanAction_tests(void) -{ - UtTest_Add(Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAny_fn_returns_1_Return_1"); - UtTest_Add(Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAll_fn_return_1_Return_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenAll_fn_return_1_Return_1"); - UtTest_Add(Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_CF_ALL_CHANNELS_WhenNo_fn_returns_0_Return_0"); - UtTest_Add(Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_1_Return_1"); - UtTest_Add(Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_WhenChannel_fn_ActionReturns_0_Return_1"); - UtTest_Add(Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendEvent_, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_WhenChanNumberEq_CF_NUM_CHANNELS_Return_neg1_And_SendEvent_"); - UtTest_Add(Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoChanAction_WhenBadChannelNumber_Return_neg1_And_SendEvent"); -} - -void add_CF_DoFreezeThaw_tests(void) -{ - UtTest_Add(Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoFreezeThaw_Set_frozen_ToGiven_context_barg_AndReturn_0"); -} - void add_CF_FreezeCmd_tests(void) { UtTest_Add(Test_CF_FreezeCmd_Set_frozen_To_1_AndAcceptCommand, @@ -3749,109 +2868,53 @@ void add_CF_ThawCmd_tests(void) "Test_CF_ThawCmd_Set_frozen_To_0_AndRejectCommand"); } -void add_CF_FindTransactionBySequenceNumberAllChannels_tests(void) -{ - UtTest_Add(Test_CF_FindTransactionBySequenceNumberAllChannels_WhenNoTransactionFoundReturn_NULL, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_FindTransactionBySequenceNumberAllChannels_WhenNoTransactionFoundReturn_NULL"); - UtTest_Add(Test_CF_FindTransactionBySequenceNumberAllChannels_Return_TransactionFound, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_FindTransactionBySequenceNumberAllChannels_Return_TransactionFound"); -} - -void add_CF_TsnChanAction_tests(void) -{ - UtTest_Add(Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotFoundAndReturn_neg1_Fail, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_TsnChanAction_SendEvent_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionNotFoundAndReturn_neg1_Fail"); - UtTest_Add(Test_CF_TsnChanAction_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionFoundRun_fn_AndReturn_CFE_SUCCESS, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_TsnChanAction_cmd_chan_Eq_CF_COMPOUND_KEY_TransactionFoundRun_fn_AndReturn_CFE_SUCCESS"); - UtTest_Add(Test_CF_TsnChanAction_cmd_chan_Eq_CF_ALL_CHANNELS_Return_CF_TraverseAllTransactions_All_Channels, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_TsnChanAction_cmd_chan_Eq_CF_ALL_CHANNELS_Return_CF_TraverseAllTransactions_All_Channels"); - UtTest_Add(Test_CF_TsnChanAction_cmd_chan_IsASingleChannel, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_TsnChanAction_cmd_chan_IsASingleChannel"); - UtTest_Add(Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_TsnChanAction_cmd_FailBecause_cmd_chan_IsInvalid"); -} - -void add_CF_DoSuspRes_Txn_tests(void) -{ - UtTest_Add(Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoSuspRes_Txn_Set_context_same_To_1_suspended_Eq_action"); - UtTest_Add(Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoSuspRes_Txn_When_suspended_NotEqTo_action_Set_suspended_To_action"); -} - -void add_CF_DoSuspRes_tests(void) -{ - UtTest_Add(Test_CF_DoSuspRes, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "CF_DoSuspRes"); -} - void add_CF_SuspendCmd_tests(void) { - UtTest_Add(Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1, + UtTest_Add(Test_CF_SuspendCmd_InvalidChannel, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_SuspendCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_1"); + "Test_CF_SuspendCmd_InvalidChannel"); + UtTest_Add(Test_CF_SuspendCmd_Success, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SuspendCmd_Success"); } void add_CF_ResumeCmd_tests(void) { - UtTest_Add(Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0, + UtTest_Add(Test_CF_ResumeCmd_InvalidChannel, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_ResumeCmd_Call_CF_DoSuspRes_WithGiven_msg_And_action_0"); -} - -void add_CF_Cancel_TxnCmd_tests(void) -{ - UtTest_Add(Test_CF_Cancel_TxnCmd_Call_CF_CFDP_CancelTransaction_WithGiven_t, + "Test_CF_ResumeCmd_InvalidChannel"); + UtTest_Add(Test_CF_ResumeCmd_SuccessSame, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_Cancel_TxnCmd_Call_CF_CFDP_CancelTransaction_WithGiven_t"); + "Test_CF_ResumeCmd_SuccessSame"); } void add_CF_CancelCmd_tests(void) { UtTest_Add(Test_CF_CancelCmd_Failure, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_CancelCmd_Failure"); UtTest_Add(Test_CF_CancelCmd_Success, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_CancelCmd_Success"); -} - -void add_CF_Abandon_TxnCmd_tests(void) -{ - UtTest_Add(Test_CF_Abandon_TxnCmd_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0, + UtTest_Add(Test_CF_CancelCmd_SuccessSingleTxn, + cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, + "Test_CF_CancelCmd_SuccessSingleTxn"); + UtTest_Add(Test_CF_CancelCmd_FailSingleTxn, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_Abandon_TxnCmd_Call_CF_CFDP_ResetTransaction_WithGiven_t_And_0"); + "Test_CF_CancelCmd_FailSingleTxn"); } void add_CF_AbandonCmd_tests(void) { UtTest_Add(Test_CF_AbandonCmd_Failure, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_AbandonCmd_Failure"); UtTest_Add(Test_CF_AbandonCmd_Success, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_AbandonCmd_Success"); -} - -void add_CF_DoEnableDisableDequeue_tests(void) -{ - UtTest_Add(Test_CF_DoEnableDisableDequeue_Set_chan_num_EnabledFlagTo_context_barg, + UtTest_Add(Test_CF_AbandonCmd_SuccessSingleTxn, + cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, + "Test_CF_AbandonCmd_SuccessSingleTxn"); + UtTest_Add(Test_CF_AbandonCmd_FailSingleTxn, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_DoEnableDisableDequeue_Set_chan_num_EnabledFlagTo_context_barg"); + "Test_CF_AbandonCmd_FailSingleTxn"); } void add_CF_EnableDequeueCmd_tests(void) @@ -3878,27 +2941,6 @@ void add_CF_DisableDequeueCmd_tests(void) "Test_CF_DisableDequeueCmd_Failure"); } -void add_CF_DoEnableDisablePolldir_tests(void) -{ - UtTest_Add(Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannelEnabledTo_context_barg, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoEnableDisablePolldir_When_CF_ALL_CHANNELS_SetAllPolldirsInChannelEnabledTo_context_barg"); - UtTest_Add( - Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_context_ChannelEnabledTo_context_barg, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoEnableDisablePolldir_WhenSetToSpecificPolldirSetPolldirFrom_context_ChannelEnabledTo_context_barg"); - UtTest_Add(Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_AndSendEvent, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoEnableDisablePolldir_FailPolldirEq_CF_MAX_POLLING_DIR_PER_CHAN_AndSendEvent"); - UtTest_Add(Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoEnableDisablePolldir_FailAnyBadPolldirSendEvent"); -} - void add_CF_EnablePolldirCmd_tests(void) { UtTest_Add(Test_CF_EnablePolldirCmd_SuccessWhenActionSuccess, @@ -3909,6 +2951,14 @@ void add_CF_EnablePolldirCmd_tests(void) cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_EnablePolldirCmd_FailWhenActionFail"); + UtTest_Add(Test_CF_EnablePolldirCmd_AllPollDirs, + cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, + "Test_CF_EnablePolldirCmd_AllPollDirs"); + UtTest_Add(Test_CF_EnablePolldirCmd_InvalidChannel, + cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, + "Test_CF_EnablePolldirCmd_InvalidChannel"); } void add_CF_DisablePolldirCmd_tests(void) @@ -3921,43 +2971,14 @@ void add_CF_DisablePolldirCmd_tests(void) cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_DisablePolldirCmd_FailWhenActionFail"); -} - -void add_CF_PurgeHistory_tests(void) -{ - UtTest_Add(Test_CF_PurgeHistory_Call_CF_CFDP_ResetHistory_AndReturn_CLIST_CONT, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_PurgeHistory_Call_CF_CFDP_ResetHistory_AndReturn_CLIST_CONT"); -} - -void add_CF_PurgeTransaction_tests(void) -{ - UtTest_Add(Test_CF_PurgeTransaction_Call_CF_CFDP_ResetTransaction_AndReturn_CLIST_CONT, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_PurgeTransaction_Call_CF_CFDP_ResetTransaction_AndReturn_CLIST_CONT"); -} - -void add_CF_DoPurgeQueue_tests(void) -{ - UtTest_Add(Test_CF_DoPurgeQueue_PendOnly, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoPurgeQueue_PendOnly"); - UtTest_Add(Test_CF_DoPurgeQueue_HistoryOnly, + UtTest_Add(Test_CF_DisablePolldirCmd_AllPollDirs, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_DoPurgeQueue_HistoryOnly"); - UtTest_Add(Test_CF_DoPurgeQueue_Both, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_DoPurgeQueue_Both"); - UtTest_Add(Test_CF_DoPurgeQueue_GivenBad_data_byte_1_SendEventAndReturn_neg1, + "Test_CF_DisablePolldirCmd_AllPollDirs"); + UtTest_Add(Test_CF_DisablePolldirCmd_InvalidChannel, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_DoPurgeQueue_GivenBad_data_byte_1_SendEventAndReturn_neg1"); - UtTest_Add(Test_CF_DoPurgeQueue_AnyGivenBad_data_byte_1_SendEventAndReturn_neg1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_DoPurgeQueue_AnyGivenBad_data_byte_1_SendEventAndReturn_neg1"); + "Test_CF_DisablePolldirCmd_InvalidChannel"); } void add_CF_PurgeQueueCmd_tests(void) @@ -3970,6 +2991,10 @@ void add_CF_PurgeQueueCmd_tests(void) cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_PurgeQueueCmd_SuccessWhenActionSuccess"); + UtTest_Add(Test_CF_PurgeQueueCmd_InvalidChannel, + cf_cmd_tests_Setup, + cf_cmd_tests_Teardown, + "Test_CF_PurgeQueueCmd_InvalidChannel"); } void add_CF_WriteQueueCmd_tests(void) @@ -3978,10 +3003,6 @@ void add_CF_WriteQueueCmd_tests(void) cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_WriteQueueCmd_When_chan_Eq_CF_NUM_CAHNNELS_SendEventAndRejectCommand"); - UtTest_Add(Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRejectCommand, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_WriteQueueCmd_When_chan_GreaterThan_CF_NUM_CAHNNELS_SendEventAndRejectCommand"); UtTest_Add(Test_CF_WriteQueueCmd_WhenUpAndPendingQueueSendEventAndRejectCommand, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, @@ -4082,61 +3103,25 @@ void add_CF_WriteQueueCmd_tests(void) "Test_CF_WriteQueueCmd_Success_type_DownAnd_q_Pend"); } -void add_CF_ValidateChunkSizeCmd_tests(void) -{ - UtTest_Add(Test_CF_ValidateChunkSizeCmd_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateChunkSizeCmd_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1"); - UtTest_Add(Test_CF_ValidateChunkSizeCmd_Any_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateChunkSizeCmd_Any_val_GreaterThan_pdu_fd_data_t_FailAndReturn_1"); - UtTest_Add(Test_CF_ValidateChunkSizeCmd_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateChunkSizeCmd_val_SizeOf_pdu_fd_data_t_SuccessAndReturn_0"); - UtTest_Add(Test_CF_ValidateChunkSizeCmd_val_LessThanOrEqSizeOf_pdu_fd_data_t_SuccessAndReturn_0, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateChunkSizeCmd_val_LessThanOrEqSizeOf_pdu_fd_data_t_SuccessAndReturn_0"); -} - -void add_CF_ValidateMaxOutgoingCmd_tests(void) +void add_CF_SetParamCmd_tests(void) { - UtTest_Add(Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_IsNot_0_Return_0_Success, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_IsNot_0_Return_0_Success"); - UtTest_Add(Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_But_sem_name_IsNot_NULL_Return_0_Success, + UtTest_Add(Test_CF_SetParamCmd_Nominal, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SetParamCmd_Nominal"); + UtTest_Add(Test_CF_SetParamCmd_BadParam, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_SetParamCmd_BadParam"); + UtTest_Add(Test_CF_SetParamCmd_ValidateChunkSize, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_But_sem_name_IsNot_NULL_Return_0_Success"); - UtTest_Add(Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Return_1_Fail, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_ValidateMaxOutgoingCmd_WhenGiven_val_Is_0_And_sem_name_Is_NULL_Return_1_Fail"); -} - -void add_CF_GetSetParamCmd_tests(void) -{ - UtTest_Add(Test_CF_GetSetParamCmd, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "CF_GetSetParamCmd"); -} - -void add_CF_SetParamCmd_tests(void) -{ - UtTest_Add(Test_CF_SetParamCmd_Call_CF_GetSetParamCmd_With_cmd_key_And_cmd_value, + "Test_CF_SetParamCmd_ValidateChunkSize"); + UtTest_Add(Test_CF_SetParamCmd_ValidateMaxMsgs, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, - "Test_CF_SetParamCmd_Call_CF_GetSetParamCmd_With_cmd_key_And_cmd_value"); + "Test_CF_SetParamCmd_ValidateMaxMsgs"); } void add_CF_GetParamCmd_tests(void) { - UtTest_Add(Test_CF_GetParamCmd_Call_CF_GetSetParamCmd_With_cmd_data_byte_0_AndConstantValue_0, - cf_cmd_tests_Setup, - cf_cmd_tests_Teardown, - "Test_CF_GetParamCmd_Call_CF_GetSetParamCmd_With_cmd_data_byte_0_AndConstantValue_0"); + UtTest_Add(Test_CF_GetParamCmd_Nominal, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_GetParamCmd_Nominal"); + + UtTest_Add(Test_CF_GetParamCmd_BadParam, cf_cmd_tests_Setup, cf_cmd_tests_Teardown, "Test_CF_GetParamCmd_BadParam"); } void add_CF_EnableEngineCmd_tests(void) @@ -4196,62 +3181,30 @@ void UtTest_Setup(void) add_CF_PlaybackDirCmd_tests(); - add_CF_DoChanAction_tests(); - - add_CF_DoFreezeThaw_tests(); - add_CF_FreezeCmd_tests(); add_CF_ThawCmd_tests(); - add_CF_FindTransactionBySequenceNumberAllChannels_tests(); - - add_CF_TsnChanAction_tests(); - - add_CF_DoSuspRes_Txn_tests(); - - add_CF_DoSuspRes_tests(); - add_CF_SuspendCmd_tests(); add_CF_ResumeCmd_tests(); - add_CF_Cancel_TxnCmd_tests(); - add_CF_CancelCmd_tests(); - add_CF_Abandon_TxnCmd_tests(); - add_CF_AbandonCmd_tests(); - add_CF_DoEnableDisableDequeue_tests(); - add_CF_EnableDequeueCmd_tests(); add_CF_DisableDequeueCmd_tests(); - add_CF_DoEnableDisablePolldir_tests(); - add_CF_EnablePolldirCmd_tests(); add_CF_DisablePolldirCmd_tests(); - add_CF_PurgeHistory_tests(); - - add_CF_PurgeTransaction_tests(); - - add_CF_DoPurgeQueue_tests(); - add_CF_PurgeQueueCmd_tests(); add_CF_WriteQueueCmd_tests(); - add_CF_ValidateChunkSizeCmd_tests(); - - add_CF_ValidateMaxOutgoingCmd_tests(); - - add_CF_GetSetParamCmd_tests(); - add_CF_SetParamCmd_tests(); add_CF_GetParamCmd_tests(); diff --git a/unit-test/cf_utils_tests.c b/unit-test/cf_utils_tests.c index 4f37ba4e..79642487 100644 --- a/unit-test/cf_utils_tests.c +++ b/unit-test/cf_utils_tests.c @@ -983,27 +983,6 @@ void Test_CF_TraverseAllTransactions_CallOtherFunction_CF_Q_RX_TimesAndReturn_ar } } -/******************************************************************************* -** -** CF_TraverseAllTransactions_All_Channels tests -** -*******************************************************************************/ - -void Test_CF_TraverseAllTransactions_All_Channels_ReturnTotalTraversals(void) -{ - /* Arrange */ - int context; - void *arg_context = &context; - uint8 per_channel_count = CF_QueueIdx_RX - CF_QueueIdx_PEND + 1; - int expected_result = per_channel_count * CF_NUM_CHANNELS; - - CF_TraverseAllTransactions_fn_t arg_fn = NULL; - UT_SetHandlerFunction(UT_KEY(CF_CList_Traverse), UT_AltHandler_CF_CList_Traverse_TRAVERSE_ALL_ARGS_T, NULL); - - /* Act */ - UtAssert_INT32_EQ(CF_TraverseAllTransactions_All_Channels(arg_fn, arg_context), expected_result); -} - /******************************************************************************* ** ** CF_WrappedOpen tests @@ -1374,14 +1353,6 @@ void add_CF_TraverseAllTransactions_tests(void) "Test_CF_TraverseAllTransactions_CallOtherFunction_CF_Q_RX_TimesAndReturn_args_counter"); } -void add_CF_TraverseAllTransactions_All_Channels_tests(void) -{ - UtTest_Add(Test_CF_TraverseAllTransactions_All_Channels_ReturnTotalTraversals, - cf_utils_tests_Setup, - cf_utils_tests_Teardown, - "Test_CF_TraverseAllTransactions_All_Channels_ReturnTotalTraversals"); -} - void add_CF_WrappedOpen_tests(void) { UtTest_Add(Test_CF_WrappedOpen_Call_OS_OpenCreate_WithGivenArgumentsAndReturnItsReturnValue, @@ -1454,8 +1425,6 @@ void UtTest_Setup(void) add_CF_TraverseAllTransactions_tests(); - add_CF_TraverseAllTransactions_All_Channels_tests(); - add_CF_WrappedOpen_tests(); add_CF_WrappedClose_tests(); diff --git a/unit-test/stubs/cf_cfdp_sbintf_stubs.c b/unit-test/stubs/cf_cfdp_sbintf_stubs.c index af649ced..4ae50f08 100644 --- a/unit-test/stubs/cf_cfdp_sbintf_stubs.c +++ b/unit-test/stubs/cf_cfdp_sbintf_stubs.c @@ -62,9 +62,9 @@ void CF_CFDP_ReceiveMessage(CF_Channel_t *chan) * Generated stub function for CF_CFDP_Send() * ---------------------------------------------------- */ -void CF_CFDP_Send(CF_Channel_t *chan_ptr, const CF_Logical_PduBuffer_t *ph) +void CF_CFDP_Send(CF_Channel_t *chan, const CF_Logical_PduBuffer_t *ph) { - UT_GenStub_AddParam(CF_CFDP_Send, CF_Channel_t *, chan_ptr); + UT_GenStub_AddParam(CF_CFDP_Send, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_CFDP_Send, const CF_Logical_PduBuffer_t *, ph); UT_GenStub_Execute(CF_CFDP_Send, Basic, NULL); diff --git a/unit-test/stubs/cf_cmd_stubs.c b/unit-test/stubs/cf_cmd_stubs.c index 887ff78a..fe79e128 100644 --- a/unit-test/stubs/cf_cmd_stubs.c +++ b/unit-test/stubs/cf_cmd_stubs.c @@ -42,19 +42,6 @@ CFE_Status_t CF_AbandonCmd(const CF_AbandonCmd_t *msg) return UT_GenStub_GetReturnValue(CF_AbandonCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_Abandon_TxnCmd() - * ---------------------------------------------------- - */ -void CF_Abandon_TxnCmd(CF_Transaction_t *txn, void *ignored) -{ - UT_GenStub_AddParam(CF_Abandon_TxnCmd, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_Abandon_TxnCmd, void *, ignored); - - UT_GenStub_Execute(CF_Abandon_TxnCmd, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_CancelCmd() @@ -71,19 +58,6 @@ CFE_Status_t CF_CancelCmd(const CF_CancelCmd_t *msg) return UT_GenStub_GetReturnValue(CF_CancelCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_Cancel_TxnCmd() - * ---------------------------------------------------- - */ -void CF_Cancel_TxnCmd(CF_Transaction_t *txn, void *ignored) -{ - UT_GenStub_AddParam(CF_Cancel_TxnCmd, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_Cancel_TxnCmd, void *, ignored); - - UT_GenStub_Execute(CF_Cancel_TxnCmd, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_DisableDequeueCmd() @@ -132,120 +106,6 @@ CFE_Status_t CF_DisableEngineCmd(const CF_DisableEngineCmd_t *msg) return UT_GenStub_GetReturnValue(CF_DisableEngineCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoChanAction() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t -CF_DoChanAction(CF_ChannelSelect_t chan_select, const char *errstr, CF_ChanActionFn_t fn, void *context) -{ - UT_GenStub_SetupReturnBuffer(CF_DoChanAction, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_DoChanAction, CF_ChannelSelect_t, chan_select); - UT_GenStub_AddParam(CF_DoChanAction, const char *, errstr); - UT_GenStub_AddParam(CF_DoChanAction, CF_ChanActionFn_t, fn); - UT_GenStub_AddParam(CF_DoChanAction, void *, context); - - UT_GenStub_Execute(CF_DoChanAction, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_DoChanAction, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoEnableDisableDequeue() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_DoEnableDisableDequeue(CF_Channel_t *chan, void *arg) -{ - UT_GenStub_SetupReturnBuffer(CF_DoEnableDisableDequeue, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_DoEnableDisableDequeue, CF_Channel_t *, chan); - UT_GenStub_AddParam(CF_DoEnableDisableDequeue, void *, arg); - - UT_GenStub_Execute(CF_DoEnableDisableDequeue, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_DoEnableDisableDequeue, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoEnableDisablePolldir() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_DoEnableDisablePolldir(CF_Channel_t *chan, void *arg) -{ - UT_GenStub_SetupReturnBuffer(CF_DoEnableDisablePolldir, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_DoEnableDisablePolldir, CF_Channel_t *, chan); - UT_GenStub_AddParam(CF_DoEnableDisablePolldir, void *, arg); - - UT_GenStub_Execute(CF_DoEnableDisablePolldir, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_DoEnableDisablePolldir, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoFreezeThaw() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_DoFreezeThaw(CF_Channel_t *chan, void *arg) -{ - UT_GenStub_SetupReturnBuffer(CF_DoFreezeThaw, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_DoFreezeThaw, CF_Channel_t *, chan); - UT_GenStub_AddParam(CF_DoFreezeThaw, void *, arg); - - UT_GenStub_Execute(CF_DoFreezeThaw, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_DoFreezeThaw, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoPurgeQueue() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_DoPurgeQueue(CF_Channel_t *chan, void *arg) -{ - UT_GenStub_SetupReturnBuffer(CF_DoPurgeQueue, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_DoPurgeQueue, CF_Channel_t *, chan); - UT_GenStub_AddParam(CF_DoPurgeQueue, void *, arg); - - UT_GenStub_Execute(CF_DoPurgeQueue, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_DoPurgeQueue, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoSuspRes() - * ---------------------------------------------------- - */ -void CF_DoSuspRes(const CF_Transaction_Payload_t *payload, uint8 action) -{ - UT_GenStub_AddParam(CF_DoSuspRes, const CF_Transaction_Payload_t *, payload); - UT_GenStub_AddParam(CF_DoSuspRes, uint8, action); - - UT_GenStub_Execute(CF_DoSuspRes, Basic, NULL); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_DoSuspRes_Txn() - * ---------------------------------------------------- - */ -void CF_DoSuspRes_Txn(CF_Transaction_t *txn, CF_ChanAction_SuspResArg_t *context) -{ - UT_GenStub_AddParam(CF_DoSuspRes_Txn, CF_Transaction_t *, txn); - UT_GenStub_AddParam(CF_DoSuspRes_Txn, CF_ChanAction_SuspResArg_t *, context); - - UT_GenStub_Execute(CF_DoSuspRes_Txn, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_EnableDequeueCmd() @@ -294,23 +154,6 @@ CFE_Status_t CF_EnableEngineCmd(const CF_EnableEngineCmd_t *msg) return UT_GenStub_GetReturnValue(CF_EnableEngineCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_FindTransactionBySequenceNumberAllChannels() - * ---------------------------------------------------- - */ -CF_Transaction_t *CF_FindTransactionBySequenceNumberAllChannels(CF_TransactionSeq_t ts, CF_EntityId_t eid) -{ - UT_GenStub_SetupReturnBuffer(CF_FindTransactionBySequenceNumberAllChannels, CF_Transaction_t *); - - UT_GenStub_AddParam(CF_FindTransactionBySequenceNumberAllChannels, CF_TransactionSeq_t, ts); - UT_GenStub_AddParam(CF_FindTransactionBySequenceNumberAllChannels, CF_EntityId_t, eid); - - UT_GenStub_Execute(CF_FindTransactionBySequenceNumberAllChannels, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_FindTransactionBySequenceNumberAllChannels, CF_Transaction_t *); -} - /* * ---------------------------------------------------- * Generated stub function for CF_FreezeCmd() @@ -343,21 +186,6 @@ CFE_Status_t CF_GetParamCmd(const CF_GetParamCmd_t *msg) return UT_GenStub_GetReturnValue(CF_GetParamCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_GetSetParamCmd() - * ---------------------------------------------------- - */ -void CF_GetSetParamCmd(bool is_set, CF_GetSet_ValueID_t param_id, uint32 value, CF_ChannelSelect_t chan_num) -{ - UT_GenStub_AddParam(CF_GetSetParamCmd, bool, is_set); - UT_GenStub_AddParam(CF_GetSetParamCmd, CF_GetSet_ValueID_t, param_id); - UT_GenStub_AddParam(CF_GetSetParamCmd, uint32, value); - UT_GenStub_AddParam(CF_GetSetParamCmd, CF_ChannelSelect_t, chan_num); - - UT_GenStub_Execute(CF_GetSetParamCmd, Basic, NULL); -} - /* * ---------------------------------------------------- * Generated stub function for CF_NoopCmd() @@ -390,23 +218,6 @@ CFE_Status_t CF_PlaybackDirCmd(const CF_PlaybackDirCmd_t *msg) return UT_GenStub_GetReturnValue(CF_PlaybackDirCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_PurgeHistory() - * ---------------------------------------------------- - */ -CF_CListTraverse_Status_t CF_PurgeHistory(CF_CListNode_t *node, void *arg) -{ - UT_GenStub_SetupReturnBuffer(CF_PurgeHistory, CF_CListTraverse_Status_t); - - UT_GenStub_AddParam(CF_PurgeHistory, CF_CListNode_t *, node); - UT_GenStub_AddParam(CF_PurgeHistory, void *, arg); - - UT_GenStub_Execute(CF_PurgeHistory, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_PurgeHistory, CF_CListTraverse_Status_t); -} - /* * ---------------------------------------------------- * Generated stub function for CF_PurgeQueueCmd() @@ -423,23 +234,6 @@ CFE_Status_t CF_PurgeQueueCmd(const CF_PurgeQueueCmd_t *msg) return UT_GenStub_GetReturnValue(CF_PurgeQueueCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_PurgeTransaction() - * ---------------------------------------------------- - */ -CF_CListTraverse_Status_t CF_PurgeTransaction(CF_CListNode_t *node, void *ignored) -{ - UT_GenStub_SetupReturnBuffer(CF_PurgeTransaction, CF_CListTraverse_Status_t); - - UT_GenStub_AddParam(CF_PurgeTransaction, CF_CListNode_t *, node); - UT_GenStub_AddParam(CF_PurgeTransaction, void *, ignored); - - UT_GenStub_Execute(CF_PurgeTransaction, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_PurgeTransaction, CF_CListTraverse_Status_t); -} - /* * ---------------------------------------------------- * Generated stub function for CF_ResetCountersCmd() @@ -536,28 +330,6 @@ CFE_Status_t CF_ThawCmd(const CF_ThawCmd_t *msg) return UT_GenStub_GetReturnValue(CF_ThawCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_TsnChanAction() - * ---------------------------------------------------- - */ -int32 CF_TsnChanAction(const CF_Transaction_Payload_t *data, - const char *cmdstr, - CF_TsnChanAction_fn_t fn, - void *context) -{ - UT_GenStub_SetupReturnBuffer(CF_TsnChanAction, int32); - - UT_GenStub_AddParam(CF_TsnChanAction, const CF_Transaction_Payload_t *, data); - UT_GenStub_AddParam(CF_TsnChanAction, const char *, cmdstr); - UT_GenStub_AddParam(CF_TsnChanAction, CF_TsnChanAction_fn_t, fn); - UT_GenStub_AddParam(CF_TsnChanAction, void *, context); - - UT_GenStub_Execute(CF_TsnChanAction, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_TsnChanAction, int32); -} - /* * ---------------------------------------------------- * Generated stub function for CF_TxFileCmd() @@ -574,40 +346,6 @@ CFE_Status_t CF_TxFileCmd(const CF_TxFileCmd_t *msg) return UT_GenStub_GetReturnValue(CF_TxFileCmd, CFE_Status_t); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_ValidateChunkSizeCmd() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_ValidateChunkSizeCmd(CF_ChunkSize_t val, CF_Channel_t *chan) -{ - UT_GenStub_SetupReturnBuffer(CF_ValidateChunkSizeCmd, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_ValidateChunkSizeCmd, CF_ChunkSize_t, val); - UT_GenStub_AddParam(CF_ValidateChunkSizeCmd, CF_Channel_t *, chan); - - UT_GenStub_Execute(CF_ValidateChunkSizeCmd, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_ValidateChunkSizeCmd, CF_ChanAction_Status_t); -} - -/* - * ---------------------------------------------------- - * Generated stub function for CF_ValidateMaxOutgoingCmd() - * ---------------------------------------------------- - */ -CF_ChanAction_Status_t CF_ValidateMaxOutgoingCmd(uint32 val, CF_Channel_t *chan) -{ - UT_GenStub_SetupReturnBuffer(CF_ValidateMaxOutgoingCmd, CF_ChanAction_Status_t); - - UT_GenStub_AddParam(CF_ValidateMaxOutgoingCmd, uint32, val); - UT_GenStub_AddParam(CF_ValidateMaxOutgoingCmd, CF_Channel_t *, chan); - - UT_GenStub_Execute(CF_ValidateMaxOutgoingCmd, Basic, NULL); - - return UT_GenStub_GetReturnValue(CF_ValidateMaxOutgoingCmd, CF_ChanAction_Status_t); -} - /* * ---------------------------------------------------- * Generated stub function for CF_WakeupCmd() diff --git a/unit-test/stubs/cf_utils_handlers.c b/unit-test/stubs/cf_utils_handlers.c index 05a99148..b98c69bc 100644 --- a/unit-test/stubs/cf_utils_handlers.c +++ b/unit-test/stubs/cf_utils_handlers.c @@ -57,51 +57,6 @@ void UT_DefaultHandler_CF_ResetHistory(void *UserObj, UT_EntryKey_t FuncKey, con } } -/*---------------------------------------------------------------- - * - * For compatibility with other tests, this has a mechanism to save its - * arguments to a test-provided context capture buffer. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_FindTransactionBySequenceNumber(void *UserObj, - UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context) -{ - CF_FindTransactionBySequenceNumber_context_t *ctxt = - UT_CF_GetContextBuffer(FuncKey, CF_FindTransactionBySequenceNumber_context_t); - CF_Transaction_t *forced_return; - - if (ctxt) - { - ctxt->chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); - ctxt->transaction_sequence_number = - UT_Hook_GetArgValueByName(Context, "transaction_sequence_number", CF_TransactionSeq_t); - ctxt->src_eid = UT_Hook_GetArgValueByName(Context, "src_eid", CF_EntityId_t); - - forced_return = ctxt->forced_return; - } - else - { - forced_return = NULL; - } - - UT_Stub_SetReturnValue(FuncKey, forced_return); -} - -/*---------------------------------------------------------------- - * - * Default always returns NULL, an alt handler can be registered for other pointer returns - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_FindUnusedTransaction(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) -{ - CF_Transaction_t *forced_return; - - forced_return = NULL; - - UT_Stub_SetReturnValue(FuncKey, forced_return); -} - /*---------------------------------------------------------------- * * For compatibility with other tests, this has a mechanism to save its @@ -159,28 +114,6 @@ void UT_DefaultHandler_CF_TraverseAllTransactions(void *UserObj, UT_EntryKey_t F } } -/*---------------------------------------------------------------- - * - * For compatibility with other tests, this has a mechanism to save its - * arguments to a test-provided context capture buffer. - * - *-----------------------------------------------------------------*/ -void UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels(void *UserObj, - UT_EntryKey_t FuncKey, - const UT_StubContext_t *Context) -{ - CF_TraverseAllTransactions_All_Channels_context_t *ctxt = - UT_CF_GetContextBuffer(FuncKey, CF_TraverseAllTransactions_All_Channels_context_t); - - if (ctxt) - { - ctxt->fn = UT_Hook_GetArgValueByName(Context, "fn", CF_TraverseAllTransactions_fn_t); - ctxt->context = UT_Hook_GetArgValueByName(Context, "context", void *); - - UT_Stub_SetReturnValue(FuncKey, ctxt->forced_return); - } -} - /*---------------------------------------------------------------- * * For compatibility with other tests, this has a mechanism to save its @@ -215,10 +148,18 @@ void UT_DefaultHandler_CF_ForEachChannel(void *UserObj, UT_EntryKey_t FuncKey, c CF_ChannelFunc_t fn = UT_Hook_GetArgValueByName(Context, "fn", CF_ChannelFunc_t); void *arg = UT_Hook_GetArgValueByName(Context, "arg", void *); int32 ret; + CF_Channel_t *chan; + + /* this permits this handler to be configured for something other than UT_CFDP_CHANNEL_PTR if needed */ + chan = UserObj; + if (chan == NULL) + { + chan = UT_CFDP_CHANNEL_PTR; + } if (fn) { - ret = fn(engine_ptr, &engine_ptr->channels[UT_CFDP_CHANNEL_IDX], arg); + ret = fn(engine_ptr, chan, arg); } else { diff --git a/unit-test/stubs/cf_utils_stubs.c b/unit-test/stubs/cf_utils_stubs.c index 605ed2db..6541d0cb 100644 --- a/unit-test/stubs/cf_utils_stubs.c +++ b/unit-test/stubs/cf_utils_stubs.c @@ -26,12 +26,9 @@ #include "cf_utils.h" #include "utgenstub.h" -void UT_DefaultHandler_CF_FindTransactionBySequenceNumber(void *, UT_EntryKey_t, const UT_StubContext_t *); -void UT_DefaultHandler_CF_FindUnusedTransaction(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_ForEachChannel(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_ResetHistory(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_TraverseAllTransactions(void *, UT_EntryKey_t, const UT_StubContext_t *); -void UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WrappedOpenCreate(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WriteHistoryQueueDataToFile(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CF_WriteTxnQueueDataToFile(void *, UT_EntryKey_t, const UT_StubContext_t *); @@ -67,7 +64,7 @@ CF_Transaction_t *CF_FindTransactionBySequenceNumber(CF_Channel_t *chan, UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber, CF_TransactionSeq_t, transaction_sequence_number); UT_GenStub_AddParam(CF_FindTransactionBySequenceNumber, CF_EntityId_t, src_eid); - UT_GenStub_Execute(CF_FindTransactionBySequenceNumber, Basic, UT_DefaultHandler_CF_FindTransactionBySequenceNumber); + UT_GenStub_Execute(CF_FindTransactionBySequenceNumber, Basic, NULL); return UT_GenStub_GetReturnValue(CF_FindTransactionBySequenceNumber, CF_Transaction_t *); } @@ -101,7 +98,7 @@ CF_Transaction_t *CF_FindUnusedTransaction(CF_Channel_t *chan, CF_Direction_t di UT_GenStub_AddParam(CF_FindUnusedTransaction, CF_Channel_t *, chan); UT_GenStub_AddParam(CF_FindUnusedTransaction, CF_Direction_t, direction); - UT_GenStub_Execute(CF_FindUnusedTransaction, Basic, UT_DefaultHandler_CF_FindUnusedTransaction); + UT_GenStub_Execute(CF_FindUnusedTransaction, Basic, NULL); return UT_GenStub_GetReturnValue(CF_FindUnusedTransaction, CF_Transaction_t *); } @@ -214,25 +211,6 @@ int32 CF_TraverseAllTransactions(CF_Channel_t *chan, CF_TraverseAllTransactions_ return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions, int32); } -/* - * ---------------------------------------------------- - * Generated stub function for CF_TraverseAllTransactions_All_Channels() - * ---------------------------------------------------- - */ -int32 CF_TraverseAllTransactions_All_Channels(CF_TraverseAllTransactions_fn_t fn, void *context) -{ - UT_GenStub_SetupReturnBuffer(CF_TraverseAllTransactions_All_Channels, int32); - - UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, CF_TraverseAllTransactions_fn_t, fn); - UT_GenStub_AddParam(CF_TraverseAllTransactions_All_Channels, void *, context); - - UT_GenStub_Execute(CF_TraverseAllTransactions_All_Channels, - Basic, - UT_DefaultHandler_CF_TraverseAllTransactions_All_Channels); - - return UT_GenStub_GetReturnValue(CF_TraverseAllTransactions_All_Channels, int32); -} - /* * ---------------------------------------------------- * Generated stub function for CF_TraverseAllTransactions_Impl() diff --git a/unit-test/utilities/cf_test_alt_handler.c b/unit-test/utilities/cf_test_alt_handler.c index 8d703e33..8c8f1c1d 100644 --- a/unit-test/utilities/cf_test_alt_handler.c +++ b/unit-test/utilities/cf_test_alt_handler.c @@ -156,3 +156,80 @@ void UT_AltHandler_CaptureTransactionStatus(void *UserObj, UT_EntryKey_t FuncKey *p_txn_stat = in_stat; } + +/*---------------------------------------------------------------- + * + * Function: UT_AltHandler_CF_TraverseAllTransactions_InvokeCb + * + * A handler for CF_TraverseAllTransactions() which invokes the callback + * with the given UserObj for the transaction + * + *-----------------------------------------------------------------*/ +void UT_AltHandler_CF_TraverseAllTransactions_InvokeCb(void *UserObj, + UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + CF_Channel_t *chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); + CF_TraverseAllTransactions_fn_t fn = UT_Hook_GetArgValueByName(Context, "fn", CF_TraverseAllTransactions_fn_t); + void *context = UT_Hook_GetArgValueByName(Context, "context", void *); + CF_Transaction_t *txn = UserObj; + int32 RetVal; + + if (fn == NULL || txn == NULL) + { + RetVal = 0; + } + else + { + txn->chan_ptr = chan; + fn(UserObj, context); + RetVal = 1; + } + + UT_Stub_SetReturnValue(FuncKey, RetVal); +} + +/*---------------------------------------------------------------- + * + * Function: UT_AltHandler_CF_FindTransactionBySequenceNumber + * + * Similar to the basic pointer return but ensures the chan_ptr + * in the transaction points to a valid channel + * + *-----------------------------------------------------------------*/ +void UT_AltHandler_CF_FindTransactionBySequenceNumber(void *UserObj, + UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context) +{ + CF_Channel_t *chan = UT_Hook_GetArgValueByName(Context, "chan", CF_Channel_t *); + CF_Transaction_t *forced_return = UserObj; + + if (forced_return != NULL) + { + forced_return->chan_ptr = chan; + } + + UT_Stub_SetReturnValue(FuncKey, forced_return); +} + +/*---------------------------------------------------------------- + * + * Function: UT_AltHandler_CF_CList_Traverse_InvokeCb + * + * Similar to the basic pointer return but ensures the chan_ptr + * in the transaction points to a valid channel + * + * A handler for CF_CList_Traverse() which invokes the callback + * + *-----------------------------------------------------------------*/ +void UT_AltHandler_CF_CList_Traverse_InvokeCb(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + CF_CListNode_t *start = UT_Hook_GetArgValueByName(Context, "start", CF_CListNode_t *); + CF_CListFn_t fn = UT_Hook_GetArgValueByName(Context, "fn", CF_CListFn_t); + void *context = UT_Hook_GetArgValueByName(Context, "context", void *); + + if (fn != NULL) + { + fn(start, context); + } +} diff --git a/unit-test/utilities/cf_test_alt_handler.h b/unit-test/utilities/cf_test_alt_handler.h index d474e563..a89aeff9 100644 --- a/unit-test/utilities/cf_test_alt_handler.h +++ b/unit-test/utilities/cf_test_alt_handler.h @@ -39,4 +39,14 @@ void UT_AltHandler_GenericPointerReturn(void *UserObj, UT_EntryKey_t FuncKey, co void UT_AltHandler_CaptureTransactionStatus(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); +void UT_AltHandler_CF_TraverseAllTransactions_InvokeCb(void *UserObj, + UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context); + +void UT_AltHandler_CF_FindTransactionBySequenceNumber(void *UserObj, + UT_EntryKey_t FuncKey, + const UT_StubContext_t *Context); + +void UT_AltHandler_CF_CList_Traverse_InvokeCb(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context); + #endif /* CF_TEST_ALT_HANDLER_H */ diff --git a/unit-test/utilities/cf_test_utils.c b/unit-test/utilities/cf_test_utils.c index cef15ec7..5566f0d7 100644 --- a/unit-test/utilities/cf_test_utils.c +++ b/unit-test/utilities/cf_test_utils.c @@ -391,5 +391,5 @@ void AnyRandomStringOfLettersOfLengthCopy(char *random_string, size_t length) /* cf specific */ CF_ChannelSelect_t Any_cf_chan_num(void) { - return (Any_uint8_LessThan(CF_NUM_CHANNELS)); + return CF_ChannelSelect_FromInt(1 + Any_uint8_LessThan(CF_NUM_CHANNELS)); } diff --git a/unit-test/utilities/cf_test_utils.h b/unit-test/utilities/cf_test_utils.h index 0960cdd7..e946bd07 100644 --- a/unit-test/utilities/cf_test_utils.h +++ b/unit-test/utilities/cf_test_utils.h @@ -45,9 +45,10 @@ #define RANDOM_VALUES_SEED 0 #endif /* !RANDOM_VALUES_SEED */ -#define UT_CFDP_CHANNEL_IDX 0 -#define UT_CFDP_CHANNEL CF_ChannelSelect_FromInt(UT_CFDP_CHANNEL_IDX) -#define UT_CFDP_CHANNEL_PTR CF_GetChannelPtr(UT_CFDP_CHANNEL) +#define UT_CFDP_CHANNEL_IDX 1 +#define UT_CFDP_CHANNEL CF_ChannelSelect_FromInt(UT_CFDP_CHANNEL_IDX) +#define UT_CFDP_CHANNEL_PTR CF_GetChannelPtr(UT_CFDP_CHANNEL) +#define UT_CFDP_INVALID_CHANNEL CF_ChannelSelect_FromInt(CF_NUM_CHANNELS + 1) typedef enum { @@ -87,21 +88,6 @@ typedef struct CF_EntityId_t dest_id; } CF_CFDP_PlaybackDir_context_t; -typedef struct -{ - CF_Channel_t *chan; - CF_TransactionSeq_t transaction_sequence_number; - CF_EntityId_t src_eid; - CF_Transaction_t *forced_return; -} CF_FindTransactionBySequenceNumber_context_t; - -typedef struct -{ - CF_TraverseAllTransactions_fn_t fn; - void *context; - int forced_return; -} CF_TraverseAllTransactions_All_Channels_context_t; - typedef struct { CF_Transaction_t *txn; From 16b9bdd99c96fa9cc544f6625380c8aefd5009be Mon Sep 17 00:00:00 2001 From: Tekin Ertekin Date: Sun, 6 Sep 2026 11:09:23 +0300 Subject: [PATCH 13/18] Fix #517, Ignore empty ranges in CF_ChunkListAdd A File Data PDU carrying an offset but no file data decodes to data_len 0, because the decoder takes the data length from whatever remains in the PDU (CF_CODEC_GET_REMAIN) and nothing rejects an empty remainder. The receive path then calls CF_ChunkListAdd with size 0, and CF_Chunks_CombineNext computes chunk_end == chunk->offset, which trips CF_Assert(chunk_end > chunk->offset). The sender reaches the same call with size 0 as well: a NAK segment request with offset_start == offset_end passes both of the checks in CF_CFDP_S_ProcessNak, which reject only offset_end < offset_start and offset_end > fsize. In a debug build either path aborts. In a normal build CF_Assert compiles away and the empty chunk is stored, where it takes a slot in the fixed chunk list and splits the surrounding gap in two, so a NAK asks for two segments where one would do. Since both the gap computation and the NAK segment list are capped, those extra segments crowd out real ones. An empty range covers no data, so the fix drops it in CF_ChunkListAdd. That covers both callers and leaves the tracked byte coverage unchanged. Testing performed: Built fsw/src/cf_chunk.c standalone against minimal headers, since the assert behavior differs between a debug and a normal build. ``` clang -std=c99 -DCF_DEBUG_BUILD -I stub -I fsw/src -o h_debug harness.c fsw/src/cf_chunk.c clang -std=c99 -I stub -I fsw/src -o h_normal harness.c fsw/src/cf_chunk.c ``` Before: the debug build aborts on CF_ChunkListAdd(list, 100, 0) with "Assertion failed: (chunk_end > chunk->offset)" (SIGABRT, exit 134). The normal build stores the empty chunk, and 62 empty ranges fill a 58 entry list. After: the debug build exits 0, the empty range is not stored, and the list holds only the one real chunk. Over 20000 randomized rounds of mixed adds (about a quarter of them empty), comparing a list built with the empty ranges against one built without them: tracked byte coverage was identical in every round both before and after the fix, the gap count differed in 16548 rounds before the fix (up to 11 extra segments) and in 0 rounds after, and CF_Assert was violated 67216 times before and 0 times after. The new unit test asserts 7 conditions; 5 of them fail against the unpatched CF_ChunkListAdd and all pass against the patched one. Expected behavior changes: Behavior Change: an empty range passed to CF_ChunkListAdd is ignored rather than stored. Zero-length File Data PDUs and zero-length NAK segment requests no longer consume a chunk list entry or fragment a gap. This contribution was prepared with AI assistance. --- fsw/src/cf_chunk.c | 14 ++++++++++++-- unit-test/cf_chunk_tests.c | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/fsw/src/cf_chunk.c b/fsw/src/cf_chunk.c index 301dbb4e..ffd3172b 100644 --- a/fsw/src/cf_chunk.c +++ b/fsw/src/cf_chunk.c @@ -281,8 +281,18 @@ void CF_Chunks_Insert(CF_ChunkList_t *chunks, CF_ChunkIdx_t i, const CF_Chunk_t *-----------------------------------------------------------------*/ void CF_ChunkListAdd(CF_ChunkList_t *chunks, CF_ChunkOffset_t offset, CF_ChunkSize_t size) { - const CF_Chunk_t chunk = { offset, size }; - const CF_ChunkIdx_t i = CF_Chunks_FindInsertPosition(chunks, &chunk); + const CF_Chunk_t chunk = { offset, size }; + CF_ChunkIdx_t i; + + /* An empty range covers no data, so there is nothing to track. Storing it would + * consume a list entry and split a surrounding gap in two, and CF_Chunks_CombineNext + * asserts that the chunk end is past its offset. */ + if (size == 0) + { + return; + } + + i = CF_Chunks_FindInsertPosition(chunks, &chunk); /* PTFO: files won't be so big we need to gracefully handle overflow, * and in that case the user should change everything in chunks diff --git a/unit-test/cf_chunk_tests.c b/unit-test/cf_chunk_tests.c index b087d4fa..4a7b0a71 100644 --- a/unit-test/cf_chunk_tests.c +++ b/unit-test/cf_chunk_tests.c @@ -163,6 +163,30 @@ void Test_CF_Chunk_CreateAddReset(void) UtAssert_UINT32_EQ(clist.count, 3); } +/* Cover add of an empty range, which covers no data and must not be stored */ +void Test_CF_Chunk_AddEmpty(void) +{ + CF_ChunkList_t clist; + CF_Chunk_t chunks[3]; + + CF_ChunkListInit(&clist, sizeof(chunks) / sizeof(chunks[0]), chunks); + + /* Empty range on an empty list */ + UtAssert_VOIDCALL(CF_ChunkListAdd(&clist, 100, 0)); + UtAssert_UINT32_EQ(clist.count, 0); + + /* Empty range between two tracked chunks leaves the list and the gaps alone */ + CF_ChunkListAdd(&clist, 0, 10); + CF_ChunkListAdd(&clist, 100, 10); + UtAssert_VOIDCALL(CF_ChunkListAdd(&clist, 50, 0)); + UtAssert_UINT32_EQ(clist.chunks[0].offset, 0); + UtAssert_UINT32_EQ(clist.chunks[0].size, 10); + UtAssert_UINT32_EQ(clist.chunks[1].offset, 100); + UtAssert_UINT32_EQ(clist.chunks[1].size, 10); + UtAssert_UINT32_EQ(clist.count, 2); + UtAssert_UINT32_EQ(CF_ChunkList_ComputeGaps(&clist, TEST_CF_MAX_GAPS, 200, 0, NULL, NULL), 2); +} + /* Cover combination cases */ void Test_CF_Chunk_Combine(void) { @@ -360,6 +384,7 @@ void UtTest_Setup(void) { /* Full coverage with just this section of tests */ TEST_CF_ADD(Test_CF_Chunk_CreateAddReset); + TEST_CF_ADD(Test_CF_Chunk_AddEmpty); TEST_CF_ADD(Test_CF_Chunk_Combine); TEST_CF_ADD(Test_CF_Chunk_GetRmFirst); TEST_CF_ADD(Test_CF_Chunk_ComputeGaps); From 91143ba2332a38b3a155ef792022af8501edbcd4 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 18 Sep 2026 13:17:18 -0400 Subject: [PATCH 14/18] Fix #521, command compatibility layer for CF Adds an argument translator for CF commands using the previous definitions. All commands which had the definition modified as part of #516 are changed to point at a compatibility shim instead of invoking the command directly. New (temporary) command codes are added to invoke the "non-shim" command directly. This should all be considered deprecated from the start and removed in a future update. This is purely to preserve compatibility with existing scripts. --- CMakeLists.txt | 1 + config/default_cf_fcncode_values.h | 69 ++-- config/default_cf_msgdefs.h | 78 +++++ config/default_cf_msgstruct.h | 187 +++++++++++ fsw/inc/cf_fcncodes.h | 57 ++-- fsw/src/cf_cmd_compat.c | 456 ++++++++++++++++++++++++++ fsw/src/cf_cmd_compat.h | 232 +++++++++++++ fsw/src/cf_dispatch.c | 122 ++++--- unit-test/CMakeLists.txt | 38 ++- unit-test/cf_dispatch_tests.c | 5 +- unit-test/stubs/cf_cmd_compat_stubs.c | 299 +++++++++++++++++ 11 files changed, 1443 insertions(+), 101 deletions(-) create mode 100644 fsw/src/cf_cmd_compat.c create mode 100644 fsw/src/cf_cmd_compat.h create mode 100644 unit-test/stubs/cf_cmd_compat_stubs.c diff --git a/CMakeLists.txt b/CMakeLists.txt index afe3f570..5a6fd3c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ if (CFE_EDS_ENABLED) list(APPEND APP_SRC_FILES fsw/src/cf_eds_dispatch.c) else() list(APPEND APP_SRC_FILES fsw/src/cf_dispatch.c) + list(APPEND APP_SRC_FILES fsw/src/cf_cmd_compat.c) endif() # Create the app module diff --git a/config/default_cf_fcncode_values.h b/config/default_cf_fcncode_values.h index 6193c599..8c142809 100644 --- a/config/default_cf_fcncode_values.h +++ b/config/default_cf_fcncode_values.h @@ -35,28 +35,55 @@ #define CF_CCVAL(x) CF_FunctionCode_##x +/* + * For the interim release, the pre-existing function codes will point + * to the compatibility shim for CF commands. This shim will convert the + * arguments into the new form and invoke the new command. The new commands + * have the command code shifted up by 30. + */ enum CF_FunctionCode { - CF_FunctionCode_NOOP = 0, - CF_FunctionCode_RESET_COUNTERS = 1, - CF_FunctionCode_TX_FILE = 2, - CF_FunctionCode_PLAYBACK_DIR = 3, - CF_FunctionCode_FREEZE = 4, - CF_FunctionCode_THAW = 5, - CF_FunctionCode_SUSPEND = 6, - CF_FunctionCode_RESUME = 7, - CF_FunctionCode_CANCEL = 8, - CF_FunctionCode_ABANDON = 9, - CF_FunctionCode_SET_PARAM = 10, - CF_FunctionCode_GET_PARAM = 11, - CF_FunctionCode_WRITE_QUEUE = 15, - CF_FunctionCode_ENABLE_DEQUEUE = 16, - CF_FunctionCode_DISABLE_DEQUEUE = 17, - CF_FunctionCode_ENABLE_DIR_POLLING = 18, - CF_FunctionCode_DISABLE_DIR_POLLING = 19, - CF_FunctionCode_PURGE_QUEUE = 21, - CF_FunctionCode_ENABLE_ENGINE = 22, - CF_FunctionCode_DISABLE_ENGINE = 23, + CF_FunctionCode_NOOP = 0, + CF_FunctionCode_RESET_COUNTERS_COMPAT = 1, + CF_FunctionCode_TX_FILE_COMPAT = 2, + CF_FunctionCode_PLAYBACK_DIR_COMPAT = 3, + CF_FunctionCode_FREEZE_COMPAT = 4, + CF_FunctionCode_THAW_COMPAT = 5, + CF_FunctionCode_SUSPEND_COMPAT = 6, + CF_FunctionCode_RESUME_COMPAT = 7, + CF_FunctionCode_CANCEL_COMPAT = 8, + CF_FunctionCode_ABANDON_COMPAT = 9, + CF_FunctionCode_SET_PARAM_COMPAT = 10, + CF_FunctionCode_GET_PARAM_COMPAT = 11, + CF_FunctionCode_WRITE_QUEUE_COMPAT = 15, + CF_FunctionCode_ENABLE_DEQUEUE_COMPAT = 16, + CF_FunctionCode_DISABLE_DEQUEUE_COMPAT = 17, + CF_FunctionCode_ENABLE_DIR_POLLING_COMPAT = 18, + CF_FunctionCode_DISABLE_DIR_POLLING_COMPAT = 19, + CF_FunctionCode_PURGE_QUEUE_COMPAT = 21, + + /* NOTE: these commands did not change (they have no args) */ + CF_FunctionCode_ENABLE_ENGINE = 22, + CF_FunctionCode_DISABLE_ENGINE = 23, + + CF_FunctionCode_RESET_COUNTERS = 31, + CF_FunctionCode_TX_FILE = 32, + CF_FunctionCode_PLAYBACK_DIR = 33, + CF_FunctionCode_FREEZE = 34, + CF_FunctionCode_THAW = 35, + CF_FunctionCode_SUSPEND = 36, + CF_FunctionCode_RESUME = 37, + CF_FunctionCode_CANCEL = 38, + CF_FunctionCode_ABANDON = 39, + CF_FunctionCode_SET_PARAM = 40, + CF_FunctionCode_GET_PARAM = 41, + CF_FunctionCode_WRITE_QUEUE = 45, + CF_FunctionCode_ENABLE_DEQUEUE = 46, + CF_FunctionCode_DISABLE_DEQUEUE = 47, + CF_FunctionCode_ENABLE_DIR_POLLING = 48, + CF_FunctionCode_DISABLE_DIR_POLLING = 49, + CF_FunctionCode_PURGE_QUEUE = 51, + }; -#endif \ No newline at end of file +#endif diff --git a/config/default_cf_msgdefs.h b/config/default_cf_msgdefs.h index 0074d55d..8b383f08 100644 --- a/config/default_cf_msgdefs.h +++ b/config/default_cf_msgdefs.h @@ -211,6 +211,16 @@ typedef struct CF_EotPacket_Payload * \{ */ +/** + * \brief Command payload argument union to support 4 uint8's, 2 uint16's or 1 uint32 + */ +typedef union CF_UnionArgs_CompatPayload +{ + uint32 dword; /**< \brief Generic uint32 argument */ + uint16 hword[2]; /**< \brief Generic uint16 array of arguments */ + uint8 byte[4]; /**< \brief Generic uint8 array of arguments */ +} CF_UnionArgs_CompatPayload_t; + /** * \brief Enum labels for use for Reset cmd */ @@ -335,6 +345,17 @@ typedef struct CF_GetParam_Payload CF_ChannelSelect_t chan_num; /**< \brief Channel number */ } CF_GetParam_Payload_t; +/** + * \brief Get parameter command structure + * + * For command details see #CF_GET_PARAM_CC + */ +typedef struct CF_GetParam_CompatPayload +{ + uint8 key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ + uint8 chan_num; /**< \brief Channel number */ +} CF_GetParam_CompatPayload_t; + /** * \brief Set parameter command structure * @@ -348,6 +369,19 @@ typedef struct CF_SetParam_Payload uint8 spare[2]; /**< \brief Alignment spare, uint32 multiple */ } CF_SetParam_Payload_t; +/** + * \brief Set parameter command structure + * + * For command details see #CF_SET_PARAM_CC + */ +typedef struct CF_SetParam_CompatPayload +{ + uint32 value; /**< \brief Parameter value to set */ + uint8 key; /**< \brief Parameter key, see #CF_GetSet_ValueID_t */ + uint8 chan_num; /**< \brief Channel number */ + uint8 spare[2]; /**< \brief Alignment spare, uint32 multiple */ +} CF_SetParam_CompatPayload_t; + /** * \brief Transmit file command structure * @@ -364,6 +398,22 @@ typedef struct CF_TxFile_Payload char dst_filename[CF_FILENAME_MAX_LEN]; /**< \brief Destination file/directory name */ } CF_TxFile_Payload_t; +/** + * \brief Transmit file command structure + * + * For command details see #CF_TX_FILE_CC + */ +typedef struct CF_TxFile_CompatPayload +{ + uint8 cfdp_class; /**< \brief CFDP class: 0=class 1, 1=class 2 */ + uint8 keep; /**< \brief Keep file flag: 1=keep, else delete */ + uint8 chan_num; /**< \brief Channel number */ + uint8 priority; /**< \brief Priority: 0=highest priority */ + CF_EntityId_t dest_id; /**< \brief Destination entity id */ + char src_filename[CF_FILENAME_MAX_LEN]; /**< \brief Source file/directory name */ + char dst_filename[CF_FILENAME_MAX_LEN]; /**< \brief Destination file/directory name */ +} CF_TxFile_CompatPayload_t; + /** * \brief Write Queue command structure * @@ -379,6 +429,21 @@ typedef struct CF_WriteQueue_Payload char filename[CF_FILENAME_MAX_LEN]; /**< \brief Filename written to */ } CF_WriteQueue_Payload_t; +/** + * \brief Write Queue command structure + * + * For command details see #CF_WRITE_QUEUE_CC + */ +typedef struct CF_WriteQueue_CompatPayload +{ + uint8 type; /**< \brief Transaction direction: all=0, up=1, down=2 */ + uint8 chan; /**< \brief Channel number */ + uint8 queue; /**< \brief Queue type: 0=pending, 1=active, 2=history, 3=all */ + uint8 spare; /**< \brief Alignment spare, puts filename on 32-bit boundary */ + + char filename[CF_FILENAME_MAX_LEN]; /**< \brief Filename written to */ +} CF_WriteQueue_CompatPayload_t; + /** * \brief Transaction command structure * @@ -394,6 +459,19 @@ typedef struct CF_Transaction_Payload uint8 spare[2]; /**< \brief Alignment spare for 32-bit multiple */ } CF_Transaction_Payload_t; +/** + * \brief Transaction command structure + * + * For command details see #CF_SUSPEND_CC, #CF_RESUME_CC, #CF_CANCEL_CC, #CF_ABANDON_CC + */ +typedef struct CF_Transaction_CompatPayload +{ + CF_TransactionSeq_t ts; /**< \brief Transaction sequence number */ + CF_EntityId_t eid; /**< \brief Entity id */ + uint8 chan; /**< \brief Channel number: 254=use ts, 255=all channels, else channel */ + uint8 spare[3]; /**< \brief Alignment spare for 32-bit multiple */ +} CF_Transaction_CompatPayload_t; + /**\}*/ /** diff --git a/config/default_cf_msgstruct.h b/config/default_cf_msgstruct.h index dd60de22..e988c459 100644 --- a/config/default_cf_msgstruct.h +++ b/config/default_cf_msgstruct.h @@ -107,6 +107,17 @@ typedef struct CF_ResetCountersCmd CF_ResetCountersCmd_Payload_t Payload; /**< \brief Command arguments */ } CF_ResetCountersCmd_t; +/** + * \brief Reset command structure + * + * For command details see #CF_RESET_CC + */ +typedef struct CF_ResetCountersCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_ResetCountersCompatCmd_t; + /** * \brief Freeze command structure * @@ -118,6 +129,17 @@ typedef struct CF_FreezeCmd CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_FreezeCmd_t; +/** + * \brief Freeze command structure + * + * For command details see #CF_FREEZE_CC + */ +typedef struct CF_FreezeCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_FreezeCompatCmd_t; + /** * \brief Thaw command structure * @@ -129,6 +151,17 @@ typedef struct CF_ThawCmd CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_ThawCmd_t; +/** + * \brief Thaw command structure + * + * For command details see #CF_THAW_CC + */ +typedef struct CF_ThawCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_ThawCompatCmd_t; + /** * \brief EnableDequeue command structure * @@ -140,6 +173,17 @@ typedef struct CF_EnableDequeueCmd CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_EnableDequeueCmd_t; +/** + * \brief EnableDequeue command structure + * + * For command details see #CF_ENABLE_DEQUEUE_CC + */ +typedef struct CF_EnableDequeueCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_EnableDequeueCompatCmd_t; + /** * \brief DisableDequeue command structure * @@ -151,6 +195,17 @@ typedef struct CF_DisableDequeueCmd CF_ChannelSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_DisableDequeueCmd_t; +/** + * \brief DisableDequeue command structure + * + * For command details see #CF_DISABLE_DEQUEUE_CC + */ +typedef struct CF_DisableDequeueCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_DisableDequeueCompatCmd_t; + /** * \brief EnableDirPolling command structure * @@ -162,6 +217,17 @@ typedef struct CF_EnableDirPollingCmd CF_PollDirSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_EnableDirPollingCmd_t; +/** + * \brief EnableDirPolling command structure + * + * For command details see #CF_ENABLE_DIR_POLLING_CC + */ +typedef struct CF_EnableDirPollingCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_EnableDirPollingCompatCmd_t; + /** * \brief DisableDirPolling command structure * @@ -173,6 +239,17 @@ typedef struct CF_DisableDirPollingCmd CF_PollDirSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_DisableDirPollingCmd_t; +/** + * \brief DisableDirPolling command structure + * + * For command details see #CF_DISABLE_DIR_POLLING_CC + */ +typedef struct CF_DisableDirPollingCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_DisableDirPollingCompatCmd_t; + /** * \brief PurgeQueue command structure * @@ -184,6 +261,17 @@ typedef struct CF_PurgeQueueCmd CF_QueueSelect_Payload_t Payload; /**< \brief Command arguments */ } CF_PurgeQueueCmd_t; +/** + * \brief PurgeQueue command structure + * + * For command details see #CF_PURGE_QUEUE_CC + */ +typedef struct CF_PurgeQueueCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_UnionArgs_CompatPayload_t Payload; /**< \brief Generic command arguments */ +} CF_PurgeQueueCompatCmd_t; + /** * \brief Get parameter command structure * @@ -195,6 +283,17 @@ typedef struct CF_GetParamCmd CF_GetParam_Payload_t Payload; } CF_GetParamCmd_t; +/** + * \brief Get parameter command structure + * + * For command details see #CF_GET_PARAM_CC + */ +typedef struct CF_GetParamCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_GetParam_CompatPayload_t Payload; +} CF_GetParamCompatCmd_t; + /** * \brief Set parameter command structure * @@ -206,6 +305,17 @@ typedef struct CF_SetParamCmd CF_SetParam_Payload_t Payload; } CF_SetParamCmd_t; +/** + * \brief Set parameter command structure + * + * For command details see #CF_SET_PARAM_CC + */ +typedef struct CF_SetParamCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_SetParam_CompatPayload_t Payload; +} CF_SetParamCompatCmd_t; + /** * \brief Transmit file command structure * @@ -217,6 +327,17 @@ typedef struct CF_TxFileCmd CF_TxFile_Payload_t Payload; } CF_TxFileCmd_t; +/** + * \brief Transmit file command structure + * + * For command details see #CF_TX_FILE_CC + */ +typedef struct CF_TxFileCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_TxFile_CompatPayload_t Payload; +} CF_TxFileCompatCmd_t; + /** * \brief Write Queue command structure * @@ -228,6 +349,17 @@ typedef struct CF_WriteQueueCmd CF_WriteQueue_Payload_t Payload; } CF_WriteQueueCmd_t; +/** + * \brief Write Queue command structure + * + * For command details see #CF_WRITE_QUEUE_CC + */ +typedef struct CF_WriteQueueCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_WriteQueue_CompatPayload_t Payload; +} CF_WriteQueueCompatCmd_t; + /** * \brief Playback directory command structure * @@ -239,6 +371,17 @@ typedef struct CF_PlaybackDirCmd CF_TxFile_Payload_t Payload; } CF_PlaybackDirCmd_t; +/** + * \brief Playback directory command structure + * + * For command details see #CF_PLAYBACK_DIR_CC + */ +typedef struct CF_PlaybackDirCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_TxFile_CompatPayload_t Payload; +} CF_PlaybackDirCompatCmd_t; + /** * \brief Suspend command structure * @@ -250,6 +393,17 @@ typedef struct CF_SuspendCmd CF_Transaction_Payload_t Payload; } CF_SuspendCmd_t; +/** + * \brief Suspend command structure + * + * For command details see #CF_SUSPEND_CC + */ +typedef struct CF_SuspendCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_Transaction_CompatPayload_t Payload; +} CF_SuspendCompatCmd_t; + /** * \brief Resume command structure * @@ -261,6 +415,17 @@ typedef struct CF_ResumeCmd CF_Transaction_Payload_t Payload; } CF_ResumeCmd_t; +/** + * \brief Resume command structure + * + * For command details see #CF_RESUME_CC + */ +typedef struct CF_ResumeCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_Transaction_CompatPayload_t Payload; +} CF_ResumeCompatCmd_t; + /** * \brief Cancel command structure * @@ -272,6 +437,17 @@ typedef struct CF_CancelCmd CF_Transaction_Payload_t Payload; } CF_CancelCmd_t; +/** + * \brief Cancel command structure + * + * For command details see #CF_CANCEL_CC + */ +typedef struct CF_CancelCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_Transaction_CompatPayload_t Payload; +} CF_CancelCompatCmd_t; + /** * \brief Abandon command structure * @@ -283,6 +459,17 @@ typedef struct CF_AbandonCmd CF_Transaction_Payload_t Payload; } CF_AbandonCmd_t; +/** + * \brief Abandon command structure + * + * For command details see #CF_ABANDON_CC + */ +typedef struct CF_AbandonCompatCmd +{ + CFE_MSG_CommandHeader_t CommandHeader; /**< \brief Command header */ + CF_Transaction_CompatPayload_t Payload; +} CF_AbandonCompatCmd_t; + /** * \brief Send Housekeeping Command * diff --git a/fsw/inc/cf_fcncodes.h b/fsw/inc/cf_fcncodes.h index e3c3a3ce..f2c4b703 100644 --- a/fsw/inc/cf_fcncodes.h +++ b/fsw/inc/cf_fcncodes.h @@ -98,7 +98,8 @@ * \par Criticality * None */ -#define CF_RESET_CC CF_CCVAL(RESET_COUNTERS) +#define CF_RESET_CC CF_CCVAL(RESET_COUNTERS) +#define CF_RESET_COMPAT_CC CF_CCVAL(RESET_COUNTERS_COMPAT) /** * \brief Transmit file @@ -129,7 +130,8 @@ * * \sa #CF_PLAYBACK_DIR_CC */ -#define CF_TX_FILE_CC CF_CCVAL(TX_FILE) +#define CF_TX_FILE_CC CF_CCVAL(TX_FILE) +#define CF_TX_FILE_COMPAT_CC CF_CCVAL(TX_FILE_COMPAT) /** * \brief Playback a directory @@ -161,7 +163,8 @@ * * \sa #CF_TX_FILE_CC */ -#define CF_PLAYBACK_DIR_CC CF_CCVAL(PLAYBACK_DIR) +#define CF_PLAYBACK_DIR_CC CF_CCVAL(PLAYBACK_DIR) +#define CF_PLAYBACK_DIR_COMPAT_CC CF_CCVAL(PLAYBACK_DIR_COMPAT) /** * \brief Freeze a channel @@ -196,7 +199,8 @@ * * \sa #CF_THAW_CC */ -#define CF_FREEZE_CC CF_CCVAL(FREEZE) +#define CF_FREEZE_CC CF_CCVAL(FREEZE) +#define CF_FREEZE_COMPAT_CC CF_CCVAL(FREEZE_COMPAT) /** * \brief Thaw a channel @@ -230,7 +234,8 @@ * * \sa #CF_FREEZE_CC */ -#define CF_THAW_CC CF_CCVAL(THAW) +#define CF_THAW_CC CF_CCVAL(THAW) +#define CF_THAW_COMPAT_CC CF_CCVAL(THAW_COMPAT) /** * \brief Suspend a transaction @@ -266,7 +271,8 @@ * * \sa #CF_RESUME_CC, #CF_CANCEL_CC, #CF_ABANDON_CC */ -#define CF_SUSPEND_CC CF_CCVAL(SUSPEND) +#define CF_SUSPEND_CC CF_CCVAL(SUSPEND) +#define CF_SUSPEND_COMPAT_CC CF_CCVAL(SUSPEND_COMPAT) /** * \brief Resume a transaction @@ -302,7 +308,8 @@ * * \sa #CF_SUSPEND_CC, #CF_CANCEL_CC, #CF_ABANDON_CC */ -#define CF_RESUME_CC CF_CCVAL(RESUME) +#define CF_RESUME_CC CF_CCVAL(RESUME) +#define CF_RESUME_COMPAT_CC CF_CCVAL(RESUME_COMPAT) /** * \brief Cancel a transaction @@ -336,7 +343,8 @@ * * \sa #CF_SUSPEND_CC, #CF_RESUME_CC, #CF_ABANDON_CC */ -#define CF_CANCEL_CC CF_CCVAL(CANCEL) +#define CF_CANCEL_CC CF_CCVAL(CANCEL) +#define CF_CANCEL_COMPAT_CC CF_CCVAL(CANCEL_COMPAT) /** * \brief Abandon a transaction @@ -370,7 +378,8 @@ * * \sa #CF_SUSPEND_CC, #CF_RESUME_CC, #CF_CANCEL_CC */ -#define CF_ABANDON_CC CF_CCVAL(ABANDON) +#define CF_ABANDON_CC CF_CCVAL(ABANDON) +#define CF_ABANDON_COMPAT_CC CF_CCVAL(ABANDON_COMPAT) /** * \brief Set parameter @@ -402,7 +411,8 @@ * * \sa #CF_GET_PARAM_CC */ -#define CF_SET_PARAM_CC CF_CCVAL(SET_PARAM) +#define CF_SET_PARAM_CC CF_CCVAL(SET_PARAM) +#define CF_SET_PARAM_COMPAT_CC CF_CCVAL(SET_PARAM_COMPAT) /** * \brief Get parameter @@ -433,7 +443,8 @@ * * \sa #CF_SET_PARAM_CC */ -#define CF_GET_PARAM_CC CF_CCVAL(GET_PARAM) +#define CF_GET_PARAM_CC CF_CCVAL(GET_PARAM) +#define CF_GET_PARAM_COMPAT_CC CF_CCVAL(GET_PARAM_COMPAT) /** * \brief Write queue @@ -469,7 +480,8 @@ * * \sa #CF_PURGE_QUEUE_CC */ -#define CF_WRITE_QUEUE_CC CF_CCVAL(WRITE_QUEUE) +#define CF_WRITE_QUEUE_CC CF_CCVAL(WRITE_QUEUE) +#define CF_WRITE_QUEUE_COMPAT_CC CF_CCVAL(WRITE_QUEUE_COMPAT) /** * \brief Enable dequeue @@ -502,7 +514,8 @@ * * \sa #CF_DISABLE_DEQUEUE_CC */ -#define CF_ENABLE_DEQUEUE_CC CF_CCVAL(ENABLE_DEQUEUE) +#define CF_ENABLE_DEQUEUE_CC CF_CCVAL(ENABLE_DEQUEUE) +#define CF_ENABLE_DEQUEUE_COMPAT_CC CF_CCVAL(ENABLE_DEQUEUE_COMPAT) /** * \brief Disable dequeue @@ -535,7 +548,8 @@ * * \sa #CF_ENABLE_DEQUEUE_CC */ -#define CF_DISABLE_DEQUEUE_CC CF_CCVAL(DISABLE_DEQUEUE) +#define CF_DISABLE_DEQUEUE_CC CF_CCVAL(DISABLE_DEQUEUE) +#define CF_DISABLE_DEQUEUE_COMPAT_CC CF_CCVAL(DISABLE_DEQUEUE_COMPAT) /** * \brief Enable directory polling @@ -574,7 +588,8 @@ * * \sa #CF_DISABLE_DIR_POLLING_CC */ -#define CF_ENABLE_DIR_POLLING_CC CF_CCVAL(ENABLE_DIR_POLLING) +#define CF_ENABLE_DIR_POLLING_CC CF_CCVAL(ENABLE_DIR_POLLING) +#define CF_ENABLE_DIR_POLLING_COMPAT_CC CF_CCVAL(ENABLE_DIR_POLLING_COMPAT) /** * \brief Disable directory polling @@ -613,7 +628,8 @@ * * \sa #CF_ENABLE_DIR_POLLING_CC */ -#define CF_DISABLE_DIR_POLLING_CC CF_CCVAL(DISABLE_DIR_POLLING) +#define CF_DISABLE_DIR_POLLING_CC CF_CCVAL(DISABLE_DIR_POLLING) +#define CF_DISABLE_DIR_POLLING_COMPAT_CC CF_CCVAL(DISABLE_DIR_POLLING_COMPAT) /** * \brief Purge queue @@ -653,7 +669,8 @@ * * \sa #CF_WRITE_QUEUE_CC */ -#define CF_PURGE_QUEUE_CC CF_CCVAL(PURGE_QUEUE) +#define CF_PURGE_QUEUE_CC CF_CCVAL(PURGE_QUEUE) +#define CF_PURGE_QUEUE_COMPAT_CC CF_CCVAL(PURGE_QUEUE_COMPAT) /** * \brief Enable engine @@ -685,7 +702,8 @@ * * \sa #CF_DISABLE_ENGINE_CC */ -#define CF_ENABLE_ENGINE_CC CF_CCVAL(ENABLE_ENGINE) +#define CF_ENABLE_ENGINE_CC CF_CCVAL(ENABLE_ENGINE) +#define CF_ENABLE_ENGINE_COMPAT_CC CF_CCVAL(ENABLE_ENGINE_COMPAT) /** * \brief Disable engine @@ -717,7 +735,8 @@ * * \sa #CF_DISABLE_ENGINE_CC */ -#define CF_DISABLE_ENGINE_CC CF_CCVAL(DISABLE_ENGINE) +#define CF_DISABLE_ENGINE_CC CF_CCVAL(DISABLE_ENGINE) +#define CF_DISABLE_ENGINE_COMPAT_CC CF_CCVAL(DISABLE_ENGINE_COMPAT) /** \brief Command code limit used for validity check and array sizing */ #define CF_NUM_COMMANDS 24 diff --git a/fsw/src/cf_cmd_compat.c b/fsw/src/cf_cmd_compat.c new file mode 100644 index 00000000..38ad4498 --- /dev/null +++ b/fsw/src/cf_cmd_compat.c @@ -0,0 +1,456 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * The CF Application command handling source file + * + * All ground commands are processed in this file. All supporting functions + * necessary to process the commands are also here. + */ + +#include "cf_app.h" +#include "cf_eventids.h" +#include "cf_cmd.h" +#include "cf_cmd_compat.h" + +#define CF_CMD_COMPAT_COMPOUND_KEY (254) +#define CF_CMD_COMPAT_ALL_CHANNELS (255) +#define CF_CMD_COMPAT_ALL_POLLDIRS (CF_ALL_CHANNELS) + +/*---------------------------------------------------------------- + * + * Local helper function + * Convert the old-style uint8 chan number to the CF_ChannelSelect_t value that correlates + * + *-----------------------------------------------------------------*/ +static CF_ChannelSelect_t CF_Translate_CompatChannel(uint8 input) +{ + if (input == CF_CMD_COMPAT_COMPOUND_KEY || input == CF_CMD_COMPAT_ALL_CHANNELS) + { + return CF_ALL_CHANNELS; + } + + if (input <= CF_NUM_CHANNELS) + { + return CF_ChannelSelect_FromInt(input + 1); + } + + /* invalid value, keep it as is for event reporting */ + return CF_ChannelSelect_FromInt(input); +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Convert the old-style uint8 poll dir idx to the CF_PollIdxSelect_t value that correlates + * + *-----------------------------------------------------------------*/ +static CF_PollIdxSelect_t CF_Translate_CompatPollDir(uint8 input) +{ + if (input == CF_CMD_COMPAT_ALL_POLLDIRS) + { + return 0; + } + + if (input <= CF_MAX_POLLING_DIR_PER_CHAN) + { + return (input + 1); + } + + /* invalid value, keep it as is for event reporting */ + return (input); +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Convert the old-style uint8 key to the CF_GetSet_ValueID_Enum_t value that correlates + * + *-----------------------------------------------------------------*/ +static CF_GetSet_ValueID_Enum_t CF_Translate_CompatValueID(uint8 input) +{ + CF_GetSet_ValueID_Enum_t key; + + /* 0 is now reserved. All valid values shifted up by 1. */ + key = input; + if (key < CF_GetSet_ValueID_MAX) + { + ++key; + } + return key; +} + +/*---------------------------------------------------------------- + * + * Local helper function + * Convert the old-style Transaction specifier payload + * Most args are compatible, but the "compound key" is now a separate flag. + * + *-----------------------------------------------------------------*/ +static void CF_Translate_Transaction_CompatPayload(CF_Transaction_Payload_t *output, + const CF_Transaction_CompatPayload_t *input) +{ + output->ts = input->ts; + output->eid = input->eid; + if (input->chan == CF_CMD_COMPAT_COMPOUND_KEY) + { + output->use_ts_eid = 1; + output->chan_num = CF_ALL_CHANNELS; + } + else + { + output->chan_num = CF_Translate_CompatChannel(input->chan); + } +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_ResetCountersCompatCmd(const CF_ResetCountersCompatCmd_t *msg) +{ + CF_ResetCountersCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ResetType = msg->Payload.byte[0]; /* reset type selector is compatible */ + + return CF_ResetCountersCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_TxFileCompatCmd(const CF_TxFileCompatCmd_t *msg) +{ + CF_TxFileCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + + newcmd.Payload.cfdp_class = msg->Payload.cfdp_class; + newcmd.Payload.keep = msg->Payload.keep; + newcmd.Payload.chan_num = CF_Translate_CompatChannel(msg->Payload.chan_num); + newcmd.Payload.priority = msg->Payload.priority; + newcmd.Payload.dest_id = msg->Payload.dest_id; + strncpy(newcmd.Payload.src_filename, msg->Payload.src_filename, sizeof(newcmd.Payload.src_filename)); + strncpy(newcmd.Payload.dst_filename, msg->Payload.dst_filename, sizeof(newcmd.Payload.dst_filename)); + + return CF_TxFileCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_PlaybackDirCompatCmd(const CF_PlaybackDirCompatCmd_t *msg) +{ + CF_PlaybackDirCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + + newcmd.Payload.cfdp_class = msg->Payload.cfdp_class; + newcmd.Payload.keep = msg->Payload.keep; + newcmd.Payload.chan_num = CF_Translate_CompatChannel(msg->Payload.chan_num); + newcmd.Payload.priority = msg->Payload.priority; + newcmd.Payload.dest_id = msg->Payload.dest_id; + strncpy(newcmd.Payload.src_filename, msg->Payload.src_filename, sizeof(newcmd.Payload.src_filename)); + strncpy(newcmd.Payload.dst_filename, msg->Payload.dst_filename, sizeof(newcmd.Payload.dst_filename)); + + return CF_PlaybackDirCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_FreezeCompatCmd(const CF_FreezeCompatCmd_t *msg) +{ + CF_FreezeCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + + return CF_FreezeCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_ThawCompatCmd(const CF_ThawCompatCmd_t *msg) +{ + CF_ThawCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + + return CF_ThawCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_SuspendCompatCmd(const CF_SuspendCompatCmd_t *msg) +{ + CF_SuspendCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + CF_Translate_Transaction_CompatPayload(&newcmd.Payload, &msg->Payload); + + return CF_SuspendCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_ResumeCompatCmd(const CF_ResumeCompatCmd_t *msg) +{ + CF_ResumeCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + CF_Translate_Transaction_CompatPayload(&newcmd.Payload, &msg->Payload); + + return CF_ResumeCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_CancelCompatCmd(const CF_CancelCompatCmd_t *msg) +{ + CF_CancelCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + CF_Translate_Transaction_CompatPayload(&newcmd.Payload, &msg->Payload); + + return CF_CancelCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_AbandonCompatCmd(const CF_AbandonCompatCmd_t *msg) +{ + CF_AbandonCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + CF_Translate_Transaction_CompatPayload(&newcmd.Payload, &msg->Payload); + + return CF_AbandonCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_EnableDequeueCompatCmd(const CF_EnableDequeueCompatCmd_t *msg) +{ + CF_EnableDequeueCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + + return CF_EnableDequeueCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_DisableDequeueCompatCmd(const CF_DisableDequeueCompatCmd_t *msg) +{ + CF_DisableDequeueCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + + return CF_DisableDequeueCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_EnableDirPollingCompatCmd(const CF_EnableDirPollingCompatCmd_t *msg) +{ + CF_EnableDirPollingCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + newcmd.Payload.PollDirIndx = CF_Translate_CompatPollDir(msg->Payload.byte[1]); + + return CF_EnableDirPollingCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_DisableDirPollingCompatCmd(const CF_DisableDirPollingCompatCmd_t *msg) +{ + CF_DisableDirPollingCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + newcmd.Payload.PollDirIndx = CF_Translate_CompatPollDir(msg->Payload.byte[1]); + + return CF_DisableDirPollingCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_PurgeQueueCompatCmd(const CF_PurgeQueueCompatCmd_t *msg) +{ + CF_PurgeQueueCmd_t newcmd; + uint8 queueidx; + + memset(&newcmd, 0, sizeof(newcmd)); + newcmd.Payload.ChannelSelect = CF_Translate_CompatChannel(msg->Payload.byte[0]); + + /* byte 1 specified the queue, only pending(0) and history(1) as options. 2=all */ + queueidx = msg->Payload.byte[1]; + if (queueidx < CF_QueueSelect_MAX) + { + /* history(1) and all(2) are shifted an extra value to match */ + if (queueidx != 0) + { + ++queueidx; + } + queueidx = (queueidx + 1) % CF_QueueSelect_MAX; + } + newcmd.Payload.QueueSelect = queueidx; + + return CF_PurgeQueueCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_WriteQueueCompatCmd(const CF_WriteQueueCompatCmd_t *msg) +{ + CF_WriteQueueCmd_t newcmd; + uint8 queueidx; + + memset(&newcmd, 0, sizeof(newcmd)); + + newcmd.Payload.dir_type = msg->Payload.type; /* direction is compatible */ + newcmd.Payload.chan_num = CF_Translate_CompatChannel(msg->Payload.chan); + queueidx = msg->Payload.queue; /* Queue type: 0=pending, 1=active, 2=history, 3=all */ + if (queueidx <= CF_QueueSelect_MAX) + { + /* we need to "roll" the value - 0 is now all, instead of 3. */ + queueidx = (queueidx + 1) % CF_QueueSelect_MAX; + } + newcmd.Payload.queue = queueidx; + + return CF_WriteQueueCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_SetParamCompatCmd(const CF_SetParamCompatCmd_t *msg) +{ + CF_SetParamCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + + newcmd.Payload.value = msg->Payload.value; + newcmd.Payload.key = CF_Translate_CompatValueID(msg->Payload.key); + newcmd.Payload.chan_num = CF_Translate_CompatChannel(msg->Payload.chan_num); + + return CF_SetParamCmd(&newcmd); +} + +/*---------------------------------------------------------------- + * + * Application-scope internal function + * See description in cf_cmd.h for argument/return detail + * This is the entry point function invoked from the SB command handler + * + *-----------------------------------------------------------------*/ +CFE_Status_t CF_GetParamCompatCmd(const CF_GetParamCompatCmd_t *msg) +{ + CF_GetParamCmd_t newcmd; + + memset(&newcmd, 0, sizeof(newcmd)); + + newcmd.Payload.key = CF_Translate_CompatValueID(msg->Payload.key); + newcmd.Payload.chan_num = CF_Translate_CompatChannel(msg->Payload.chan_num); + + return CF_GetParamCmd(&newcmd); +} diff --git a/fsw/src/cf_cmd_compat.h b/fsw/src/cf_cmd_compat.h new file mode 100644 index 00000000..3d1d103f --- /dev/null +++ b/fsw/src/cf_cmd_compat.h @@ -0,0 +1,232 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * CF command processing function declarations + * This implements a compatibility layer to allow a smoother transition + * between command definitions. The goal is to employ consistent patterns + * across all CMD/TLM where resources are identified by integers of a consistent + * range and definition. Specifically, the integer value of "0" will be reserved + * to indicate "all" for a given resource, or considered invalid if the command + * cannot be applied to all resources. + * + * Because this shifts values for what was previously considered valid (e.g. passing + * 0 now means all where it previously meant channel 0), the code here implements + * a translation layer for old command definitions. These will rewrite the command + * to be in the new format. + * + * This entire source module should be considered deprecated and will be removed + * in an upcoming release. + */ + +#ifndef CF_CMD_COMPAT_H +#define CF_CMD_COMPAT_H + +#include "cfe.h" +#include "cf_app.h" +#include "cf_utils.h" + +/************************************************************************/ +/** @brief The reset counters command. + * + * @par Description + * This function has a signature the same of all cmd_ functions. + * Resets the given counter, or all. + * Increments the command accept or reject counter. If the command + * counters are reset, then there is no increment. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_ResetCountersCompatCmd(const CF_ResetCountersCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to start a file transfer. + * + * @par Description + * This function has a signature the same of all cmd_ functions. + * Increments the command accept or reject counter. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + * + */ +CFE_Status_t CF_TxFileCompatCmd(const CF_TxFileCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to start directory playback. + * + * @par Description + * This function has a signature the same of all cmd_ functions. + * Increments the command accept or reject counter. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_PlaybackDirCompatCmd(const CF_PlaybackDirCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Freeze a channel. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_FreezeCompatCmd(const CF_FreezeCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Thaw a channel. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_ThawCompatCmd(const CF_ThawCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle transaction suspend command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_SuspendCompatCmd(const CF_SuspendCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle transaction resume command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_ResumeCompatCmd(const CF_ResumeCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle a cancel ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_CancelCompatCmd(const CF_CancelCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle an abandon ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_AbandonCompatCmd(const CF_AbandonCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle an enable dequeue ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_EnableDequeueCompatCmd(const CF_EnableDequeueCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Handle a disable dequeue ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_DisableDequeueCompatCmd(const CF_DisableDequeueCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Enable a polling dir ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_EnableDirPollingCompatCmd(const CF_EnableDirPollingCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Disable a polling dir ground command. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_DisableDirPollingCompatCmd(const CF_DisableDirPollingCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to purge either the history or pending queues. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_PurgeQueueCompatCmd(const CF_PurgeQueueCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to write a file with queue information. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_WriteQueueCompatCmd(const CF_WriteQueueCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to set a configuration parameter. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_SetParamCompatCmd(const CF_SetParamCompatCmd_t *msg); + +/************************************************************************/ +/** @brief Ground command to get a configuration parameter. + * + * @par Assumptions, External Events, and Notes: + * msg must not be NULL. + * + * @param msg Pointer to command message + */ +CFE_Status_t CF_GetParamCompatCmd(const CF_GetParamCompatCmd_t *msg); + +#endif diff --git a/fsw/src/cf_dispatch.c b/fsw/src/cf_dispatch.c index ed7e0abc..e72ae3f5 100644 --- a/fsw/src/cf_dispatch.c +++ b/fsw/src/cf_dispatch.c @@ -29,6 +29,7 @@ #include "cf_app.h" #include "cf_eventids.h" #include "cf_cmd.h" +#include "cf_cmd_compat.h" #include "cfe.h" #include @@ -44,49 +45,83 @@ void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *BufPtr) typedef void (*const handler_fn_t)(const void *); static handler_fn_t fns[] = { - [CF_NOOP_CC] = (handler_fn_t)CF_NoopCmd, - [CF_RESET_CC] = (handler_fn_t)CF_ResetCountersCmd, - [CF_TX_FILE_CC] = (handler_fn_t)CF_TxFileCmd, - [CF_PLAYBACK_DIR_CC] = (handler_fn_t)CF_PlaybackDirCmd, - [CF_FREEZE_CC] = (handler_fn_t)CF_FreezeCmd, - [CF_THAW_CC] = (handler_fn_t)CF_ThawCmd, - [CF_SUSPEND_CC] = (handler_fn_t)CF_SuspendCmd, - [CF_RESUME_CC] = (handler_fn_t)CF_ResumeCmd, - [CF_CANCEL_CC] = (handler_fn_t)CF_CancelCmd, - [CF_ABANDON_CC] = (handler_fn_t)CF_AbandonCmd, - [CF_SET_PARAM_CC] = (handler_fn_t)CF_SetParamCmd, - [CF_GET_PARAM_CC] = (handler_fn_t)CF_GetParamCmd, - [CF_WRITE_QUEUE_CC] = (handler_fn_t)CF_WriteQueueCmd, - [CF_ENABLE_DEQUEUE_CC] = (handler_fn_t)CF_EnableDequeueCmd, - [CF_DISABLE_DEQUEUE_CC] = (handler_fn_t)CF_DisableDequeueCmd, - [CF_ENABLE_DIR_POLLING_CC] = (handler_fn_t)CF_EnableDirPollingCmd, - [CF_DISABLE_DIR_POLLING_CC] = (handler_fn_t)CF_DisableDirPollingCmd, - [CF_PURGE_QUEUE_CC] = (handler_fn_t)CF_PurgeQueueCmd, - [CF_ENABLE_ENGINE_CC] = (handler_fn_t)CF_EnableEngineCmd, - [CF_DISABLE_ENGINE_CC] = (handler_fn_t)CF_DisableEngineCmd, + [CF_NOOP_CC] = (handler_fn_t)CF_NoopCmd, + [CF_RESET_COMPAT_CC] = (handler_fn_t)CF_ResetCountersCompatCmd, + [CF_TX_FILE_COMPAT_CC] = (handler_fn_t)CF_TxFileCompatCmd, + [CF_PLAYBACK_DIR_COMPAT_CC] = (handler_fn_t)CF_PlaybackDirCompatCmd, + [CF_FREEZE_COMPAT_CC] = (handler_fn_t)CF_FreezeCompatCmd, + [CF_THAW_COMPAT_CC] = (handler_fn_t)CF_ThawCompatCmd, + [CF_SUSPEND_COMPAT_CC] = (handler_fn_t)CF_SuspendCompatCmd, + [CF_RESUME_COMPAT_CC] = (handler_fn_t)CF_ResumeCompatCmd, + [CF_CANCEL_COMPAT_CC] = (handler_fn_t)CF_CancelCompatCmd, + [CF_ABANDON_COMPAT_CC] = (handler_fn_t)CF_AbandonCompatCmd, + [CF_SET_PARAM_COMPAT_CC] = (handler_fn_t)CF_SetParamCompatCmd, + [CF_GET_PARAM_COMPAT_CC] = (handler_fn_t)CF_GetParamCompatCmd, + [CF_WRITE_QUEUE_COMPAT_CC] = (handler_fn_t)CF_WriteQueueCompatCmd, + [CF_ENABLE_DEQUEUE_COMPAT_CC] = (handler_fn_t)CF_EnableDequeueCompatCmd, + [CF_DISABLE_DEQUEUE_COMPAT_CC] = (handler_fn_t)CF_DisableDequeueCompatCmd, + [CF_ENABLE_DIR_POLLING_COMPAT_CC] = (handler_fn_t)CF_EnableDirPollingCompatCmd, + [CF_DISABLE_DIR_POLLING_COMPAT_CC] = (handler_fn_t)CF_DisableDirPollingCompatCmd, + [CF_PURGE_QUEUE_COMPAT_CC] = (handler_fn_t)CF_PurgeQueueCompatCmd, + [CF_ENABLE_ENGINE_CC] = (handler_fn_t)CF_EnableEngineCmd, + [CF_DISABLE_ENGINE_CC] = (handler_fn_t)CF_DisableEngineCmd, + [CF_RESET_CC] = (handler_fn_t)CF_ResetCountersCmd, + [CF_TX_FILE_CC] = (handler_fn_t)CF_TxFileCmd, + [CF_PLAYBACK_DIR_CC] = (handler_fn_t)CF_PlaybackDirCmd, + [CF_FREEZE_CC] = (handler_fn_t)CF_FreezeCmd, + [CF_THAW_CC] = (handler_fn_t)CF_ThawCmd, + [CF_SUSPEND_CC] = (handler_fn_t)CF_SuspendCmd, + [CF_RESUME_CC] = (handler_fn_t)CF_ResumeCmd, + [CF_CANCEL_CC] = (handler_fn_t)CF_CancelCmd, + [CF_ABANDON_CC] = (handler_fn_t)CF_AbandonCmd, + [CF_SET_PARAM_CC] = (handler_fn_t)CF_SetParamCmd, + [CF_GET_PARAM_CC] = (handler_fn_t)CF_GetParamCmd, + [CF_WRITE_QUEUE_CC] = (handler_fn_t)CF_WriteQueueCmd, + [CF_ENABLE_DEQUEUE_CC] = (handler_fn_t)CF_EnableDequeueCmd, + [CF_DISABLE_DEQUEUE_CC] = (handler_fn_t)CF_DisableDequeueCmd, + [CF_ENABLE_DIR_POLLING_CC] = (handler_fn_t)CF_EnableDirPollingCmd, + [CF_DISABLE_DIR_POLLING_CC] = (handler_fn_t)CF_DisableDirPollingCmd, + [CF_PURGE_QUEUE_CC] = (handler_fn_t)CF_PurgeQueueCmd, }; static const uint16 expected_lengths[] = { - [CF_NOOP_CC] = sizeof(CF_NoopCmd_t), - [CF_RESET_CC] = sizeof(CF_ResetCountersCmd_t), - [CF_TX_FILE_CC] = sizeof(CF_TxFileCmd_t), - [CF_PLAYBACK_DIR_CC] = sizeof(CF_PlaybackDirCmd_t), - [CF_FREEZE_CC] = sizeof(CF_FreezeCmd_t), - [CF_THAW_CC] = sizeof(CF_ThawCmd_t), - [CF_SUSPEND_CC] = sizeof(CF_SuspendCmd_t), - [CF_RESUME_CC] = sizeof(CF_ResumeCmd_t), - [CF_CANCEL_CC] = sizeof(CF_CancelCmd_t), - [CF_ABANDON_CC] = sizeof(CF_AbandonCmd_t), - [CF_SET_PARAM_CC] = sizeof(CF_SetParamCmd_t), - [CF_GET_PARAM_CC] = sizeof(CF_GetParamCmd_t), - [CF_WRITE_QUEUE_CC] = sizeof(CF_WriteQueueCmd_t), - [CF_ENABLE_DEQUEUE_CC] = sizeof(CF_EnableDequeueCmd_t), - [CF_DISABLE_DEQUEUE_CC] = sizeof(CF_DisableDequeueCmd_t), - [CF_ENABLE_DIR_POLLING_CC] = sizeof(CF_EnableDirPollingCmd_t), - [CF_DISABLE_DIR_POLLING_CC] = sizeof(CF_DisableDirPollingCmd_t), - [CF_PURGE_QUEUE_CC] = sizeof(CF_PurgeQueueCmd_t), - [CF_ENABLE_ENGINE_CC] = sizeof(CF_EnableEngineCmd_t), - [CF_DISABLE_ENGINE_CC] = sizeof(CF_DisableEngineCmd_t), + [CF_NOOP_CC] = sizeof(CF_NoopCmd_t), + [CF_RESET_COMPAT_CC] = sizeof(CF_ResetCountersCompatCmd_t), + [CF_TX_FILE_COMPAT_CC] = sizeof(CF_TxFileCompatCmd_t), + [CF_PLAYBACK_DIR_COMPAT_CC] = sizeof(CF_PlaybackDirCompatCmd_t), + [CF_FREEZE_COMPAT_CC] = sizeof(CF_FreezeCompatCmd_t), + [CF_THAW_COMPAT_CC] = sizeof(CF_ThawCompatCmd_t), + [CF_SUSPEND_COMPAT_CC] = sizeof(CF_SuspendCompatCmd_t), + [CF_RESUME_COMPAT_CC] = sizeof(CF_ResumeCompatCmd_t), + [CF_CANCEL_COMPAT_CC] = sizeof(CF_CancelCompatCmd_t), + [CF_ABANDON_COMPAT_CC] = sizeof(CF_AbandonCompatCmd_t), + [CF_SET_PARAM_COMPAT_CC] = sizeof(CF_SetParamCompatCmd_t), + [CF_GET_PARAM_COMPAT_CC] = sizeof(CF_GetParamCompatCmd_t), + [CF_WRITE_QUEUE_COMPAT_CC] = sizeof(CF_WriteQueueCompatCmd_t), + [CF_ENABLE_DEQUEUE_COMPAT_CC] = sizeof(CF_EnableDequeueCompatCmd_t), + [CF_DISABLE_DEQUEUE_COMPAT_CC] = sizeof(CF_DisableDequeueCompatCmd_t), + [CF_ENABLE_DIR_POLLING_COMPAT_CC] = sizeof(CF_EnableDirPollingCompatCmd_t), + [CF_DISABLE_DIR_POLLING_COMPAT_CC] = sizeof(CF_DisableDirPollingCompatCmd_t), + [CF_PURGE_QUEUE_COMPAT_CC] = sizeof(CF_PurgeQueueCompatCmd_t), + [CF_ENABLE_ENGINE_CC] = sizeof(CF_EnableEngineCmd_t), + [CF_DISABLE_ENGINE_CC] = sizeof(CF_DisableEngineCmd_t), + [CF_RESET_CC] = sizeof(CF_ResetCountersCmd_t), + [CF_TX_FILE_CC] = sizeof(CF_TxFileCmd_t), + [CF_PLAYBACK_DIR_CC] = sizeof(CF_PlaybackDirCmd_t), + [CF_FREEZE_CC] = sizeof(CF_FreezeCmd_t), + [CF_THAW_CC] = sizeof(CF_ThawCmd_t), + [CF_SUSPEND_CC] = sizeof(CF_SuspendCmd_t), + [CF_RESUME_CC] = sizeof(CF_ResumeCmd_t), + [CF_CANCEL_CC] = sizeof(CF_CancelCmd_t), + [CF_ABANDON_CC] = sizeof(CF_AbandonCmd_t), + [CF_SET_PARAM_CC] = sizeof(CF_SetParamCmd_t), + [CF_GET_PARAM_CC] = sizeof(CF_GetParamCmd_t), + [CF_WRITE_QUEUE_CC] = sizeof(CF_WriteQueueCmd_t), + [CF_ENABLE_DEQUEUE_CC] = sizeof(CF_EnableDequeueCmd_t), + [CF_DISABLE_DEQUEUE_CC] = sizeof(CF_DisableDequeueCmd_t), + [CF_ENABLE_DIR_POLLING_CC] = sizeof(CF_EnableDirPollingCmd_t), + [CF_DISABLE_DIR_POLLING_CC] = sizeof(CF_DisableDirPollingCmd_t), + [CF_PURGE_QUEUE_CC] = sizeof(CF_PurgeQueueCmd_t), }; CFE_MSG_FcnCode_t cmd = 0; @@ -94,7 +129,7 @@ void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *BufPtr) CFE_MSG_GetFcnCode(&BufPtr->Msg, &cmd); - if (cmd < (sizeof(expected_lengths) / sizeof(expected_lengths[0]))) + if (cmd < (sizeof(expected_lengths) / sizeof(expected_lengths[0])) && fns[cmd] != NULL) { CFE_MSG_GetSize(&BufPtr->Msg, &len); @@ -102,10 +137,7 @@ void CF_ProcessGroundCommand(const CFE_SB_Buffer_t *BufPtr) if (len == expected_lengths[cmd]) { /* if valid, process command */ - if (fns[cmd]) - { - fns[cmd](BufPtr); - } + fns[cmd](BufPtr); } else { diff --git a/unit-test/CMakeLists.txt b/unit-test/CMakeLists.txt index 41548a20..dd01eac1 100644 --- a/unit-test/CMakeLists.txt +++ b/unit-test/CMakeLists.txt @@ -34,10 +34,7 @@ # All "stubs" files in here should be auto-generated using UtAssert generate_stubs.pl tool # From the top-level directory of CF these can be regenerated with a command like: # ../../osal/ut_assert/scripts/generate_stubs.pl ./unit-test/stubs fsw/src/*.h -add_cfe_coverage_stubs(cf_internal - utilities/cf_test_utils.c - utilities/cf_test_alt_handler.c - +set(CF_UT_STUB_SRC_LIST stubs/cf_app_global.c stubs/cf_app_stubs.c stubs/cf_cfdp_handlers.c @@ -61,6 +58,18 @@ add_cfe_coverage_stubs(cf_internal stubs/cf_utils_stubs.c ) +# cmd compatibility shim only enabled in non-EDS build +if (NOT CFE_EDS_ENABLED) + list(APPEND CF_UT_STUB_SRC_LIST stubs/cf_cmd_compat_stubs.c) +endif() + +add_cfe_coverage_stubs(cf_internal + utilities/cf_test_utils.c + utilities/cf_test_alt_handler.c + ${CF_UT_STUB_SRC_LIST} +) + + target_link_libraries(coverage-cf_internal-stubs ut_core_api_stubs ut_assert) target_include_directories(coverage-cf_internal-stubs PUBLIC utilities) target_include_directories(coverage-cf_internal-stubs PUBLIC ../fsw/inc) @@ -75,17 +84,20 @@ foreach(SRCFILE ${APP_SRC_FILES}) # extension, this will be used as the base name of the unit test file. get_filename_component(UNIT_NAME "${SRCFILE}" NAME_WE) - # Use the module name to make the tests' name by adding _tests to the end - set(TESTS_NAME "${UNIT_NAME}_tests") + # Skip UT for compatibility shims. These are deprecated. + if (NOT UNIT_NAME MATCHES "compat$") + # Use the module name to make the tests' name by adding _tests to the end + set(TESTS_NAME "${UNIT_NAME}_tests") - # Get the tests' sourcefile name with unit test path and extension - set(TESTS_SOURCE_FILE "${PROJECT_SOURCE_DIR}/unit-test/${TESTS_NAME}.c") + # Get the tests' sourcefile name with unit test path and extension + set(TESTS_SOURCE_FILE "${PROJECT_SOURCE_DIR}/unit-test/${TESTS_NAME}.c") - # Create the coverage test executable - # Note: This renders a target named "coverage-cf-${UNIT_NAME}-testrunner" - add_cfe_coverage_test(cf "${UNIT_NAME}" "${TESTS_SOURCE_FILE}" "${CFS_CF_SOURCE_DIR}/${SRCFILE}") + # Create the coverage test executable + # Note: This renders a target named "coverage-cf-${UNIT_NAME}-testrunner" + add_cfe_coverage_test(cf "${UNIT_NAME}" "${TESTS_SOURCE_FILE}" "${CFS_CF_SOURCE_DIR}/${SRCFILE}") - # CF test cases should be linked with stubs for other internal CF units - add_cfe_coverage_dependency(cf "${UNIT_NAME}" cf_internal) + # CF test cases should be linked with stubs for other internal CF units + add_cfe_coverage_dependency(cf "${UNIT_NAME}" cf_internal) + endif() endforeach() diff --git a/unit-test/cf_dispatch_tests.c b/unit-test/cf_dispatch_tests.c index 0c3c8e26..adc41ddb 100644 --- a/unit-test/cf_dispatch_tests.c +++ b/unit-test/cf_dispatch_tests.c @@ -183,11 +183,10 @@ void Test_CF_ProcessGroundCommand_ReceivesCmdCode_0x0C_AndDoNothingBecause_fns_1 /* Assert */ UtAssert_STUB_COUNT(CFE_MSG_GetFcnCode, 1); - UtAssert_STUB_COUNT(CFE_MSG_GetSize, 1); - UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 0); + UtAssert_STUB_COUNT(CFE_EVS_SendEvent, 1); /* Assert for incremented counter */ UtAssert_UINT32_EQ(CF_AppData.counters.cmd, 0); - UtAssert_UINT32_EQ(CF_AppData.counters.err, 0); + UtAssert_UINT32_EQ(CF_AppData.counters.err, 1); } /******************************************************************************* diff --git a/unit-test/stubs/cf_cmd_compat_stubs.c b/unit-test/stubs/cf_cmd_compat_stubs.c new file mode 100644 index 00000000..ef147523 --- /dev/null +++ b/unit-test/stubs/cf_cmd_compat_stubs.c @@ -0,0 +1,299 @@ +/************************************************************************ + * NASA Docket No. GSC-18,447-1, and identified as “CFS CFDP (CF) + * Application version 3.0.0” + * + * Copyright (c) 2019 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/** + * @file + * + * Auto-Generated stub implementations for functions defined in cf_cmd_compat header + */ + +#include "cf_cmd_compat.h" +#include "utgenstub.h" + +/* + * ---------------------------------------------------- + * Generated stub function for CF_AbandonCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_AbandonCompatCmd(const CF_AbandonCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_AbandonCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_AbandonCompatCmd, const CF_AbandonCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_AbandonCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_AbandonCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_CancelCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_CancelCompatCmd(const CF_CancelCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_CancelCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_CancelCompatCmd, const CF_CancelCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_CancelCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_CancelCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_DisableDequeueCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_DisableDequeueCompatCmd(const CF_DisableDequeueCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_DisableDequeueCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_DisableDequeueCompatCmd, const CF_DisableDequeueCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_DisableDequeueCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_DisableDequeueCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_DisableDirPollingCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_DisableDirPollingCompatCmd(const CF_DisableDirPollingCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_DisableDirPollingCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_DisableDirPollingCompatCmd, const CF_DisableDirPollingCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_DisableDirPollingCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_DisableDirPollingCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_EnableDequeueCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_EnableDequeueCompatCmd(const CF_EnableDequeueCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_EnableDequeueCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_EnableDequeueCompatCmd, const CF_EnableDequeueCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_EnableDequeueCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_EnableDequeueCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_EnableDirPollingCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_EnableDirPollingCompatCmd(const CF_EnableDirPollingCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_EnableDirPollingCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_EnableDirPollingCompatCmd, const CF_EnableDirPollingCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_EnableDirPollingCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_EnableDirPollingCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_FreezeCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_FreezeCompatCmd(const CF_FreezeCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_FreezeCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_FreezeCompatCmd, const CF_FreezeCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_FreezeCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_FreezeCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_GetParamCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_GetParamCompatCmd(const CF_GetParamCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_GetParamCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_GetParamCompatCmd, const CF_GetParamCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_GetParamCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_GetParamCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_PlaybackDirCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_PlaybackDirCompatCmd(const CF_PlaybackDirCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_PlaybackDirCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_PlaybackDirCompatCmd, const CF_PlaybackDirCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_PlaybackDirCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_PlaybackDirCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_PurgeQueueCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_PurgeQueueCompatCmd(const CF_PurgeQueueCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_PurgeQueueCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_PurgeQueueCompatCmd, const CF_PurgeQueueCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_PurgeQueueCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_PurgeQueueCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_ResetCountersCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_ResetCountersCompatCmd(const CF_ResetCountersCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_ResetCountersCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_ResetCountersCompatCmd, const CF_ResetCountersCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_ResetCountersCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ResetCountersCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_ResumeCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_ResumeCompatCmd(const CF_ResumeCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_ResumeCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_ResumeCompatCmd, const CF_ResumeCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_ResumeCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ResumeCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_SetParamCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_SetParamCompatCmd(const CF_SetParamCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_SetParamCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_SetParamCompatCmd, const CF_SetParamCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_SetParamCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_SetParamCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_SuspendCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_SuspendCompatCmd(const CF_SuspendCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_SuspendCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_SuspendCompatCmd, const CF_SuspendCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_SuspendCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_SuspendCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_ThawCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_ThawCompatCmd(const CF_ThawCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_ThawCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_ThawCompatCmd, const CF_ThawCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_ThawCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_ThawCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_TxFileCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_TxFileCompatCmd(const CF_TxFileCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_TxFileCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_TxFileCompatCmd, const CF_TxFileCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_TxFileCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_TxFileCompatCmd, CFE_Status_t); +} + +/* + * ---------------------------------------------------- + * Generated stub function for CF_WriteQueueCompatCmd() + * ---------------------------------------------------- + */ +CFE_Status_t CF_WriteQueueCompatCmd(const CF_WriteQueueCompatCmd_t *msg) +{ + UT_GenStub_SetupReturnBuffer(CF_WriteQueueCompatCmd, CFE_Status_t); + + UT_GenStub_AddParam(CF_WriteQueueCompatCmd, const CF_WriteQueueCompatCmd_t *, msg); + + UT_GenStub_Execute(CF_WriteQueueCompatCmd, Basic, NULL); + + return UT_GenStub_GetReturnValue(CF_WriteQueueCompatCmd, CFE_Status_t); +} From bdee9cc82e9cb057594d99a23753ff3c1c8378ed Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 23 Sep 2026 13:51:31 -0400 Subject: [PATCH 15/18] Part nasa/cFS#1136, Create SECURITY.md --- SECURITY.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8786e2d3 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,9 @@ +# Security Policy + +Please refer to the [cFS Security Policy](https://github.com/nasa/cFS/blob/main/SECURITY.md) for information on: + +- Reporting security vulnerabilities through NASA's Vulnerability Disclosure Program (VDP) +- Security testing practices +- Additional support resources + +All security vulnerability reports should be submitted via the Bugcrowd portal as described in the main cFS security policy. From 0a62283ef6022d6a9c3245a4f15257e0b4c2d995 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Thu, 1 Oct 2026 14:45:28 -0400 Subject: [PATCH 16/18] Fix #521, correction to polldir compat value --- fsw/src/cf_cmd_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/src/cf_cmd_compat.c b/fsw/src/cf_cmd_compat.c index 38ad4498..8e8fcf93 100644 --- a/fsw/src/cf_cmd_compat.c +++ b/fsw/src/cf_cmd_compat.c @@ -33,7 +33,7 @@ #define CF_CMD_COMPAT_COMPOUND_KEY (254) #define CF_CMD_COMPAT_ALL_CHANNELS (255) -#define CF_CMD_COMPAT_ALL_POLLDIRS (CF_ALL_CHANNELS) +#define CF_CMD_COMPAT_ALL_POLLDIRS (CF_CMD_COMPAT_ALL_CHANNELS) /*---------------------------------------------------------------- * From 0945c5af4d7149d6fd32b403a4de16e10e615738 Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 2 Oct 2026 13:09:40 -0400 Subject: [PATCH 17/18] Fix #521, correct for compound key channel Remove compound key check in channel translation (does not apply outside of transactions) --- fsw/src/cf_cmd_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/src/cf_cmd_compat.c b/fsw/src/cf_cmd_compat.c index 8e8fcf93..b156db4d 100644 --- a/fsw/src/cf_cmd_compat.c +++ b/fsw/src/cf_cmd_compat.c @@ -43,7 +43,7 @@ *-----------------------------------------------------------------*/ static CF_ChannelSelect_t CF_Translate_CompatChannel(uint8 input) { - if (input == CF_CMD_COMPAT_COMPOUND_KEY || input == CF_CMD_COMPAT_ALL_CHANNELS) + if (input == CF_CMD_COMPAT_ALL_CHANNELS) { return CF_ALL_CHANNELS; } From 53468589c4c27f0005125db4a99e9421dde4891f Mon Sep 17 00:00:00 2001 From: "LOMBAY-GONZALEZ, JOSE" Date: Tue, 6 Oct 2026 13:28:21 -0400 Subject: [PATCH 18/18] Part #1132, Update README.md for v7.0.2rc1. Added clarification to make about cFS being a demonstration bundle. Added link to the mission ready cFS bundle. Added Known Issues section. Added Getting Help section. Removed About cFS section. --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c8a8f6d..6263ded8 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,19 @@ User's guide information can be generated using Doxygen (from top mission direct cFS Framework (cFE, OSAL, PSP) -An integrated bundle including the cFE, OSAL, and PSP can -be obtained at https://github.com/nasa/cfs +A demonstration bundle of the Core Flight System including the cFE, OSAL, and PSP can be obtained at https://github.com/nasa/cfs + +For information about a mission ready cFS bundle, see: https://github.com/nasa/cFS#cfs-gov-mission-ready-version + +## Known issues + +See all [open issues](https://github.com/nasa/CF/issues) and closed to milestones later than this version. + +## Getting Help + +For best results, submit issues:questions or issues:help wanted requests at . + +Official cFS page: ## About cFS