Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #75, move app global to internal include #78

Merged
merged 1 commit into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions fsw/inc/fm_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
#include <fm_platform_cfg.h>
#include <fm_extern_typedefs.h>

#ifdef FM_INCLUDE_DECOMPRESS
#include <cfs_fs_lib.h>
#endif

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM -- command packet structures */
Expand Down Expand Up @@ -530,70 +526,4 @@ typedef struct
uint32 Mode; /**< \brief File Mode */
} FM_ChildQueueEntry_t;

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM -- application global data structure */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/**
* \brief Application global data structure
*/
typedef struct
{
FM_MonitorTable_t *MonitorTablePtr; /**< \brief File System Table Pointer */
CFE_TBL_Handle_t MonitorTableHandle; /**< \brief File System Table Handle */

CFE_SB_PipeId_t CmdPipe; /**< \brief cFE software bus command pipe */

CFE_ES_TaskId_t ChildTaskID; /**< \brief Child task ID */
osal_id_t ChildSemaphore; /**< \brief Child task wakeup counting semaphore */
osal_id_t ChildQueueCountSem; /**< \brief Child queue counter mutex semaphore */

uint8 ChildCmdCounter; /**< \brief Child task command success counter */
uint8 ChildCmdErrCounter; /**< \brief Child task command error counter */
uint8 ChildCmdWarnCounter; /**< \brief Child task command warning counter */

uint8 ChildWriteIndex; /**< \brief Array index for next write to command args */
uint8 ChildReadIndex; /**< \brief Array index for next read from command args */
uint8 ChildQueueCount; /**< \brief Number of pending commands in queue */

uint8 CommandCounter; /**< \brief Application command success counter */
uint8 CommandErrCounter; /**< \brief Application command error counter */
uint8 Spare8a; /**< \brief Placeholder for unused command warning counter */

uint8 ChildCurrentCC; /**< \brief Command code currently executing */
uint8 ChildPreviousCC; /**< \brief Command code previously executed */
uint8 Spare8b; /**< \brief Structure alignment spare */

uint32 FileStatTime; /**< \brief Modify time from most recent OS_stat */
uint32 FileStatSize; /**< \brief File size from most recent OS_stat */
uint32 FileStatMode; /**< \brief File mode from most recent OS_stat (OS_FILESTAT_MODE) */

FM_DirListFileStats_t DirListFileStats; /**< \brief Get dir list to file statistics structure */

FM_DirListPkt_t DirListPkt; /**< \brief Get dir list to packet telemetry packet */

FM_MonitorReportPkt_t
MonitorReportPkt; /**< \brief Telemetry packet reporting status of items in the monitor table */

FM_FileInfoPkt_t FileInfoPkt; /**< \brief Get file info telemetry packet */

FM_OpenFilesPkt_t OpenFilesPkt; /**< \brief Get open files telemetry packet */

FM_HousekeepingPkt_t HousekeepingPkt; /**< \brief Application housekeeping telemetry packet */

char ChildBuffer[FM_CHILD_FILE_BLOCK_SIZE]; /**< \brief Child task file I/O buffer */

FM_ChildQueueEntry_t ChildQueue[FM_CHILD_QUEUE_DEPTH]; /**< \brief Child task command queue */

#ifdef FM_INCLUDE_DECOMPRESS
FS_LIB_Decompress_State_t DecompressState;

#endif
} FM_GlobalData_t;

/** \brief File Manager global */
extern FM_GlobalData_t FM_GlobalData;

#endif
85 changes: 84 additions & 1 deletion fsw/src/fm_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
#define FM_APP_H

#include "cfe.h"
#include "fm_msg.h"

#ifdef FM_INCLUDE_DECOMPRESS
#include "cfs_fs_lib.h"
#endif

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application global function prototypes */
/* FM -- application global constants */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Expand All @@ -41,6 +46,75 @@
*/
#define FM_SB_TIMEOUT 1000

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM -- application global data structure */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/**
* \brief Application global data structure
*/
typedef struct
{
FM_MonitorTable_t *MonitorTablePtr; /**< \brief File System Table Pointer */
CFE_TBL_Handle_t MonitorTableHandle; /**< \brief File System Table Handle */

CFE_SB_PipeId_t CmdPipe; /**< \brief cFE software bus command pipe */

CFE_ES_TaskId_t ChildTaskID; /**< \brief Child task ID */
osal_id_t ChildSemaphore; /**< \brief Child task wakeup counting semaphore */
osal_id_t ChildQueueCountSem; /**< \brief Child queue counter mutex semaphore */

uint8 ChildCmdCounter; /**< \brief Child task command success counter */
uint8 ChildCmdErrCounter; /**< \brief Child task command error counter */
uint8 ChildCmdWarnCounter; /**< \brief Child task command warning counter */

uint8 ChildWriteIndex; /**< \brief Array index for next write to command args */
uint8 ChildReadIndex; /**< \brief Array index for next read from command args */
uint8 ChildQueueCount; /**< \brief Number of pending commands in queue */

uint8 CommandCounter; /**< \brief Application command success counter */
uint8 CommandErrCounter; /**< \brief Application command error counter */
uint8 Spare8a; /**< \brief Placeholder for unused command warning counter */

uint8 ChildCurrentCC; /**< \brief Command code currently executing */
uint8 ChildPreviousCC; /**< \brief Command code previously executed */
uint8 Spare8b; /**< \brief Structure alignment spare */

uint32 FileStatTime; /**< \brief Modify time from most recent OS_stat */
uint32 FileStatSize; /**< \brief File size from most recent OS_stat */
uint32 FileStatMode; /**< \brief File mode from most recent OS_stat (OS_FILESTAT_MODE) */

FM_DirListFileStats_t DirListFileStats; /**< \brief Get dir list to file statistics structure */

FM_DirListPkt_t DirListPkt; /**< \brief Get dir list to packet telemetry packet */

FM_MonitorReportPkt_t
MonitorReportPkt; /**< \brief Telemetry packet reporting status of items in the monitor table */

FM_FileInfoPkt_t FileInfoPkt; /**< \brief Get file info telemetry packet */

FM_OpenFilesPkt_t OpenFilesPkt; /**< \brief Get open files telemetry packet */

FM_HousekeepingPkt_t HousekeepingPkt; /**< \brief Application housekeeping telemetry packet */

char ChildBuffer[FM_CHILD_FILE_BLOCK_SIZE]; /**< \brief Child task file I/O buffer */

FM_ChildQueueEntry_t ChildQueue[FM_CHILD_QUEUE_DEPTH]; /**< \brief Child task command queue */

#ifdef FM_INCLUDE_DECOMPRESS
FS_LIB_Decompress_State_t DecompressState;

#endif
} FM_GlobalData_t;

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application global function prototypes */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/**
* \brief Application entry point and main process loop
*
Expand Down Expand Up @@ -129,4 +203,13 @@ void FM_ProcessCmd(const CFE_SB_Buffer_t *BufPtr);
*/
void FM_ReportHK(const CFE_MSG_CommandHeader_t *Msg);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application global data structure instance */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/** \brief File Manager global */
extern FM_GlobalData_t FM_GlobalData;

#endif
1 change: 1 addition & 0 deletions fsw/src/fm_cmd_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/

#include "cfe.h"
#include "fm_app.h"
#include "fm_msg.h"
#include "fm_cmd_utils.h"
#include "fm_child.h"
Expand Down
2 changes: 1 addition & 1 deletion fsw/src/fm_tbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

#include "fm_platform_cfg.h"
#include "fm_msg.h"
#include "fm_app.h"
#include "fm_tbl.h"
#include "fm_events.h"

Expand Down
1 change: 1 addition & 0 deletions unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

add_cfe_coverage_stubs("fm_internal"
utilities/fm_test_utils.c
stubs/fm_global_stubs.c
stubs/fm_cmds_stubs.c
stubs/fm_cmd_utils_stubs.c
stubs/fm_cmd_utils_handlers.c
Expand Down
2 changes: 1 addition & 1 deletion unit-test/fm_cmd_utils_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "cfe.h"
#include "fm_cmd_utils.h"
#include "fm_msg.h"
#include "fm_app.h"
#include "fm_child.h"
#include "fm_perfids.h"
#include "fm_events.h"
Expand Down
2 changes: 1 addition & 1 deletion unit-test/fm_tbl_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include "cfe.h"
#include "fm_platform_cfg.h"
#include "fm_msg.h"
#include "fm_app.h"
#include "fm_tbl.h"
#include "fm_events.h"

Expand Down
118 changes: 45 additions & 73 deletions unit-test/stubs/fm_app_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,98 +19,70 @@

/**
* @file
* The File Manager (FM) Application provides onboard file system
* management services by processing commands for copying and moving
* files, decompressing files, concatenating files, creating directories,
* deleting files and directories, and providing file and directory status.
* When the File Manager application receives a housekeeping request
* (scheduled within the scheduler application), FM reports it's housekeeping
* status values via telemetry messaging.
*
* Auto-Generated stub implementations for functions defined in fm_app header
*/

#include "cfe.h"
#include "fm_msg.h"
#include "fm_msgdefs.h"
#include "fm_msgids.h"
#include "fm_app.h"
#include "fm_tbl.h"
#include "fm_child.h"
#include "fm_cmds.h"
#include "fm_cmd_utils.h"
#include "fm_events.h"
#include "fm_perfids.h"
#include "fm_platform_cfg.h"
#include "fm_version.h"
#include "fm_verify.h"
#include "fm_test_utils.h"

#include <string.h>

/* UT includes */
#include "uttest.h"
#include "utassert.h"
#include "utstubs.h"
#include "utgenstub.h"

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application global data */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* ----------------------------------------------------
* Generated stub function for FM_AppInit()
* ----------------------------------------------------
*/
int32 FM_AppInit(void)
{
UT_GenStub_SetupReturnBuffer(FM_AppInit, int32);

FM_GlobalData_t FM_GlobalData;
UT_GenStub_Execute(FM_AppInit, Basic, NULL);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application -- entry point and main loop processor */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
return UT_GenStub_GetReturnValue(FM_AppInit, int32);
}

/*
* ----------------------------------------------------
* Generated stub function for FM_AppMain()
* ----------------------------------------------------
*/
void FM_AppMain(void)
{
UT_DEFAULT_IMPL(FM_AppMain);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application -- startup initialization processor */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
UT_GenStub_Execute(FM_AppMain, Basic, NULL);
}

int32 FM_AppInit(void)
/*
* ----------------------------------------------------
* Generated stub function for FM_ProcessCmd()
* ----------------------------------------------------
*/
void FM_ProcessCmd(const CFE_SB_Buffer_t *BufPtr)
{
return UT_DEFAULT_IMPL(FM_AppInit);
}
UT_GenStub_AddParam(FM_ProcessCmd, const CFE_SB_Buffer_t *, BufPtr);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application -- input packet processor */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
UT_GenStub_Execute(FM_ProcessCmd, Basic, NULL);
}

/*
* ----------------------------------------------------
* Generated stub function for FM_ProcessPkt()
* ----------------------------------------------------
*/
void FM_ProcessPkt(const CFE_SB_Buffer_t *MessagePtr)
{
UT_DEFAULT_IMPL(FM_ProcessPkt);
}
UT_GenStub_AddParam(FM_ProcessPkt, const CFE_SB_Buffer_t *, MessagePtr);

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application -- command packet processor */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

void FM_ProcessCmd(const CFE_SB_Buffer_t *MessagePtr)
{
UT_DEFAULT_IMPL(FM_ProcessCmd);
UT_Stub_CopyFromLocal(UT_KEY(FM_ProcessCmd), &MessagePtr, sizeof(MessagePtr));
UT_GenStub_Execute(FM_ProcessPkt, Basic, NULL);
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* FM application -- housekeeping request packet processor */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
* ----------------------------------------------------
* Generated stub function for FM_ReportHK()
* ----------------------------------------------------
*/
void FM_ReportHK(const CFE_MSG_CommandHeader_t *Msg)
{
UT_DEFAULT_IMPL(FM_ReportHK);
UT_GenStub_AddParam(FM_ReportHK, const CFE_MSG_CommandHeader_t *, Msg);

UT_GenStub_Execute(FM_ReportHK, Basic, NULL);
}
Loading