Skip to content

Commit

Permalink
Merge pull request #60 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
Integration Candidate 2020-11-10
  • Loading branch information
astrogeco authored Nov 16, 2020
2 parents 179a680 + a401a3c commit aa805af
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ ci_lab is a simple command uplink application that accepts CCSDS telecommand pac

## Version History

### Development Build: 2.4.0-rc1+dev8

- Replaces deprecated SB API's with MSG
- No behavior impact, removes undesirable pattern use of `OS_PACK`
- See <https://github.com/nasa/ci_lab/pull/60>

### Development Build: 2.4.0-rc1+dev2

Expand Down
51 changes: 28 additions & 23 deletions fsw/src/ci_lab_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@
/*
* Declaring the CI_LAB_IngestBuffer as a union
* ensures it is aligned appropriately to
* store a CFE_SB_Msg_t type.
* store a CFE_MSG_Message_t type.
*/
typedef union
{
CFE_SB_Msg_t MsgHdr;
uint8 bytes[CI_LAB_MAX_INGEST];
uint16 hwords[2];
CFE_MSG_Message_t MsgHdr;
uint8 bytes[CI_LAB_MAX_INGEST];
uint16 hwords[2];
} CI_LAB_IngestBuffer_t;

typedef union
{
CFE_SB_Msg_t MsgHdr;
CI_LAB_HkTlm_t HkTlm;
CFE_MSG_Message_t MsgHdr;
CI_LAB_HkTlm_t HkTlm;
} CI_LAB_HkTlm_Buffer_t;

typedef struct
{
bool SocketConnected;
CFE_SB_PipeId_t CommandPipe;
CFE_SB_MsgPtr_t MsgPtr;
osal_id_t SocketID;
OS_SockAddr_t SocketAddress;
bool SocketConnected;
CFE_SB_PipeId_t CommandPipe;
CFE_MSG_Message_t *MsgPtr;
osal_id_t SocketID;
OS_SockAddr_t SocketAddress;

CI_LAB_HkTlm_Buffer_t HkBuffer;
CI_LAB_IngestBuffer_t IngestBuffer;
Expand Down Expand Up @@ -201,7 +201,7 @@ void CI_LAB_TaskInit(void)
*/
OS_TaskInstallDeleteHandler(&CI_LAB_delete_callback);

CFE_SB_InitMsg(&CI_LAB_Global.HkBuffer.HkTlm, CI_LAB_HK_TLM_MID, CI_LAB_HK_TLM_LNGTH, true);
CFE_MSG_Init(&CI_LAB_Global.HkBuffer.HkTlm.TlmHeader.BaseMsg, CI_LAB_HK_TLM_MID, CI_LAB_HK_TLM_LNGTH);

CFE_EVS_SendEvent(CI_LAB_STARTUP_INF_EID, CFE_EVS_EventType_INFORMATION, "CI Lab Initialized.%s",
CI_LAB_VERSION_STRING);
Expand All @@ -222,8 +222,9 @@ void CI_LAB_TaskInit(void)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void CI_LAB_ProcessCommandPacket(void)
{
CFE_SB_MsgId_t MsgId;
MsgId = CFE_SB_GetMsgId(CI_LAB_Global.MsgPtr);
CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID;

CFE_MSG_GetMsgId(CI_LAB_Global.MsgPtr, &MsgId);

switch (CFE_SB_MsgIdToValue(MsgId))
{
Expand Down Expand Up @@ -254,9 +255,9 @@ void CI_LAB_ProcessCommandPacket(void)

void CI_LAB_ProcessGroundCommand(void)
{
uint16 CommandCode;
CFE_MSG_FcnCode_t CommandCode = 0;

CommandCode = CFE_SB_GetCmdCode(CI_LAB_Global.MsgPtr);
CFE_MSG_GetFcnCode(CI_LAB_Global.MsgPtr, &CommandCode);

/* Process "known" CI task ground commands */
switch (CommandCode)
Expand Down Expand Up @@ -393,23 +394,27 @@ void CI_LAB_ReadUpLink(void)
/* CI_LAB_VerifyCmdLength() -- Verify command packet length */
/* */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **/
bool CI_LAB_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength)
bool CI_LAB_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t ExpectedLength)
{
bool result = true;
uint16 ActualLength = CFE_SB_GetTotalMsgLength(msg);
bool result = true;
CFE_MSG_Size_t ActualLength = 0;
CFE_MSG_FcnCode_t FcnCode = 0;
CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID;

CFE_MSG_GetSize(MsgPtr, &ActualLength);

/*
** Verify the command packet length...
*/
if (ExpectedLength != ActualLength)
{
CFE_SB_MsgId_t MessageID = CFE_SB_GetMsgId(msg);
uint16 CommandCode = CFE_SB_GetCmdCode(msg);
CFE_MSG_GetMsgId(MsgPtr, &MsgId);
CFE_MSG_GetFcnCode(MsgPtr, &FcnCode);

CFE_EVS_SendEvent(CI_LAB_LEN_ERR_EID, CFE_EVS_EventType_ERROR,
"Invalid msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u",
(unsigned int)CFE_SB_MsgIdToValue(MessageID), (unsigned int)CommandCode,
(unsigned int)ActualLength, (unsigned int)ExpectedLength);
(unsigned int)CFE_SB_MsgIdToValue(MsgId), (unsigned int)FcnCode, (unsigned int)ActualLength,
(unsigned int)ExpectedLength);
result = false;
CI_LAB_Global.HkBuffer.HkTlm.Payload.CommandErrorCounter++;
}
Expand Down
3 changes: 2 additions & 1 deletion fsw/src/ci_lab_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "cfe_evs.h"
#include "cfe_sb.h"
#include "cfe_es.h"
#include "cfe_msg_api.h"

#include "osapi.h"

Expand Down Expand Up @@ -67,6 +68,6 @@ void CI_LAB_ProcessGroundCommand(void);
void CI_LAB_ResetCounters_Internal(void);
void CI_LAB_ReadUpLink(void);

bool CI_LAB_VerifyCmdLength(CFE_SB_MsgPtr_t msg, uint16 ExpectedLength);
bool CI_LAB_VerifyCmdLength(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Size_t ExpectedLength);

#endif /* _ci_lab_app_h_ */
4 changes: 2 additions & 2 deletions fsw/src/ci_lab_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ typedef struct

typedef struct
{
uint8 TlmHeader[CFE_SB_TLM_HDR_SIZE];
CFE_SB_TlmHdr_t TlmHeader;
CI_LAB_HkTlm_Payload_t Payload;
} OS_PACK CI_LAB_HkTlm_t;
} CI_LAB_HkTlm_t;

#define CI_LAB_HK_TLM_LNGTH sizeof(CI_LAB_HkTlm_t)

Expand Down
2 changes: 1 addition & 1 deletion fsw/src/ci_lab_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

/* Development Build Macro Definitions */

#define CI_LAB_BUILD_NUMBER 2 /*!< Development Build: Number of commits since baseline */
#define CI_LAB_BUILD_NUMBER 8 /*!< Development Build: Number of commits since baseline */
#define CI_LAB_BUILD_BASELINE \
"v2.4.0-rc1" /*!< Development Build: git tag that is the base for the current development */

Expand Down

0 comments on commit aa805af

Please sign in to comment.