From 8b0b209626737d7ccc18e80ef4e691a0e78293dc Mon Sep 17 00:00:00 2001 From: Jacob Hageman Date: Wed, 15 Nov 2023 16:32:06 +0000 Subject: [PATCH] Fix #146, Support scheduled uplink check --- config/default_ci_lab_msgids.h | 5 +++-- fsw/inc/ci_lab_eventids.h | 1 + fsw/src/ci_lab_app.c | 12 ++++++++++-- fsw/src/ci_lab_app.h | 1 + fsw/src/ci_lab_dispatch.c | 5 +++++ 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config/default_ci_lab_msgids.h b/config/default_ci_lab_msgids.h index feefb97..df5cf31 100644 --- a/config/default_ci_lab_msgids.h +++ b/config/default_ci_lab_msgids.h @@ -23,8 +23,9 @@ #ifndef CI_LAB_MSGIDS_H #define CI_LAB_MSGIDS_H -#define CI_LAB_CMD_MID 0x1884 -#define CI_LAB_SEND_HK_MID 0x1885 +#define CI_LAB_CMD_MID 0x1884 +#define CI_LAB_SEND_HK_MID 0x1885 +#define CI_LAB_READ_UPLINK_MID 0x1886 #define CI_LAB_HK_TLM_MID 0x0884 diff --git a/fsw/inc/ci_lab_eventids.h b/fsw/inc/ci_lab_eventids.h index 74b2842..f547063 100644 --- a/fsw/inc/ci_lab_eventids.h +++ b/fsw/inc/ci_lab_eventids.h @@ -37,6 +37,7 @@ #define CI_LAB_CR_PIPE_ERR_EID 11 #define CI_LAB_SB_SUBSCRIBE_CMD_ERR_EID 12 #define CI_LAB_SB_SUBSCRIBE_HK_ERR_EID 13 +#define CI_LAB_SB_SUBSCRIBE_UL_ERR_EID 14 #define CI_LAB_CMD_LEN_ERR_EID 16 #endif diff --git a/fsw/src/ci_lab_app.c b/fsw/src/ci_lab_app.c index 3a5cdcd..c300d7a 100644 --- a/fsw/src/ci_lab_app.c +++ b/fsw/src/ci_lab_app.c @@ -74,8 +74,8 @@ void CI_LAB_AppMain(void) CI_LAB_TaskPipe(SBBufPtr); } - /* Regardless of packet vs timeout, always process uplink queue */ - if (CI_LAB_Global.SocketConnected) + /* Regardless of packet vs timeout, always process uplink queue if not scheduled */ + if (CI_LAB_Global.SocketConnected && !CI_LAB_Global.Scheduled) { CI_LAB_ReadUpLink(); } @@ -129,6 +129,13 @@ void CI_LAB_TaskInit(void) CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_HK_ERR_EID, CFE_EVS_EventType_ERROR, "Error subscribing to SB HK Request, RC = 0x%08X", (unsigned int)status); } + + status = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(CI_LAB_READ_UPLINK_MID), CI_LAB_Global.CommandPipe); + if (status != CFE_SUCCESS) + { + CFE_EVS_SendEvent(CI_LAB_SB_SUBSCRIBE_UL_ERR_EID, CFE_EVS_EventType_ERROR, + "Error subscribing to SB Read Uplink Request, RC = 0x%08X", (unsigned int)status); + } } else { @@ -221,6 +228,7 @@ void CI_LAB_ReadUpLink(void) OsStatus = OS_SocketRecvFrom(CI_LAB_Global.SocketID, CI_LAB_Global.NetBufPtr, CI_LAB_Global.NetBufSize, &CI_LAB_Global.SocketAddress, OS_CHECK); + if (OsStatus > 0) { CFE_ES_PerfLogEntry(CI_LAB_SOCKET_RCV_PERF_ID); diff --git a/fsw/src/ci_lab_app.h b/fsw/src/ci_lab_app.h index cb1510e..4706359 100644 --- a/fsw/src/ci_lab_app.h +++ b/fsw/src/ci_lab_app.h @@ -53,6 +53,7 @@ typedef struct { bool SocketConnected; + bool Scheduled; CFE_SB_PipeId_t CommandPipe; osal_id_t SocketID; OS_SockAddr_t SocketAddress; diff --git a/fsw/src/ci_lab_dispatch.c b/fsw/src/ci_lab_dispatch.c index 038002d..174b00c 100644 --- a/fsw/src/ci_lab_dispatch.c +++ b/fsw/src/ci_lab_dispatch.c @@ -122,6 +122,11 @@ void CI_LAB_TaskPipe(const CFE_SB_Buffer_t *SBBufPtr) CI_LAB_SendHkCmd((const CI_LAB_SendHkCmd_t *)SBBufPtr); break; + case CI_LAB_READ_UPLINK_MID: + CI_LAB_Global.Scheduled = true; + CI_LAB_ReadUpLink(); + break; + default: CI_LAB_Global.HkTlm.Payload.CommandErrorCounter++; CFE_EVS_SendEvent(CI_LAB_MID_ERR_EID, CFE_EVS_EventType_ERROR, "CI: invalid command packet,MID = 0x%x",