Skip to content
Open
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
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ project(CFS_SCH C)
include_directories(fsw/public_inc)
include_directories(fsw/mission_inc)
include_directories(fsw/platform_inc)
include_directories(fsw/src)

aux_source_directory(fsw/src APP_SRC_FILES)

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

# Create the app tables if the parent build has the add_cfe_tables command
if (COMMAND add_cfe_tables)
add_cfe_tables(sch fsw/tables/sch_def_schtbl.c fsw/tables/sch_def_msgtbl.c)
endif(COMMAND add_cfe_tables)
2 changes: 1 addition & 1 deletion fsw/platform_inc/sch_msgids.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
***************************/
#define SCH_CMD_MID 0x1895 /**< \brief SCH Ground Commands Message ID */
#define SCH_SEND_HK_MID 0x1896 /**< \brief SCH Send Housekeeping Message ID */
#define SCH_UNUSED_MID 0x1897 /**< \brief SCH MDT Unused Message Message ID */
#define SCH_UNUSED_MID (CFE_SB_HIGHEST_VALID_MSGID+1) /**< \brief SCH MDT Unused Message Message ID */
/*
#define SCH_SPARE1 0x1898
#define SCH_SPARE2 0x1899
Expand Down
2 changes: 1 addition & 1 deletion fsw/platform_inc/sch_platform_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
** Must be at least large enough to hold the smallest possible message header
* ** (see #CFE_SB_TLM_HDR_SIZE and #CFE_SB_CMD_HDR_SIZE)
*/
#define SCH_MAX_MSG_WORDS 64 /* max message length (in words) */
#define SCH_MAX_MSG_WORDS 62 /* max message length (in words) */


/*
Expand Down
39 changes: 29 additions & 10 deletions fsw/src/sch_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
#include "sch_verify.h"
#include "cfe_platform_cfg.h" /* for CFE_SB_HIGHEST_VALID_MSGID */

uint8 CFE_SB_GetPktType(CFE_SB_MsgId_t MsgId);

/*************************************************************************
**
** Macro definitions
Expand Down Expand Up @@ -1166,7 +1168,8 @@ int32 SCH_ValidateMessageData(void *TableData)
uint16 *MessageBuffer;
uint16 *UserDataPtr;

uint16 MessageLength;
uint16 PayloadLength;
uint16 CmdCode;
CFE_SB_MsgId_t MessageID;
CFE_SB_MsgId_t MaxValue = (CFE_SB_MsgId_t) SCH_MDT_MAX_MSG_ID;
CFE_SB_MsgId_t MinValue = (CFE_SB_MsgId_t) SCH_MDT_MIN_MSG_ID;
Expand All @@ -1184,17 +1187,18 @@ int32 SCH_ValidateMessageData(void *TableData)
BufferIndex = 0;

MessageBuffer = &TableArray[TableIndex].MessageBuffer[0];
MessageID = CFE_SB_GetMsgId((CFE_SB_MsgPtr_t) MessageBuffer);
MessageLength = CFE_SB_GetTotalMsgLength((CFE_SB_MsgPtr_t) MessageBuffer);
MessageID = TableArray[TableIndex].mid;
CmdCode = TableArray[TableIndex].cmdCode;
PayloadLength = TableArray[TableIndex].payloadLength;

if (MessageID == SCH_UNUSED_MID)
{
/*
** If message ID is unused, then look for junk in user data portion
*/
UnusedCount++;
UserDataPtr = (uint16 *)CFE_SB_GetUserData((CFE_SB_MsgPtr_t) MessageBuffer);
while (UserDataPtr < &TableArray[TableIndex+1].MessageBuffer[0])
UserDataPtr = &MessageBuffer[0];
while (UserDataPtr <= &TableArray[TableIndex].MessageBuffer[SCH_MAX_MSG_WORDS-1])
{
if (*UserDataPtr != SCH_UNUSED)
{
Expand All @@ -1212,16 +1216,31 @@ int32 SCH_ValidateMessageData(void *TableData)
/*
** If message ID is valid, then check message length
*/
if ((MessageLength > (SCH_MAX_MSG_WORDS * 2)) ||
(MessageLength < (SCH_MIN_MSG_WORDS * 2)) ||
((MessageLength & 1) != 0))
if (PayloadLength > SCH_MAX_MSG_WORDS*2)
{
EntryResult = SCH_MDT_INVALID_LENGTH;
BadCount++;
}
else
{
GoodCount++;
GoodCount++;
// Populate the CCSDS header and move the message content into the proper user data space.
uint16 TempBuffer[SCH_MAX_MSG_WORDS];
if(PayloadLength > 0) {
CFE_PSP_MemCpy( TempBuffer, MessageBuffer, PayloadLength );
}

if ( CFE_SB_GetPktType( MessageID ) == 1 )
{
CFE_SB_InitMsg( MessageBuffer, MessageID, sizeof(CCSDS_CommandPacket_t) + PayloadLength, TRUE );
CFE_SB_SetCmdCode( (CFE_SB_MsgPtr_t) MessageBuffer, CmdCode );
CFE_PSP_MemCpy( MessageBuffer + sizeof(CCSDS_CommandPacket_t), TempBuffer, PayloadLength );
}
else
{
CFE_SB_InitMsg( MessageBuffer, MessageID, sizeof(CCSDS_TelemetryPacket_t) + PayloadLength, TRUE );
CFE_PSP_MemCpy( MessageBuffer + sizeof(CCSDS_TelemetryPacket_t), TempBuffer, PayloadLength );
}
}
}
else
Expand All @@ -1239,7 +1258,7 @@ int32 SCH_ValidateMessageData(void *TableData)

CFE_EVS_SendEvent(SCH_MESSAGE_TBL_ERR_EID, CFE_EVS_ERROR,
"Message tbl verify err - idx[%d] mid[0x%X] len[%d] buf[%d]",
(int)TableIndex, MessageID, MessageLength, (int)BufferIndex);
(int)TableIndex, MessageID, PayloadLength, (int)BufferIndex);
}
}

Expand Down
6 changes: 5 additions & 1 deletion fsw/src/sch_tbldefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ typedef struct
*/
typedef struct
{
uint16 MessageBuffer[SCH_MAX_MSG_WORDS]; /**< \brief Packed Messages */

CFE_SB_MsgId_t mid; /**< \brief MID to send */
uint16 cmdCode; /**< \brief Specifies the command code if relevant. */
uint16 payloadLength; /**< \brief Message length of any user payload. */
uint16 MessageBuffer[SCH_MAX_MSG_WORDS]; /**< \brief User payload content byte-stream. */

} SCH_MessageEntry_t;

Expand Down
Loading