nasa / ECI

CFS application framework for integrating external C code into the CFS environment
https://nasa.github.io/ECI/
Other
34 stars 12 forks source link

ECI not updating outgoing packet headers properly #1

Open SpaceSteve121 opened 5 years ago

SpaceSteve121 commented 5 years ago

In past usage, the external code allocated space for the CCSDS header in the output messages, but expected the ECI to manage the header (which is generally out-of-scope for the external code). This was implemented by having the ECI initialize the header at startup (using CFE_SB_InitMsg) and then filling the MessageID (via CFE_SB_SetMsgId), Packet Length (via CFE_SB_SetTotalMsgLength), and Timestamp (via CFE_SB_TimeStampMsg) after each step function.

This implementation works so long as the external code does not modify the header. It was discovered that if the external code overwrote the secondary header flag to indicate no secondary header, CFE_SB_TimeStampMsg, which checks that flag, did not update the time as intended.

To remedy this situation and better define the intent of the external code, I intend to update the ECI such that it overwrite the entire header (using CFE_SB_InitMsg) after the execution of the step function and then update the timestamp (using CFE_SB_TimeStampMsg), which ensures a correct header regardless of what the step function may have done during execution. The external code may disable this functionality by defining ECI_MSG_HEADER_NO_OVERWRITE, in which case the external code takes full responsibility for managing the header (including setting the messageID, packet length, and timestamps or checksum).

This change preserves the current output message definition, but does not allow packet-by-packet control of this behavior. That could be investigated if that's a desired feature.

SpaceSteve121 commented 5 years ago

It was also discovered that ECI does not fill the checksum field for outgoing command messages, which should also be fixed for compatibility with downstream apps which do validate checksums.