Skip to content

Commit

Permalink
Part nasa#17, Use real message types in tables
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Jun 7, 2022
1 parent 7743c2a commit 65889dc
Showing 1 changed file with 31 additions and 67 deletions.
98 changes: 31 additions & 67 deletions fsw/tables/sc_rts001.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,82 +47,46 @@

#include "cfe.h"
#include "cfe_tbl_filedef.h"
#include "cfe_endian.h"

#include "sc_app.h" /* defines SC table headers */
#include "sc_platform_cfg.h" /* defines table buffer size */
#include "sc_msgdefs.h" /* defines SC command code values */
#include "sc_msgids.h" /* defines SC packet msg ID's */

/*
** Execution time for each sample command
*/
#define CMD1_TIME 0
#define CMD2_TIME 5
#define CMD3_TIME 5
* Checksum for each sample command
*/
#ifndef SC_NOOP_CKSUM
#define SC_NOOP_CKSUM 0x8F
#endif

/*
** Calculate checksum for each sample command
*/
#define CMD1_XSUM 0x008F
#define CMD2_XSUM 0x0088
#define CMD3_XSUM 0x008B
/* Custom table structure, modify as needed to add desired commands */
typedef struct
{
SC_RtsEntryHeader_t hdr1;
SC_NoArgsCmd_t cmd1;
SC_RtsEntryHeader_t hdr2;
SC_NoArgsCmd_t cmd2;
} SC_RtsStruct001_t;

/*
** Optional command data values
*/
#define CMD2_ARG 0x0200
#define CMD3_ARG 0x0200
/* Define the union to size the table correctly */
typedef union
{
SC_RtsStruct001_t rts;
uint16 buf[SC_RTS_BUFF_SIZE];
} SC_RtsTable001_t;

/*
** Command packet segment flags and sequence counter
** - 2 bits of segment flags (0xC000 = start and end of packet)
** - 14 bits of sequence count (unused for command packets)
*/
#define PKT_FLAGS 0xC000
/* Helper macro to get size of structure elements */
#define SC_RTS_MEMBER_SIZE(member) sizeof(((SC_RtsStruct001_t *)0)->member)

/*
** Length of cmd pkt data (in bytes minus one) that follows primary header (thus, 0xFFFF = 64k)
*/
#define CMD1_LENGTH 1
#define CMD2_LENGTH 5
#define CMD3_LENGTH 5

/*
** Sample cFE Table Header
*/
static CFE_TBL_FileDef_t CFE_TBL_FileDef __attribute__((__used__)) = {
"RTS_Table001", "SC.RTS_TBL001", "SC Sample RTS_TBL001", "sc_rts001.tbl", (SC_RTS_BUFF_SIZE * sizeof(uint16))};

/*
** Sample RTS Table Data
*/
uint16 RTS_Table001[SC_RTS_BUFF_SIZE] = {
/* cmd time, <---------------------------- cmd pkt primary header ----------------------------> <----- cmd pkt
2nd header ----> <-- opt data ---> */
0x0000,
CMD1_TIME,
CFE_MAKE_BIG16(SC_CMD_MID),
CFE_MAKE_BIG16(PKT_FLAGS),
CFE_MAKE_BIG16(CMD1_LENGTH),
CFE_MAKE_BIG16((SC_NOOP_CC << 8) | CMD1_XSUM),
0x0000,
CMD2_TIME,
CFE_MAKE_BIG16(SC_CMD_MID),
CFE_MAKE_BIG16(PKT_FLAGS),
CFE_MAKE_BIG16(CMD2_LENGTH),
CFE_MAKE_BIG16((SC_ENABLE_RTS_CC << 8) | CMD2_XSUM),
CMD2_ARG,
0x0000,
0x0000,
CMD3_TIME,
CFE_MAKE_BIG16(SC_CMD_MID),
CFE_MAKE_BIG16(PKT_FLAGS),
CFE_MAKE_BIG16(CMD3_LENGTH),
CFE_MAKE_BIG16((SC_START_RTS_CC << 8) | CMD3_XSUM),
CMD3_ARG,
0x0000,
/* Used designated intializers to be verbose, modify as needed/desired */
SC_RtsTable001_t SC_Rts001 =
{
.rts.hdr1.TimeTag = 5,
.rts.cmd1.CmdHeader = CFE_MSG_CMD_HDR_INIT(SC_CMD_MID, SC_RTS_MEMBER_SIZE(cmd1), SC_NOOP_CC, SC_NOOP_CKSUM),
.rts.hdr2.TimeTag = 3,
.rts.cmd2.CmdHeader = CFE_MSG_CMD_HDR_INIT(SC_CMD_MID, SC_RTS_MEMBER_SIZE(cmd2), SC_NOOP_CC, SC_NOOP_CKSUM)
};

/************************/
/* End of File Comment */
/************************/
/* Macro for table structure */
CFE_TBL_FILEDEF(SC_Rts001, SC.RTS_TBL001, SC Example RTS_TBL001, sc_rts001.tbl)

0 comments on commit 65889dc

Please sign in to comment.