Skip to content
Snippets Groups Projects
Commit 1dc7fcf0 authored by Theodoros Katzalis's avatar Theodoros Katzalis
Browse files

Some `int` types changed to `uint` and the comments are updated

parent ce0b423b
No related branches found
No related tags found
No related merge requests found
...@@ -36,10 +36,10 @@ struct TimeAndDate { ...@@ -36,10 +36,10 @@ struct TimeAndDate {
*/ */
class TimeHelper { class TimeHelper {
private: private:
int SecondsPerMinute = 60; uint8_t SecondsPerMinute = 60;
int SecondsPerHour = 3600; uint16_t SecondsPerHour = 3600;
int SecondsPerDay = 86400; uint32_t SecondsPerDay = 86400;
int DaysOfMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; uint8_t DaysOfMonth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/** /**
* @param year The year that will be examined if it is a leap year(366 days) * @param year The year that will be examined if it is a leap year(366 days)
...@@ -51,9 +51,13 @@ private: ...@@ -51,9 +51,13 @@ private:
* Convert UTC date to elapsed seconds since Unix epoch(1/1/1970 00:00:00). This is a * Convert UTC date to elapsed seconds since Unix epoch(1/1/1970 00:00:00). This is a
* reimplemented mktime() of <ctime> library in an embedded systems way * reimplemented mktime() of <ctime> library in an embedded systems way
* *
* Note:
* This function can convert UTC dates after 1 January 2019
*
* @param TimeInfo the time information/data from the RTC(UTC format) * @param TimeInfo the time information/data from the RTC(UTC format)
* @return the elapsed seconds between a given UTC date(after the Unix epoch) and Unix epoch * @return the elapsed seconds between a given UTC date(after the Unix epoch) and Unix epoch
* @todo change the epoch for computer-efficiency * @todo check if we need to change the epoch to ,the recommended from the standard, 1 January
* 1958
*/ */
uint32_t mkUTCtime(struct TimeAndDate &TimeInfo); uint32_t mkUTCtime(struct TimeAndDate &TimeInfo);
...@@ -61,9 +65,13 @@ private: ...@@ -61,9 +65,13 @@ private:
* Convert elapsed seconds since Unix epoch to UTC date. This is a reimplemented gmtime() of * Convert elapsed seconds since Unix epoch to UTC date. This is a reimplemented gmtime() of
* <ctime> library in an embedded systems way * <ctime> library in an embedded systems way
* *
* Note:
* This function can convert elapsed seconds after 1 January 2019 since Unix epoch
*
* @param seconds elapsed seconds since Unix epoch * @param seconds elapsed seconds since Unix epoch
* @return the UTC date based on the /p * @return the UTC date based on the /p
* @todo change the epoch for computer efficiency * @todo check if we need to change the epoch to ,the recommended from the standard, 1 January
* 1958
*/ */
struct TimeAndDate utcTime(uint32_t seconds); struct TimeAndDate utcTime(uint32_t seconds);
...@@ -80,7 +88,6 @@ public: ...@@ -80,7 +88,6 @@ public:
* day` segments. The P-field won't be included in the code, because as the ECSS standards * day` segments. The P-field won't be included in the code, because as the ECSS standards
* claims, it can be just implicitly declared. * claims, it can be just implicitly declared.
* @param TimeInfo is the data provided from RTC(Real Time Clock) * @param TimeInfo is the data provided from RTC(Real Time Clock)
* @todo check if we need to define other epoch than the 1 January 1970
* @todo time security for critical time operations * @todo time security for critical time operations
* @todo declare the implicit P-field * @todo declare the implicit P-field
* @todo check if we need milliseconds * @todo check if we need milliseconds
...@@ -90,8 +97,9 @@ public: ...@@ -90,8 +97,9 @@ public:
/** /**
* Parse the CDS time format(3.3 in CCSDS 301.0-B-4 standard) * Parse the CDS time format(3.3 in CCSDS 301.0-B-4 standard)
* *
* @param seconds elapsed seconds since Unix epoch * @param data time information provided from the ground segment
* @return the UTC date based on the /p * @param length the size of the time information
* @return the UTC date
*/ */
static struct TimeAndDate parseCDStimeFormat(const uint8_t *data, uint8_t length); static struct TimeAndDate parseCDStimeFormat(const uint8_t *data, uint8_t length);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment