Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
41 changes: 41 additions & 0 deletions .github/workflows/snapshot-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Snapshot CFS module

on:
workflow_dispatch:
inputs:
base-branch:
description: 'The base branch to merge into'
type: string
required: false
default: 'main'
ic-branch:
description: 'The temporary integration branch to create (ic)'
type: string
required: false
default: 'ic-snapshot-dev'
dev-branch:
description: 'The branch to pull in'
type: string
required: false
default: 'dev'
pr-label:
description: 'The label(s) to apply to the generated PR'
type: string
required: false
default: ''
version-numbers:
description: 'The pending version/tag info, as a JSON object'
type: string
required: false
default: '{}'

jobs:
snapshot-module:
name: Snapshot module
uses: nasa/cFS/.github/workflows/snapshot-module-reusable.yml@dev
with:
base-branch: ${{ inputs.base-branch }}
ic-branch: ${{ inputs.ic-branch }}
dev-branch: ${{ inputs.dev-branch }}
pr-label: ${{ inputs.pr-label }}
version-numbers: ${{ inputs.version-numbers }}
72 changes: 44 additions & 28 deletions fsw/src/lc_action.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,27 +288,27 @@ void LC_SampleSingleAP(uint16 APNumber)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
* StackPtr is an index into an array RPNStack (see LC_EvaluateRPN)
* StackIdx is an index into an array RPNStack (see LC_EvaluateRPN)
* which contains values to be used in an RPN function. This macro
* validates the StackPtr to confirm that another operand is present
* validates the StackIdx to confirm that another operand is present
* in the RPMStack array, then returns the next element.
*/
#define POP_RPN_DATA ((StackPtr <= 0) ? (IllegalRPN = true) : (RPNStack[--StackPtr]))
#define POP_RPN_DATA ((StackIdx <= 0) ? (IllegalRPN = true) : (RPNStack[--StackIdx]))
uint8 LC_EvaluateRPN(uint16 APNumber)
{
bool Done;
bool IllegalRPN;
bool IllegalOperand;
uint8 EvalResult = LC_ACTION_ERROR;
int32 RPNEquationPtr;
int32 StackPtr;
int32 RPNEquationIdx;
int32 StackIdx;
uint16 RPNData;
uint16 RPNStack[LC_MAX_RPN_EQU_SIZE];
uint16 Operand1;
uint16 Operand2;

StackPtr = 0;
RPNEquationPtr = 0;
StackIdx = 0;
RPNEquationIdx = 0;
IllegalRPN = false;
IllegalOperand = false;
Done = false;
Expand All @@ -322,7 +322,9 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
** Pick off each piece of the RPN equation and handle
** one at a time
*/
RPNData = LC_OperData.ADTPtr[APNumber].RPNEquation[RPNEquationPtr++];
RPNData = LC_OperData.ADTPtr[APNumber].RPNEquation[RPNEquationIdx];

RPNEquationIdx++;

/*
** The data is either an RPN operator or a watchpoint number
Expand All @@ -339,74 +341,86 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
Operand1 = POP_RPN_DATA;
if ((Operand1 == LC_WATCH_FALSE) || (Operand2 == LC_WATCH_FALSE))
{
RPNStack[StackPtr++] = LC_WATCH_FALSE;
RPNStack[StackIdx] = LC_WATCH_FALSE;
}
else if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR))
{
RPNStack[StackPtr++] = LC_WATCH_ERROR;
RPNStack[StackIdx] = LC_WATCH_ERROR;
}
else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE))
{
RPNStack[StackPtr++] = LC_WATCH_STALE;
RPNStack[StackIdx] = LC_WATCH_STALE;
}
else
{
RPNStack[StackPtr++] = LC_WATCH_TRUE;
RPNStack[StackIdx] = LC_WATCH_TRUE;
}

StackIdx++;

break;

case LC_RPN_OR:
Operand2 = POP_RPN_DATA;
Operand1 = POP_RPN_DATA;
if ((Operand1 == LC_WATCH_TRUE) || (Operand2 == LC_WATCH_TRUE))
{
RPNStack[StackPtr++] = LC_WATCH_TRUE;
RPNStack[StackIdx] = LC_WATCH_TRUE;
}
else if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR))
{
RPNStack[StackPtr++] = LC_WATCH_ERROR;
RPNStack[StackIdx] = LC_WATCH_ERROR;
}
else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE))
{
RPNStack[StackPtr++] = LC_WATCH_STALE;
RPNStack[StackIdx] = LC_WATCH_STALE;
}
else
{
RPNStack[StackPtr++] = LC_WATCH_FALSE;
RPNStack[StackIdx] = LC_WATCH_FALSE;
}

StackIdx++;

break;

case LC_RPN_XOR:
Operand2 = POP_RPN_DATA;
Operand1 = POP_RPN_DATA;
if ((Operand1 == LC_WATCH_ERROR) || (Operand2 == LC_WATCH_ERROR))
{
RPNStack[StackPtr++] = LC_WATCH_ERROR;
RPNStack[StackIdx] = LC_WATCH_ERROR;
}
else if ((Operand1 == LC_WATCH_STALE) || (Operand2 == LC_WATCH_STALE))
{
RPNStack[StackPtr++] = LC_WATCH_STALE;
RPNStack[StackIdx] = LC_WATCH_STALE;
}
else
{
RPNStack[StackPtr++] = (Operand1 != Operand2);
RPNStack[StackIdx] = (Operand1 != Operand2);
}

StackIdx++;

break;

case LC_RPN_NOT:
Operand1 = POP_RPN_DATA;
if (Operand1 == LC_WATCH_ERROR)
{
RPNStack[StackPtr++] = LC_WATCH_ERROR;
RPNStack[StackIdx] = LC_WATCH_ERROR;
}
else if (Operand1 == LC_WATCH_STALE)
{
RPNStack[StackPtr++] = LC_WATCH_STALE;
RPNStack[StackIdx] = LC_WATCH_STALE;
}
else
{
RPNStack[StackPtr++] = (Operand1 == LC_WATCH_FALSE);
RPNStack[StackIdx] = (Operand1 == LC_WATCH_FALSE);
}

StackIdx++;

break;

case LC_RPN_EQUAL:
Expand All @@ -415,7 +429,7 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
{
IllegalOperand = true;
}
else if (StackPtr == 0)
else if (StackIdx == 0)
{
Done = true;
}
Expand All @@ -432,7 +446,9 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
default:
if (RPNData < LC_MAX_WATCHPOINTS)
{
RPNStack[StackPtr++] = LC_OperData.WRTPtr[RPNData].WatchResult;
RPNStack[StackIdx] = LC_OperData.WRTPtr[RPNData].WatchResult;

StackIdx++;
}
else
{
Expand All @@ -447,7 +463,7 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
*/
if ((Done == false) && (IllegalRPN == false) && (IllegalOperand == false))
{
if (RPNEquationPtr >= LC_MAX_RPN_EQU_SIZE)
if (RPNEquationIdx >= LC_MAX_RPN_EQU_SIZE)
{
IllegalRPN = true;
}
Expand All @@ -459,10 +475,10 @@ uint8 LC_EvaluateRPN(uint16 APNumber)
{
CFE_EVS_SendEvent(LC_INVALID_RPN_ERR_EID,
CFE_EVS_EventType_ERROR,
"AP has illegal RPN expression: AP = %d, LastOperand = %d, StackPtr = %d",
"AP has illegal RPN expression: AP = %d, LastOperand = %d, StackIdx = %d",
APNumber,
(int)(RPNEquationPtr - 1),
(int)StackPtr);
(int)(RPNEquationIdx - 1),
(int)StackIdx);

EvalResult = LC_ACTION_ERROR;
}
Expand Down
14 changes: 7 additions & 7 deletions fsw/src/lc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ LC_AppData_t LC_AppData;

void LC_AppMain(void)
{
int32 Status = CFE_SUCCESS;
bool Initialized = false;
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
CFE_SB_Buffer_t *BufPtr = NULL;
int32 Status;
bool Initialized;
uint32 RunStatus = CFE_ES_RunStatus_APP_RUN;
CFE_SB_Buffer_t *BufPtr = NULL;

/*
** Performance Log, Start
Expand Down Expand Up @@ -186,7 +186,7 @@ void LC_AppMain(void)

CFE_Status_t LC_AppInit(void)
{
CFE_Status_t Status = CFE_SUCCESS;
CFE_Status_t Status;

/*
** Zero out the global data structures...
Expand Down Expand Up @@ -241,7 +241,7 @@ CFE_Status_t LC_AppInit(void)

CFE_Status_t LC_EvsInit(void)
{
CFE_Status_t Status = CFE_SUCCESS;
CFE_Status_t Status;

/*
** If an application event filter table is added
Expand Down Expand Up @@ -269,7 +269,7 @@ CFE_Status_t LC_EvsInit(void)

CFE_Status_t LC_SbInit(void)
{
CFE_Status_t Status = CFE_SUCCESS;
CFE_Status_t Status;

/*
** Initialize housekeeping packet...
Expand Down
28 changes: 19 additions & 9 deletions fsw/src/lc_watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ void LC_CreateHashTable(void)
if (CFE_SB_MsgId_Equal(LastMessageID, MessageID) && (WatchPtLink != (LC_WatchPtList_t *)NULL))
{
/* WatchPtLink points to last link in list for this Message ID */
WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++];
WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount];

LC_OperData.WatchpointCount++;

/* Add new link to end of list, point to new last link */
WatchPtLink = WatchPtLink->Next;
Expand Down Expand Up @@ -180,7 +182,9 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID)
if (LC_OperData.HashTable[HashTableIndex] == (LC_MessageList_t *)NULL)
{
/* Get next unused MessageID linked list entry */
MessageLink = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount++];
MessageLink = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount];

LC_OperData.MessageIDsCount++;

/* Set first (and only) link in this hash table entry linked list */
LC_OperData.HashTable[HashTableIndex] = MessageLink;
Expand All @@ -202,9 +206,11 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID)
if (MessageLink->Next == (LC_MessageList_t *)NULL)
{
/* Reached end of list without finding MessageID */
MessageLink->Next = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount++];
MessageLink->Next = &LC_OperData.MessageLinks[LC_OperData.MessageIDsCount];
MessageLink = MessageLink->Next;

LC_OperData.MessageIDsCount++;

/* Add link with this MessageID (will exit loop) */
MessageLink->MessageID = MessageID;

Expand Down Expand Up @@ -237,7 +243,9 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID)
if (MessageLink->WatchPtList == (LC_WatchPtList_t *)NULL)
{
/* Get next unused watchpoint linked list entry */
WatchPtLink = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++];
WatchPtLink = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount];

LC_OperData.WatchpointCount++;

/* Set the start (and only) link in the watchpoint link list */
MessageLink->WatchPtList = WatchPtLink;
Expand All @@ -253,8 +261,10 @@ LC_WatchPtList_t *LC_AddWatchpoint(CFE_SB_MsgId_t MessageID)
}

/* Add the new watchpoint link to the end of the list */
WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount++];
WatchPtLink->Next = &LC_OperData.WatchPtLinks[LC_OperData.WatchpointCount];
WatchPtLink = WatchPtLink->Next;

LC_OperData.WatchpointCount++;
}

/* Return pointer to last link in watchpoint linked list */
Expand Down Expand Up @@ -785,9 +795,9 @@ bool LC_WPOffsetValid(uint16 WatchIndex, const CFE_SB_Buffer_t *BufPtr)
{
size_t MsgLength = 0;
uint32 Offset;
uint32 NumOfDataBytes = 0;
bool OffsetValid = true;
CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID;
uint32 NumOfDataBytes;
bool OffsetValid = true;
CFE_SB_MsgId_t MessageID = CFE_SB_INVALID_MSG_ID;

/*
** Check the message length against the watchpoint
Expand Down Expand Up @@ -907,7 +917,7 @@ bool LC_GetSizedWPData(uint16 WatchIndex, const uint8 *WPDataPtr, uint32 *SizedD
{
case LC_DATA_WATCH_BYTE:
TempBuffer.Signed8 = *WPDataPtr;
*SizedDataPtr = TempBuffer.Signed8; /* Extend signed 8 bit value to 32 bits */
*SizedDataPtr = (uint32)TempBuffer.Signed8; /* Extend signed 8 bit value to 32 bits */
break;

case LC_DATA_WATCH_UBYTE:
Expand Down
4 changes: 2 additions & 2 deletions unit-test/lc_action_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ void LC_EvaluateRPN_Test_DefaultIllegalRPN(void)

snprintf(ExpectedEventString,
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackPtr = %%d");
"AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackIdx = %%d");

LC_OperData.ADTPtr[APNumber].RPNEquation[0] = LC_MAX_WATCHPOINTS;

Expand Down Expand Up @@ -1135,7 +1135,7 @@ void LC_EvaluateRPN_Test_EndOfBufferWhenNotDone(void)

snprintf(ExpectedEventString,
CFE_MISSION_EVS_MAX_MESSAGE_LENGTH,
"AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackPtr = %%d");
"AP has illegal RPN expression: AP = %%d, LastOperand = %%d, StackIdx = %%d");

for (i = 0; i < (sizeof(LC_OperData.ADTPtr[0].RPNEquation) / sizeof(LC_OperData.ADTPtr[0].RPNEquation[0])); i++)
{
Expand Down