Skip to content

Commit 06a4587

Browse files
committed
WIP nasa#62 - alignment updates started
1 parent f7d41f6 commit 06a4587

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

fsw/src/ci_lab_app.c

+32-24
Original file line numberDiff line numberDiff line change
@@ -43,26 +43,25 @@
4343
/*
4444
* Declaring the CI_LAB_IngestBuffer as a union
4545
* ensures it is aligned appropriately to
46-
* store a CFE_MSG_Message_t type.
46+
* store a CFE_SB_Msg_t type.
4747
*/
4848
typedef union
4949
{
50-
CFE_MSG_Message_t MsgHdr;
51-
uint8 bytes[CI_LAB_MAX_INGEST];
52-
uint16 hwords[2];
50+
CFE_SB_Msg_t SBMsg;
51+
uint8 bytes[CI_LAB_MAX_INGEST];
52+
uint16 hwords[2];
5353
} CI_LAB_IngestBuffer_t;
5454

5555
typedef union
5656
{
57-
CFE_MSG_Message_t MsgHdr;
58-
CI_LAB_HkTlm_t HkTlm;
57+
CFE_SB_Msg_t SBMsg;
58+
CI_LAB_HkTlm_t HkTlm;
5959
} CI_LAB_HkTlm_Buffer_t;
6060

6161
typedef struct
6262
{
6363
bool SocketConnected;
6464
CFE_SB_PipeId_t CommandPipe;
65-
CFE_MSG_Message_t *MsgPtr;
6665
osal_id_t SocketID;
6766
OS_SockAddr_t SocketAddress;
6867

@@ -87,7 +86,9 @@ static CFE_EVS_BinFilter_t CI_LAB_EventFilters[] =
8786
*/
8887
int32 CI_LAB_Noop(const CI_LAB_Noop_t *data);
8988
int32 CI_LAB_ResetCounters(const CI_LAB_ResetCounters_t *data);
90-
int32 CI_LAB_ReportHousekeeping(const CFE_SB_CmdHdr_t *data);
89+
90+
/* Housekeeping message handler */
91+
int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data);
9192

9293
/** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
9394
/* CI_Lab_AppMain() -- Application entry point and main process loop */
@@ -101,8 +102,9 @@ int32 CI_LAB_ReportHousekeeping(const CFE_SB_CmdHdr_t *data);
101102
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
102103
void CI_Lab_AppMain(void)
103104
{
104-
int32 status;
105-
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
105+
int32 status;
106+
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
107+
CFE_SB_Msg_t *SBMsgPtr;
106108

107109
CFE_ES_PerfLogEntry(CI_LAB_MAIN_TASK_PERF_ID);
108110

@@ -116,13 +118,13 @@ void CI_Lab_AppMain(void)
116118
CFE_ES_PerfLogExit(CI_LAB_MAIN_TASK_PERF_ID);
117119

118120
/* Pend on receipt of command packet -- timeout set to 500 millisecs */
119-
status = CFE_SB_RcvMsg(&CI_LAB_Global.MsgPtr, CI_LAB_Global.CommandPipe, 500);
121+
status = CFE_SB_RcvMsg(&SBMsgPtr, CI_LAB_Global.CommandPipe, 500);
120122

121123
CFE_ES_PerfLogEntry(CI_LAB_MAIN_TASK_PERF_ID);
122124

123125
if (status == CFE_SUCCESS)
124126
{
125-
CI_LAB_ProcessCommandPacket();
127+
CI_LAB_ProcessCommandPacket(SBMsgPtr);
126128
}
127129

128130
/* Regardless of packet vs timeout, always process uplink queue */
@@ -201,7 +203,7 @@ void CI_LAB_TaskInit(void)
201203
*/
202204
OS_TaskInstallDeleteHandler(&CI_LAB_delete_callback);
203205

204-
CFE_MSG_Init(&CI_LAB_Global.HkBuffer.HkTlm.TlmHeader.BaseMsg, CI_LAB_HK_TLM_MID, CI_LAB_HK_TLM_LNGTH);
206+
CFE_MSG_Init(&CI_LAB_Global.HkBuffer.SBMsg.Msg, CI_LAB_HK_TLM_MID, CI_LAB_HK_TLM_LNGTH);
205207

206208
CFE_EVS_SendEvent(CI_LAB_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s",
207209
CI_LAB_VERSION_STRING);
@@ -220,20 +222,20 @@ void CI_LAB_TaskInit(void)
220222
/* 3. Request for housekeeping telemetry packet (from HS task) */
221223
/* */
222224
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
223-
void CI_LAB_ProcessCommandPacket(void)
225+
void CI_LAB_ProcessCommandPacket(CFE_SB_Msg_t *SBMsgPtr)
224226
{
225227
CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID;
226228

227-
CFE_MSG_GetMsgId(CI_LAB_Global.MsgPtr, &MsgId);
229+
CFE_MSG_GetMsgId(&SBMsgPtr->Msg, &MsgId);
228230

229231
switch (CFE_SB_MsgIdToValue(MsgId))
230232
{
231233
case CI_LAB_CMD_MID:
232-
CI_LAB_ProcessGroundCommand();
234+
CI_LAB_ProcessGroundCommand(SBMsgPtr);
233235
break;
234236

235237
case CI_LAB_SEND_HK_MID:
236-
CI_LAB_ReportHousekeeping((const CFE_SB_CmdHdr_t *)CI_LAB_Global.MsgPtr);
238+
CI_LAB_ReportHousekeeping((const CFE_MSG_CommandHeader_t *)SBMsgPtr);
237239
break;
238240

239241
default:
@@ -253,21 +255,27 @@ void CI_LAB_ProcessCommandPacket(void)
253255
/* */
254256
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
255257

256-
void CI_LAB_ProcessGroundCommand(void)
258+
void CI_LAB_ProcessGroundCommand(CFE_SB_Msg_t *SBMsgPtr)
257259
{
258260
CFE_MSG_FcnCode_t CommandCode = 0;
259261

260-
CFE_MSG_GetFcnCode(CI_LAB_Global.MsgPtr, &CommandCode);
262+
CFE_MSG_GetFcnCode(&SBMsgPtr->Msg, &CommandCode);
261263

262264
/* Process "known" CI task ground commands */
263265
switch (CommandCode)
264266
{
265267
case CI_LAB_NOOP_CC:
266-
CI_LAB_Noop((const CI_LAB_Noop_t *)CI_LAB_Global.MsgPtr);
268+
if (CI_LAB_VerifyCmdLength(&SBMsgPtr->Msg, sizeof(CI_LAB_Noop_t)))
269+
{
270+
CI_LAB_Noop((const CI_LAB_Noop_t *)SBMsgPtr);
271+
}
267272
break;
268273

269274
case CI_LAB_RESET_COUNTERS_CC:
270-
CI_LAB_ResetCounters((const CI_LAB_ResetCounters_t *)CI_LAB_Global.MsgPtr);
275+
if (CI_LAB_VerifyCmdLength(&SBMsgPtr->Msg, sizeof(CI_LAB_ResetCounters_t)))
276+
{
277+
CI_LAB_ResetCounters((const CI_LAB_ResetCounters_t *)SBMsgPtr);
278+
}
271279
break;
272280

273281
/* default case already found during FC vs length test */
@@ -319,11 +327,11 @@ int32 CI_LAB_ResetCounters(const CI_LAB_ResetCounters_t *data)
319327
/* telemetry, packetize it and send it to the housekeeping task via */
320328
/* the software bus */
321329
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
322-
int32 CI_LAB_ReportHousekeeping(const CFE_SB_CmdHdr_t *data)
330+
int32 CI_LAB_ReportHousekeeping(const CFE_MSG_CommandHeader_t *data)
323331
{
324332
CI_LAB_Global.HkBuffer.HkTlm.Payload.SocketConnected = CI_LAB_Global.SocketConnected;
325-
CFE_SB_TimeStampMsg(&CI_LAB_Global.HkBuffer.MsgHdr);
326-
CFE_SB_SendMsg(&CI_LAB_Global.HkBuffer.MsgHdr);
333+
CFE_SB_TimeStampMsg(&CI_LAB_Global.HkBuffer.HkTlm.TlmHeader);
334+
CFE_SB_SendMsg(&CI_LAB_Global.HkBuffer.SBMsg);
327335
return CFE_SUCCESS;
328336

329337
} /* End of CI_LAB_ReportHousekeeping() */

fsw/src/ci_lab_app.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@
6363
*/
6464
void CI_Lab_AppMain(void);
6565
void CI_LAB_TaskInit(void);
66-
void CI_LAB_ProcessCommandPacket(void);
67-
void CI_LAB_ProcessGroundCommand(void);
66+
void CI_LAB_ProcessCommandPacket(CFE_SB_Msg_t *SBMsgPtr);
67+
void CI_LAB_ProcessGroundCommand(CFE_SB_Msg_T *SBMsgPtr);
6868
void CI_LAB_ResetCounters_Internal(void);
6969
void CI_LAB_ReadUpLink(void);
7070

fsw/src/ci_lab_msg.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
*/
4242
typedef struct
4343
{
44-
uint8 CmdHeader[CFE_SB_CMD_HDR_SIZE];
44+
CFE_MSG_CommandHeader_t CmdHeader;
4545

4646
} CI_LAB_NoArgsCmd_t;
4747

@@ -74,8 +74,8 @@ typedef struct
7474

7575
typedef struct
7676
{
77-
CFE_SB_TlmHdr_t TlmHeader;
78-
CI_LAB_HkTlm_Payload_t Payload;
77+
CFE_MSG_TelemetryHeader_t TlmHeader;
78+
CI_LAB_HkTlm_Payload_t Payload;
7979
} OS_PACK CI_LAB_HkTlm_t;
8080

8181
#define CI_LAB_HK_TLM_LNGTH sizeof(CI_LAB_HkTlm_t)

0 commit comments

Comments
 (0)