Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #488, Remove compiler added padding in tlm packets #662

Closed
wants to merge 1 commit into from

Conversation

dmknutsen
Copy link
Contributor

@dmknutsen dmknutsen commented May 1, 2020

Describe the contribution
Fix #488
Removes compiler added padding by padding CCSDS_TlmSecHdr_t such that the payload will always start on a 64-bit boundary. Also adjusts packet alignment such that packets with 64 bit variables are aligned correctly.

Related to nasa/cFS-GroundSystem#81
Intended to be delivered with nasa/cFS-GroundSystem#82

Testing performed
Steps taken to test the contribution:

  1. Modified GroundSystem.py to display raw packets as they are being decommed
  2. Bit busted packets to ensure no compiler added padding is being applied.
  3. Ran unit tests.

Expected behavior changes
Compiler added padding will no longer be applied to packets.

System(s) tested on
Oracle VM VirtualBox
OS: ubuntu-19.10
Versions: cFE 6.7.14.0, OSAL 5.0.13.0, PSP 1.4.9.0

Contributor Info - All information REQUIRED for consideration of pull request
Dan Knutsen
NASA/Goddard

@skliper skliper added this to the 7.0.0 milestone May 1, 2020
@astrogeco astrogeco added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label May 5, 2020
@astrogeco astrogeco changed the title Fix 488, Remove compiler added padding in tlm packets Fix #488, Remove compiler added padding in tlm packets May 5, 2020
@astrogeco
Copy link
Contributor

CCB-20200506 - Will conflict with some 6.8 changes so we'll need to handle that. Related discussion on #678 .

@skliper skliper added CCB:Ignore Pull Request can be ignored. Will be re-examined at by next CCB. and removed CCB:Ready Ready for discussion at the Configuration Control Board (CCB) labels May 6, 2020
uint8 tempPad1[4];
#elif ( CCSDS_TIME_SIZE == 8 )
uint8 tempPad1[2];
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding shouldn't be added this way -- it isn't a fixed quantity. Furthermore the "ccsds.h" definition should be the source of truth -- that is, it should be the actual definition of the structure without getting into any architecture-specific padding requirements.

The other reason not to do it this way is that the opposite problem exists when extended headers is enabled. This adds 4 bytes to the primary, so now the size of TLM hdr becomes 16 and the CMD header becomes 12, so now CMDs will need padding and TLM packets will not.

The paradigm should be that ccsds.h definitions represent the basic fundamental primitives, and cfe_sb.h structures represent how these are actually realized for use within the software bus and applications.

So - in the related PR #678 the CFE_SB_TlmHdr_t becomes a padded and aligned version of CCSDS_TlmSecHdr_t

One can reliably determine the actual amount of padding on the current system by checking sizeof(CFE_SB_TlmHdr_t) - sizeof(CCSDS_TlmSecHdr_t) or equivalent...

This will work on 32 bit or 64 bit, with or without extended headers, and should continue to work even if the headers are changed in the future.

Copy link
Contributor

@CDKnightNASA CDKnightNASA May 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or what about using a union, like:

typedef union { uint8 Time[CCSDS_TIME_SIZE], TotalSz[10] } CCSDS_TlmSecHdr_t;

@skliper skliper added duplicate and removed enhancement CCB:Ignore Pull Request can be ignored. Will be re-examined at by next CCB. labels May 6, 2020
@skliper
Copy link
Contributor

skliper commented May 6, 2020

Marking as duplicate and closing for now, can reinvestigate as part of future packet refactor for the padding within packets.

@skliper skliper closed this May 6, 2020
@skliper skliper removed this from the 7.0.0 milestone Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cFE Tlm Packet 64-bit alignment issue
5 participants