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

CFE_TIME_GetTime() information seems incorrect? #53

Closed
SweeWarman opened this issue Mar 10, 2020 · 4 comments
Closed

CFE_TIME_GetTime() information seems incorrect? #53

SweeWarman opened this issue Mar 10, 2020 · 4 comments
Labels

Comments

@SweeWarman
Copy link

SweeWarman commented Mar 10, 2020

A question related to the use of the time service provided by cfe.

I am trying to get time information using the API provided by cfe as follows:

CFE_TIME_SysTime_t time;
time = CFE_TIME_GetTime();

And I print it as follows:

char buffer[500] = {0};
CFE_TIME_Print(buffer,time);
OS_printf("%s\n",buffer);

But the printed year and time information seems to be incorrect. It indicates some value in 1980 as: 1980-012-14:03:20.00000. Also, when I launch cfe (core-cpu1), I see the following output which indicates the time starting in 2030 and then changing to some value in 1980.

2030-069-17:55:07.13648 SB internal message format: CCSDS Space Packet Protocol version 1
2030-069-17:55:07.13649 ES Startup: Calling CFE_TIME_EarlyInit
1980-012-14:03:20.00000 ES Startup: Calling CFE_TBL_EarlyInit
1980-012-14:03:20.00021 ES Startup: Calling CFE_FS_EarlyInit

Could someone please explain how I could obtain the correct current time information using the cFE APIs without having to resort to using functions in time.h?

Thanks!

@jphickey
Copy link
Contributor

correct current time information using the cFE APIs

This depends on what is considered "correct" ....

The CFE_TIME functions do not directly use the CPU's real time clock. Rather, CFE TIME tracks a notion of "MET" (mission elapsed time) and combines this with the "mission epoch" (CFE_MISSION_TIME_EPOCH_YEAR, CFE_MISSION_TIME_EPOCH_DAY, etc) and the spacecraft time correction factor (SCTF) to produce an estimate of "wall time".

As you noted, the default epoch is 1980, and if no SCTF is set, this is the value one will get from CFE_TIME. It expects to get a proper value for these in the incoming messages (time at tone etc).

@skliper
Copy link
Contributor

skliper commented Mar 15, 2020

If you want time from the underlying OS, see OS_GetLocalTime (and OS_SetLocalTime) that abstract time.h. Note this is typically not what missions use for general time management (cFE Time Services).

@skliper
Copy link
Contributor

skliper commented Mar 16, 2020

Note the cFE User's Guide does attempt to document mission time management and related configuration options (make usersguide from top level bundle).

@jphickey
Copy link
Contributor

One possible suggestion/consideration - rather than always initializing the STCF value to zero, as it does today, it could query the PSP for the initial value.

In that case a "development" PSP like pc-linux, which almost certainly is NOT going to get time at tone signals to make it correct, could at least pre-initialize this value from the OS clock so that the log timestamps don't always just show 1980.

Other PSPs which do not have a real time reference and/or do not want to use it can continue initializing STCF to zero and relying on time at tone signals, as they do today.

chillfig pushed a commit to chillfig/cFS that referenced this issue Mar 17, 2022
A local buffer structure should be cleared/memset
to 0 before being passed along.
chillfig pushed a commit to chillfig/cFS that referenced this issue Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants