Skip to content

Commit 1db3d97

Browse files
jphickeyastrogeco
authored andcommitted
Fix #38: Add union for proper TLM buffer alignment
Put the HkTlm buffer into a union to ensure it is aligned appropriately for conversion to a CFE_SB_Msg_t type.
1 parent 4adabae commit 1db3d97

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

fsw/src/sample_app.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int32 SAMPLE_AppInit( void )
174174
/*
175175
** Initialize housekeeping packet (clear user data area).
176176
*/
177-
CFE_SB_InitMsg(&SAMPLE_AppData.HkBuf,
177+
CFE_SB_InitMsg(&SAMPLE_AppData.HkBuf.MsgHdr,
178178
SAMPLE_APP_HK_TLM_MID,
179179
sizeof(SAMPLE_AppData.HkBuf),
180180
true);
@@ -356,14 +356,14 @@ int32 SAMPLE_ReportHousekeeping( const CCSDS_CommandPacket_t *Msg )
356356
/*
357357
** Get command execution counters...
358358
*/
359-
SAMPLE_AppData.HkBuf.Payload.CommandErrorCounter = SAMPLE_AppData.ErrCounter;
360-
SAMPLE_AppData.HkBuf.Payload.CommandCounter = SAMPLE_AppData.CmdCounter;
359+
SAMPLE_AppData.HkBuf.HkTlm.Payload.CommandErrorCounter = SAMPLE_AppData.ErrCounter;
360+
SAMPLE_AppData.HkBuf.HkTlm.Payload.CommandCounter = SAMPLE_AppData.CmdCounter;
361361

362362
/*
363363
** Send housekeeping telemetry packet...
364364
*/
365-
CFE_SB_TimeStampMsg(&SAMPLE_AppData.HkBuf);
366-
CFE_SB_SendMsg(&SAMPLE_AppData.HkBuf);
365+
CFE_SB_TimeStampMsg(&SAMPLE_AppData.HkBuf.MsgHdr);
366+
CFE_SB_SendMsg(&SAMPLE_AppData.HkBuf.MsgHdr);
367367

368368
/*
369369
** Manage any pending table loads, validations, etc.

fsw/src/sample_app.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@
5656
/************************************************************************
5757
** Type Definitions
5858
*************************************************************************/
59+
60+
/*
61+
* Buffer to hold telemetry data prior to sending
62+
* Defined as a union to ensure proper alignment for a CFE_SB_Msg_t type
63+
*/
64+
typedef union
65+
{
66+
CFE_SB_Msg_t MsgHdr;
67+
SAMPLE_HkTlm_t HkTlm;
68+
} SAMPLE_HkBuffer_t;
69+
5970
/*
6071
** Global Data
6172
*/
@@ -70,7 +81,7 @@ typedef struct
7081
/*
7182
** Housekeeping telemetry packet...
7283
*/
73-
SAMPLE_HkTlm_t HkBuf;
84+
SAMPLE_HkBuffer_t HkBuf;
7485

7586
/*
7687
** Run Status variable used in the main processing loop

0 commit comments

Comments
 (0)