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 #114, clean up dispatch logic #115

Merged
merged 1 commit into from
Jan 4, 2024
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
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@ project(CFS_HS C)
set(APP_SRC_FILES
fsw/src/hs_monitors.c
fsw/src/hs_utils.c
fsw/src/hs_dispatch.c
fsw/src/hs_sysmon.c
fsw/src/hs_app.c
fsw/src/hs_cmds.c
)

if (CFE_EDS_ENABLED_BUILD)
list(APPEND APP_SRC_FILES
fsw/src/hs_eds_dispatch.c
)
else()
list(APPEND APP_SRC_FILES
fsw/src/hs_dispatch.c
)
endif()

# Create the app module
add_cfe_app(hs ${APP_SRC_FILES})

Expand Down
13 changes: 3 additions & 10 deletions arch_build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@ set(HS_PLATFORM_CONFIG_FILE_LIST
hs_platform_cfg.h
)

if (CFE_EDS_ENABLED_BUILD)

# In an EDS-based build, msgids come generated from the EDS tool
set(HS_CFGFILE_SRC_hs_msgids "${CMAKE_CURRENT_LIST_DIR}/config/hs_eds_msg_topicids.h")

endif(CFE_EDS_ENABLED_BUILD)

# Create wrappers around the all the config header files
# This makes them individually overridable by the missions, without modifying
# the distribution default copies
foreach(HS_CFGFILE ${HS_PLATFORM_CONFIG_FILE_LIST})
get_filename_component(CFGKEY "${HS_CFGFILE}" NAME_WE)
if (DEFINED HS_CFGFILE_SRC_${CFGKEY})
set(DEFAULT_SOURCE "${HS_CFGFILE_SRC_${CFGKEY}}")
set(DEFAULT_SOURCE GENERATED_FILE "${HS_CFGFILE_SRC_${CFGKEY}}")
else()
set(DEFAULT_SOURCE "${CMAKE_CURRENT_LIST_DIR}/config/default_${HS_CFGFILE}")
set(DEFAULT_SOURCE FALLBACK_FILE "${CMAKE_CURRENT_LIST_DIR}/config/default_${HS_CFGFILE}")
endif()
generate_config_includefile(
FILE_NAME "${HS_CFGFILE}"
FALLBACK_FILE ${DEFAULT_SOURCE}
${DEFAULT_SOURCE}
)
endforeach()
17 changes: 0 additions & 17 deletions config/default_hs_internal_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,6 @@
* \{
*/

/**
* \brief Application Name
*
* \par Description:
* This definition must match the name used at startup by the cFE
* Executive Services when creating the HS application. Note that
* application names are also an argument to certain cFE commands.
* For example, the application name is needed to access tables
* via cFE Table Services commands.
*
* \par Limits:
* HS requires that this name be defined, but otherwise places
* no limits on the definition. Refer to CFE Executive Services
* for specific information on limits related to application names.
*/
#define HS_APP_NAME "HS"

/**
* \brief Watchdog Timeout Value
*
Expand Down
17 changes: 17 additions & 0 deletions config/default_hs_mission_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,21 @@

#include "hs_interface_cfg.h"

/**
* \brief Application Name
*
* \par Description:
* This definition must match the name used at startup by the cFE
* Executive Services when creating the HS application. Note that
* application names are also an argument to certain cFE commands.
* For example, the application name is needed to access tables
* via cFE Table Services commands.
*
* \par Limits:
* HS requires that this name be defined, but otherwise places
* no limits on the definition. Refer to CFE Executive Services
* for specific information on limits related to application names.
*/
#define HS_APP_NAME "HS"

#endif
17 changes: 13 additions & 4 deletions config/default_hs_msgids.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,22 @@
#ifndef HS_MSGIDS_H
#define HS_MSGIDS_H

#include "cfe_core_api_base_msgids.h"
#include "hs_topicids.h"

/**
* \defgroup cfshscmdmid CFS Health and Safety Command Message IDs
* \{
*/

#define HS_CMD_MID 0x18AE /**< \brief Msg ID for cmds to HS */
#define HS_SEND_HK_MID 0x18AF /**< \brief Msg ID to request HS housekeeping */
#define HS_WAKEUP_MID 0x18B0 /**< \brief Msg ID to wake up HS */
/** \brief Msg ID for cmds to HS */
#define HS_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_HS_CMD_TOPICID)

/** \brief Msg ID to request HS housekeeping */
#define HS_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_HS_SEND_HK_TOPICID)

/** \brief Msg ID to wake up HS */
#define HS_WAKEUP_MID CFE_PLATFORM_CMD_TOPICID_TO_MIDV(CFE_MISSION_HS_WAKEUP_TOPICID)

/**\}*/

Expand All @@ -40,7 +48,8 @@
* \{
*/

#define HS_HK_TLM_MID 0x08AD /**< \brief HS Housekeeping Telemetry */
/** \brief HS Housekeeping Telemetry */
#define HS_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MIDV(CFE_MISSION_HS_HK_TLM_TOPICID)

/**\}*/

Expand Down
37 changes: 7 additions & 30 deletions config/hs_eds_msg_topicids.h → config/default_hs_topicids.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,14 @@

/**
* @file
* CFS Health and Safety (HS) Application Message IDs
* CFS Health and Safety (HS) Application Topic IDs
*/
#ifndef HS_MSGIDS_H
#define HS_MSGIDS_H
#ifndef HS_TOPICIDS_H
#define HS_TOPICIDS_H

#include "cfe_msgids.h"

/**
* \defgroup cfshscmdmid CFS Health and Safety Command Message IDs
* \{
*/

/** \brief Msg ID for cmds to HS */
#define HS_CMD_MID CFE_PLATFORM_CMD_TOPICID_TO_MID(CFE_MISSION_HS_CMD_TOPICID)

/** \brief Msg ID to request HS housekeeping */
#define HS_SEND_HK_MID CFE_PLATFORM_CMD_TOPICID_TO_MID(CFE_MISSION_HS_SEND_HK_TOPICID)

/** \brief Msg ID to wake up HS */
#define HS_WAKEUP_MID CFE_PLATFORM_CMD_TOPICID_TO_MID(CFE_MISSION_HS_WAKEUP_TOPICID)

/**\}*/

/**
* \defgroup cfshstlmmid CFS Health and Safety Telemetry Message IDs
* \{
*/

/** \brief HS Housekeeping Telemetry */
#define HS_HK_TLM_MID CFE_PLATFORM_TLM_TOPICID_TO_MID(CFE_MISSION_HS_HK_TLM_TOPICID)

/**\}*/
#define CFE_MISSION_HS_CMD_TOPICID 0xAE /**< \brief Msg ID for cmds to HS */
#define CFE_MISSION_HS_SEND_HK_TOPICID 0xAF /**< \brief Msg ID to request HS housekeeping */
#define CFE_MISSION_HS_WAKEUP_TOPICID 0xB0 /**< \brief Msg ID to wake up HS */
#define CFE_MISSION_HS_HK_TLM_TOPICID 0xAD /**< \brief HS Housekeeping Telemetry */

#endif
49 changes: 36 additions & 13 deletions fsw/src/hs_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
/* Housekeeping request */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_SendHkCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_SendHkCmd(const HS_SendHkCmd_t *BufPtr)

Check notice

Code scanning / CodeQL

Function too long Note

HS_SendHkCmd has too many lines (141, while 60 are allowed).

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_ES_AppId_t AppId = CFE_ES_APPID_UNDEFINED;

Expand Down Expand Up @@ -184,31 +184,36 @@
*/
CFE_SB_TimeStampMsg(CFE_MSG_PTR(HS_AppData.HkPacket.TelemetryHeader));
CFE_SB_TransmitMsg(CFE_MSG_PTR(HS_AppData.HkPacket.TelemetryHeader), true);

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Noop command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_NoopCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_NoopCmd(const HS_NoopCmd_t *BufPtr)
{
HS_AppData.CmdCount++;

CFE_EVS_SendEvent(HS_NOOP_INF_EID, CFE_EVS_EventType_INFORMATION, "No-op command: Version %d.%d.%d.%d",
HS_MAJOR_VERSION, HS_MINOR_VERSION, HS_REVISION, HS_MISSION_REV);

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Reset counters command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_ResetCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_ResetCmd(const HS_ResetCmd_t *BufPtr)
{
HS_ResetCounters();

CFE_EVS_SendEvent(HS_RESET_DBG_EID, CFE_EVS_EventType_DEBUG, "Reset counters command");
return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand All @@ -229,32 +234,34 @@
/* Enable applications monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_EnableAppMonCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_EnableAppMonCmd(const HS_EnableAppMonCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppMonStatusRefresh();
HS_AppData.CurrentAppMonState = HS_STATE_ENABLED;
CFE_EVS_SendEvent(HS_ENABLE_APPMON_DBG_EID, CFE_EVS_EventType_DEBUG, "Application Monitoring Enabled");
return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable applications monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_DisableAppMonCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_DisableAppMonCmd(const HS_DisableAppMonCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppData.CurrentAppMonState = HS_STATE_DISABLED;
CFE_EVS_SendEvent(HS_DISABLE_APPMON_DBG_EID, CFE_EVS_EventType_DEBUG, "Application Monitoring Disabled");
return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Enable events monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_EnableEventMonCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_EnableEventMonCmd(const HS_EnableEventMonCmd_t *BufPtr)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_Status_t Status = CFE_SUCCESS;

Expand Down Expand Up @@ -295,14 +302,16 @@
{
HS_AppData.CmdErrCount++;
}

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable event monitor command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_DisableEventMonCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_DisableEventMonCmd(const HS_DisableEventMonCmd_t *BufPtr)

Check notice

Code scanning / CodeQL

Long function without assertion Note

All functions of more than 10 lines should have at least one assertion.
{
CFE_Status_t Status = CFE_SUCCESS;

Expand Down Expand Up @@ -342,75 +351,87 @@
{
HS_AppData.CmdErrCount++;
}

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Enable aliveness indicator command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_EnableAlivenessCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_EnableAlivenessCmd(const HS_EnableAlivenessCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppData.CurrentAlivenessState = HS_STATE_ENABLED;
CFE_EVS_SendEvent(HS_ENABLE_ALIVENESS_DBG_EID, CFE_EVS_EventType_DEBUG, "Aliveness Indicator Enabled");

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable aliveness indicator command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_DisableAlivenessCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_DisableAlivenessCmd(const HS_DisableAlivenessCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppData.CurrentAlivenessState = HS_STATE_DISABLED;
CFE_EVS_SendEvent(HS_DISABLE_ALIVENESS_DBG_EID, CFE_EVS_EventType_DEBUG, "Aliveness Indicator Disabled");

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Enable cpu hogging indicator command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_EnableCpuHogCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_EnableCpuHogCmd(const HS_EnableCpuHogCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppData.CurrentCPUHogState = HS_STATE_ENABLED;
CFE_EVS_SendEvent(HS_ENABLE_CPUHOG_DBG_EID, CFE_EVS_EventType_DEBUG, "CPU Hogging Indicator Enabled");

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Disable cpu hogging indicator command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_DisableCpuHogCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_DisableCpuHogCmd(const HS_DisableCpuHogCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_AppData.CurrentCPUHogState = HS_STATE_DISABLED;
CFE_EVS_SendEvent(HS_DISABLE_CPUHOG_DBG_EID, CFE_EVS_EventType_DEBUG, "CPU Hogging Indicator Disabled");

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Reset processor resets performed count command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_ResetResetsPerformedCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_ResetResetsPerformedCmd(const HS_ResetResetsPerformedCmd_t *BufPtr)
{
HS_AppData.CmdCount++;
HS_SetCDSData(0, HS_AppData.CDSData.MaxResets);
CFE_EVS_SendEvent(HS_RESET_RESETS_DBG_EID, CFE_EVS_EventType_DEBUG,
"Processor Resets Performed by HS Counter has been Reset");

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* */
/* Set max processor resets command */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void HS_SetMaxResetsCmd(const CFE_SB_Buffer_t *BufPtr)
CFE_Status_t HS_SetMaxResetsCmd(const HS_SetMaxResetsCmd_t *BufPtr)
{
const HS_SetMaxResets_Payload_t *CmdPtr;

Expand All @@ -421,6 +442,8 @@

CFE_EVS_SendEvent(HS_SET_MAX_RESETS_DBG_EID, CFE_EVS_EventType_DEBUG,
"Max Resets Performable by HS has been set to %d", HS_AppData.CDSData.MaxResets);

return CFE_SUCCESS;
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Expand Down
Loading