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

Support for fractional seconds in epoch definition #2084

Closed
jonathan-brandenburg-metecs opened this issue Apr 11, 2022 · 1 comment · Fixed by #2088 or #2098
Closed

Support for fractional seconds in epoch definition #2084

jonathan-brandenburg-metecs opened this issue Apr 11, 2022 · 1 comment · Fixed by #2088 or #2098
Milestone

Comments

@jonathan-brandenburg-metecs
Copy link

jonathan-brandenburg-metecs commented Apr 11, 2022

Would a change to accept fractional seconds for the time epoch be accepted into cFE?

cFE supports setting the epoch of time with a granularity of seconds. Here is a relevant extract from sample_mission_cfg.h:

/**
**  \cfetimecfg Default EPOCH Values
**
**  \par Description:
**      Default ground time epoch values
**      Note: these values are used only by the CFE_TIME_Print() API function
**
**  \par Limits
**      Year - must be within 136 years
**      Day - Jan 1 = 1, Feb 1 = 32, etc.
**      Hour - 0 to 23
**      Minute - 0 to 59
**      Second - 0 to 59
*/
#define CFE_MISSION_TIME_EPOCH_YEAR   1980
#define CFE_MISSION_TIME_EPOCH_DAY    1
#define CFE_MISSION_TIME_EPOCH_HOUR   0
#define CFE_MISSION_TIME_EPOCH_MINUTE 0
#define CFE_MISSION_TIME_EPOCH_SECOND 0

It seems the definition of a commonly used epoch, J2000, contains fractional seconds: January 1, 2000, 11:58:55.816 UTC

As this issue is written, I've locally modified CFE_TIME_Print() to account for fractional seconds using a CFE_MISSION_TIME_EPOCH_MICROS macro, defined in this example to 816000. I have not yet written the unit tests. Here is a fragment from cfe_time_api.c:

    /*
    ** Convert the cFE time (offset from epoch) into calendar time...
    */
    NumberOfMicros = CFE_TIME_Sub2MicroSecs(TimeToPrint.Subseconds) + CFE_MISSION_TIME_EPOCH_MICROS;

    NumberOfMinutes = (NumberOfMicros / 60000000) + (TimeToPrint.Seconds / 60) + CFE_MISSION_TIME_EPOCH_MINUTE;
    NumberOfMicros = NumberOfMicros % 60000000;

    NumberOfSeconds = (NumberOfMicros / 1000000) + (TimeToPrint.Seconds % 60) + CFE_MISSION_TIME_EPOCH_SECOND;
    NumberOfMicros = NumberOfMicros % 1000000;

    /*
    ** Adding the epoch "seconds" after computing the minutes avoids
    **    overflow problems when the input time value (seconds) is
    **    at, or near, 0xFFFFFFFF...
    */

    while (NumberOfSeconds >= 60)
    {
        NumberOfMinutes++;
        NumberOfSeconds -= 60;
    }
@skliper skliper added the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Apr 11, 2022
@astrogeco astrogeco removed the CCB:Ready Ready for discussion at the Configuration Control Board (CCB) label Apr 13, 2022
@astrogeco
Copy link
Contributor

astrogeco commented Apr 13, 2022

CCB:2022-04-13

  • rollover concerns need to make sure users stay within the bounds

astrogeco added a commit that referenced this issue May 2, 2022
Fix #2084, Add support for fractional seconds in epoch
astrogeco added a commit that referenced this issue May 2, 2022
Fix #2084, Add support for fractional seconds in epoch

Apply clang-format
astrogeco added a commit that referenced this issue May 2, 2022
Fix #2084, Add support for fractional seconds in epoch

Apply clang-format
@skliper skliper added this to the Draco milestone Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants