Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
f0d29c20
Commit
f0d29c20
authored
5 years ago
by
thodkatz
Browse files
Options
Downloads
Patches
Plain Diff
Update documentation and define leap seconds
parent
a58307d6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/Helpers/TimeHelper.hpp
+12
-8
12 additions, 8 deletions
inc/Helpers/TimeHelper.hpp
src/Helpers/TimeHelper.cpp
+3
-2
3 additions, 2 deletions
src/Helpers/TimeHelper.cpp
with
15 additions
and
10 deletions
inc/Helpers/TimeHelper.hpp
+
12
−
8
View file @
f0d29c20
...
...
@@ -8,6 +8,7 @@
#define SECONDS_PER_MINUTE 60u
#define SECONDS_PER_HOUR 3600u
#define SECONDS_PER_DAY 86400u
#define LEAP_SECONDS 27
/**
* This class formats the spacecraft time and cooperates closely with the ST[09] time management.
...
...
@@ -20,10 +21,10 @@
* T-Field. The T-Field is consisted of two segments: 1) the `DAY` and the 2) `ms of day` segments. The P-field won't
* be included in the code, because as the ECSS standards claims, it can be just implicitly declared.
*
* The CUC
time forma
t consists of two main fields: the time code preamble field
(P-field) and the time specification
* field(T-field). The T-Field contains the value of the time unit and the designer
decides what the time unit will
* be, so this is a subject for discussion. The recommended time unit from the
standard is the second and it is
* probably the best solution for accuracy.
* The CUC
is TAI-based (TAI: International Atomic Time). I
t consists of two main fields: the time code preamble field
*
(P-field) and the time specification
field(T-field). The T-Field contains the value of the time unit and the designer
*
decides what the time unit will
be, so this is a subject for discussion. The recommended time unit from the
*
standard is the second and it is
probably the best solution for accuracy.
*
* @notes
* The defined epoch for both time formats is 1 January 1958 00:00:00
...
...
@@ -102,11 +103,14 @@ public:
*
* Converts a UTC date to CUC time format.
*
* @note
* @note
s
* The T-field is specified for the seconds passed from the defined epoch 1 January 1958. We use 4 octets(32
* bits) for the time unit(seconds) because 32 bits for the seconds are enough to count 136 years! But if we use 24
* bits) for the time unit
(seconds) because 32 bits for the seconds are enough to count 136 years! But if we use 24
* bits for the seconds then it will count 0,5 years and this isn't enough. Remember we can use only integers
* numbers of octets for the time unit(second)
* numbers of octets for the time unit (second)
*
* The CUC time format doesn't include leap seconds, so we need to add them because we assume that
* the RTC will provide UTC format.
*
* @param TimeInfo is the data provided from RTC (UTC)
* @return TimeFormat the CUC time format. More specific, 32 bits are used for the T-field (seconds since 1/1/1958)
...
...
@@ -122,7 +126,7 @@ public:
* fixed size of 32 bits
* @return the UTC date
*/
static
TimeAndDate
parseCUCtimeFormat
(
const
uint8_t
*
data
);
static
TimeAndDate
parseCUCtimeFormat
(
uint8_t
*
data
);
};
#endif // ECSS_SERVICES_TIMEHELPER_HPP
This diff is collapsed.
Click to expand it.
src/Helpers/TimeHelper.cpp
+
3
−
2
View file @
f0d29c20
...
...
@@ -127,12 +127,13 @@ TimeAndDate TimeHelper::parseCDStimeFormat(const uint8_t* data) {
}
uint32_t
TimeHelper
::
generateCUCtimeFormat
(
struct
TimeAndDate
&
TimeInfo
)
{
return
utcToSeconds
(
TimeInfo
);
return
(
utcToSeconds
(
TimeInfo
)
+
LEAP_SECONDS
)
;
}
TimeAndDate
TimeHelper
::
parseCUCtimeFormat
(
const
uint8_t
*
data
)
{
TimeAndDate
TimeHelper
::
parseCUCtimeFormat
(
uint8_t
*
data
)
{
uint32_t
seconds
=
((
static_cast
<
uint32_t
>
(
data
[
0
]))
<<
24
)
|
((
static_cast
<
uint32_t
>
(
data
[
1
])))
<<
16
|
((
static_cast
<
uint32_t
>
(
data
[
2
])))
<<
8
|
(
static_cast
<
uint32_t
>
(
data
[
3
]));
seconds
-=
LEAP_SECONDS
;
return
secondsToUTC
(
seconds
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment