Skip to content

Commit ce2f752

Browse files
authored
Merge branch 'main' into fix-394
2 parents 0cbd8a7 + f5c3cb3 commit ce2f752

File tree

3 files changed

+71
-63
lines changed

3 files changed

+71
-63
lines changed

fsw/inc/cf_msg.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,16 @@ typedef struct CF_NoArgsCmd
870870
CFE_MSG_CommandHeader_t cmd_header; /**< \brief Command header */
871871
} CF_NoArgsCmd_t;
872872

873+
/**
874+
* \brief Command payload argument union to support 4 uint8's, 2 uint16's or 1 uint32
875+
*/
876+
typedef union CF_UnionArgs_Payload
877+
{
878+
uint32 dword; /**< \brief Generic uint32 argument */
879+
uint16 hword[2]; /**< \brief Generic uint16 array of arguments */
880+
uint8 byte[4]; /**< \brief Generic uint8 array of arguments */
881+
} CF_UnionArgs_Payload_t;
882+
873883
/**
874884
* \brief Generic command structure with arguments supports common handling on multiple command types
875885
*
@@ -879,7 +889,7 @@ typedef struct CF_NoArgsCmd
879889
typedef struct
880890
{
881891
CFE_MSG_CommandHeader_t cmd_header; /**< \brief Command header */
882-
uint8 byte[4]; /**< \brief Generic uint8 array of arguments */
892+
CF_UnionArgs_Payload_t data; /**< \brief Generic command arguments */
883893
} CF_UnionArgsCmd_t;
884894

885895
/**

fsw/src/cf_cmd.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void CF_CmdReset(CFE_SB_Buffer_t *msg)
6262
CF_UnionArgsCmd_t *cmd = (CF_UnionArgsCmd_t *)msg;
6363
static const char *names[5] = {"all", "cmd", "fault", "up", "down"};
6464
/* 0=all, 1=cmd, 2=fault 3=up 4=down */
65-
uint8 param = cmd->byte[0];
65+
uint8 param = cmd->data.byte[0];
6666
int i;
6767
int acc = 1;
6868

@@ -220,22 +220,22 @@ CFE_Status_t CF_DoChanAction(CF_UnionArgsCmd_t *cmd, const char *errstr, CF_Chan
220220
/* this function is generic for any ground command that takes a single channel
221221
* argument which must be less than CF_NUM_CHANNELS or 255 which is a special
222222
* value that means apply command to all channels */
223-
if (cmd->byte[0] == CF_ALL_CHANNELS)
223+
if (cmd->data.byte[0] == CF_ALL_CHANNELS)
224224
{
225225
/* apply to all channels */
226226
for (i = 0; i < CF_NUM_CHANNELS; ++i)
227227
ret |= fn(i, context);
228228
}
229-
else if (cmd->byte[0] < CF_NUM_CHANNELS)
229+
else if (cmd->data.byte[0] < CF_NUM_CHANNELS)
230230
{
231-
ret = fn(cmd->byte[0], context);
231+
ret = fn(cmd->data.byte[0], context);
232232
}
233233
else
234234
{
235235
/* bad parameter */
236236
CFE_EVS_SendEvent(CF_EID_ERR_CMD_CHAN_PARAM, CFE_EVS_EventType_ERROR,
237-
"CF: %s: channel parameter out of range. received %d", errstr, cmd->byte[0]);
238-
ret = CF_ERROR;
237+
"CF: %s: channel parameter out of range. received %d", errstr, cmd->data.byte[0]);
238+
ret = -1;
239239
}
240240

241241
return ret;
@@ -591,20 +591,20 @@ CFE_Status_t CF_DoEnableDisablePolldir(uint8 chan_num, const CF_ChanAction_BoolM
591591
int i;
592592
CFE_Status_t ret = CFE_SUCCESS;
593593
/* no need to bounds check chan_num, done in caller */
594-
if (context->msg->byte[1] == CF_ALL_POLLDIRS)
594+
if (context->msg->data.byte[1] == CF_ALL_POLLDIRS)
595595
{
596596
/* all polldirs in channel */
597597
for (i = 0; i < CF_MAX_POLLING_DIR_PER_CHAN; ++i)
598598
CF_AppData.config_table->chan[chan_num].polldir[i].enabled = context->barg;
599599
}
600-
else if (context->msg->byte[1] < CF_MAX_POLLING_DIR_PER_CHAN)
600+
else if (context->msg->data.byte[1] < CF_MAX_POLLING_DIR_PER_CHAN)
601601
{
602-
CF_AppData.config_table->chan[chan_num].polldir[context->msg->byte[1]].enabled = context->barg;
602+
CF_AppData.config_table->chan[chan_num].polldir[context->msg->data.byte[1]].enabled = context->barg;
603603
}
604604
else
605605
{
606606
CFE_EVS_SendEvent(CF_EID_ERR_CMD_POLLDIR_INVALID, CFE_EVS_EventType_ERROR,
607-
"CF: enable/disable polldir: invalid polldir %d on channel %d", context->msg->byte[1],
607+
"CF: enable/disable polldir: invalid polldir %d on channel %d", context->msg->data.byte[1],
608608
chan_num);
609609
ret = CF_ERROR;
610610
}
@@ -703,7 +703,7 @@ CFE_Status_t CF_DoPurgeQueue(uint8 chan_num, CF_UnionArgsCmd_t *cmd)
703703
int pend = 0;
704704
int hist = 0;
705705

706-
switch (cmd->byte[1])
706+
switch (cmd->data.byte[1])
707707
{
708708
case 0: /* pend */
709709
pend = 1;
@@ -720,8 +720,8 @@ CFE_Status_t CF_DoPurgeQueue(uint8 chan_num, CF_UnionArgsCmd_t *cmd)
720720

721721
default:
722722
CFE_EVS_SendEvent(CF_EID_ERR_CMD_PURGE_ARG, CFE_EVS_EventType_ERROR, "CF: purge queue invalid arg %d",
723-
cmd->byte[1]);
724-
ret = CF_ERROR;
723+
cmd->data.byte[1]);
724+
ret = -1;
725725
break;
726726
}
727727

0 commit comments

Comments
 (0)