Skip to content

Commit

Permalink
Fix #2114, Add macro for initializing command header
Browse files Browse the repository at this point in the history
  • Loading branch information
skliper committed Jun 7, 2022
1 parent 10898c9 commit f9112b4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/msg/option_inc/default_cfe_msg_hdr_pri.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@
*/
#define CFE_MSG_PTR(shdr) (&((shdr).Msg))

/**
* \brief Macro to initialize a command header, useful in tables that define commands
*/
#define CFE_MSG_CMD_HDR_INIT(mid, size, fc, cksum) \
{ \
.Msg.CCSDS = \
{ \
.Pri = {.StreamId = {((mid) >> 8) & 0xFF, (mid)&0xFF}, \
.Sequence = {0xC0, 0}, \
.Length = {((size)-7) >> 8, ((size)-7) & 0xFF}}, \
}, \
CFE_MSG_CMD_HDR_SEC_INIT(fc, cksum) \
}

/*
* Type Definitions
*/
Expand Down
22 changes: 22 additions & 0 deletions modules/msg/option_inc/default_cfe_msg_hdr_priext.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@
*/
#define CFE_MSG_PTR(shdr) (&((shdr).Msg))

/**
* \brief Macro to initialize a command header, useful in tables that define commands
*/
#define CFE_MSG_CMD_HDR_INIT(mid, size, fc, cksum) \
{ \
.Msg.CCSDS = \
{ \
.Pri = \
{ \
.StreamId = {(((mid)&0x80)<<5, (mid)&0x7F}, \
.Sequence = {0xC0, 0}, \
.Length = {((size)-7)>>8, ((size)-7)&0xFF} \
}, \
.Ext = \
{ \
.Subsystem = {0, ((mid)>>8)&0xFF}, \
.SystemId = {0, 0) \
} \
}, \
CFE_MSG_CMD_HDR_SEC_INIT(fc, cksum) \
}

/*
* Type Definitions
*/
Expand Down
5 changes: 5 additions & 0 deletions modules/msg/option_inc/default_cfe_msg_sechdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
* Defines
*/

/**
* \brief Macro to initialize secondary header, used in macro to intialize entire header which is useful in tables
*/
#define CFE_MSG_CMD_HDR_SEC_INIT(fc, cksum) .Sec = {.FunctionCode = (fc), .Checksum = (cksum)}

/*
* Type Definitions
*/
Expand Down

0 comments on commit f9112b4

Please sign in to comment.