From d424d85f6d0699a7f9da63f28e973a2855873243 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 3 Nov 2020 17:07:48 +0100 Subject: [PATCH] sizet changes and indentation --- timemanager/CCSDSTime.cpp | 18 +-- timemanager/CCSDSTime.h | 16 +-- timemanager/Clock.h | 256 +++++++++++++++++++------------------- 3 files changed, 145 insertions(+), 145 deletions(-) diff --git a/timemanager/CCSDSTime.cpp b/timemanager/CCSDSTime.cpp index 6acd5539..aefcac2e 100644 --- a/timemanager/CCSDSTime.cpp +++ b/timemanager/CCSDSTime.cpp @@ -54,7 +54,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to, } ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, - const uint8_t* from, uint32_t length) { + const uint8_t* from, size_t length) { ReturnValue_t result; if (length > 0xFF) { return LENGTH_MISMATCH; @@ -72,7 +72,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, case CDS: return convertFromCDS(to, from, length); case CCS: { - uint32_t temp = 0; + size_t temp = 0; return convertFromCCS(to, from, &temp, length); } @@ -97,7 +97,7 @@ ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, } ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, - const uint8_t* from, uint32_t* foundLength, uint32_t maxLength) { + const uint8_t* from, size_t* foundLength, size_t maxLength) { uint8_t subsecondsLength = *from & 0b111; uint32_t totalLength = subsecondsLength + 8; if (maxLength < totalLength) { @@ -395,7 +395,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) { } ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, - uint32_t* foundLength, uint32_t maxLength) { + size_t* foundLength, size_t maxLength) { //We don't expect ascii here. SHOULDDO uint8_t codeIdentification = (*from >> 4); switch (codeIdentification) { @@ -413,7 +413,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, } ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from, - uint32_t* foundLength, uint32_t maxLength) { + size_t* foundLength, size_t maxLength) { if (maxLength < 1) { return INVALID_TIME_FORMAT; } @@ -491,7 +491,7 @@ ReturnValue_t CCSDSTime::convertTimevalToTimeOfDay(Clock::TimeOfDay_t* to, } ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, - uint32_t* foundLength, uint32_t maxLength) { + size_t* foundLength, size_t maxLength) { uint8_t pField = *from; from++; //Check epoch @@ -556,12 +556,12 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, } ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, - const uint8_t* from, uint32_t* foundLength, uint32_t maxLength) { + const uint8_t* from, size_t* foundLength, size_t maxLength) { uint32_t secs = 0; uint32_t subSeconds = 0; uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1; uint8_t nFine = (pField & 0b11); - uint32_t totalLength = nCoarse + nFine; + size_t totalLength = nCoarse + nFine; if (foundLength != NULL) { *foundLength = totalLength; } @@ -593,7 +593,7 @@ uint32_t CCSDSTime::subsecondsToMicroseconds(uint16_t subseconds) { } ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from, - uint32_t* foundLength, uint32_t maxLength) { + size_t* foundLength, size_t maxLength) { Clock::TimeOfDay_t tempTime; ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength, maxLength); diff --git a/timemanager/CCSDSTime.h b/timemanager/CCSDSTime.h index 29c9f8f5..e9e6957f 100644 --- a/timemanager/CCSDSTime.h +++ b/timemanager/CCSDSTime.h @@ -156,7 +156,7 @@ public: * - @c INVALID_TIME_FORMAT if the format or a value is invalid */ static ReturnValue_t convertFromCcsds(Clock::TimeOfDay_t *to, - uint8_t const *from, uint32_t length); + uint8_t const *from, size_t length); /** * not implemented yet @@ -166,31 +166,31 @@ public: * @return */ static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from, - uint32_t* foundLength, uint32_t maxLength); + size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from, - uint32_t* foundLength, uint32_t maxLength); + size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField, - uint8_t const *from, uint32_t* foundLength, uint32_t maxLength); + uint8_t const *from, size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from, - uint32_t* foundLength, uint32_t maxLength); + size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField, - uint8_t const *from, uint32_t* foundLength, uint32_t maxLength); + uint8_t const *from, size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from, - uint32_t* foundLength, uint32_t maxLength); + size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to, - uint8_t const *from, uint32_t* foundLength, uint32_t maxLength); + uint8_t const *from, size_t* foundLength, size_t maxLength); static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); diff --git a/timemanager/Clock.h b/timemanager/Clock.h index 82007795..f4ed847a 100644 --- a/timemanager/Clock.h +++ b/timemanager/Clock.h @@ -21,146 +21,146 @@ public: uint32_t usecond; //!< Microseconds, 0 .. 999999 } TimeOfDay_t; - /** - * This method returns the number of clock ticks per second. - * In RTEMS, this is typically 1000. - * @return The number of ticks. - * - * @deprecated, we should not worry about ticks, but only time - */ - static uint32_t getTicksPerSecond(void); - /** - * This system call sets the system time. - * To set the time, it uses a TimeOfDay_t struct. - * @param time The struct with the time settings to set. - * @return -@c RETURN_OK on success. Otherwise, the OS failure code - * is returned. - */ - static ReturnValue_t setClock(const TimeOfDay_t* time); - /** - * This system call sets the system time. - * To set the time, it uses a timeval struct. - * @param time The struct with the time settings to set. - * @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned. - */ - static ReturnValue_t setClock(const timeval* time); - /** - * This system call returns the current system clock in timeval format. - * The timval format has the fields @c tv_sec with seconds and @c tv_usec with - * microseconds since an OS-defined epoch. - * @param time A pointer to a timeval struct where the current time is stored. - * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. - */ - static ReturnValue_t getClock_timeval(timeval* time); + /** + * This method returns the number of clock ticks per second. + * In RTEMS, this is typically 1000. + * @return The number of ticks. + * + * @deprecated, we should not worry about ticks, but only time + */ + static uint32_t getTicksPerSecond(void); + /** + * This system call sets the system time. + * To set the time, it uses a TimeOfDay_t struct. + * @param time The struct with the time settings to set. + * @return -@c RETURN_OK on success. Otherwise, the OS failure code + * is returned. + */ + static ReturnValue_t setClock(const TimeOfDay_t* time); + /** + * This system call sets the system time. + * To set the time, it uses a timeval struct. + * @param time The struct with the time settings to set. + * @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned. + */ + static ReturnValue_t setClock(const timeval* time); + /** + * This system call returns the current system clock in timeval format. + * The timval format has the fields @c tv_sec with seconds and @c tv_usec with + * microseconds since an OS-defined epoch. + * @param time A pointer to a timeval struct where the current time is stored. + * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. + */ + static ReturnValue_t getClock_timeval(timeval* time); - /** - * Get the time since boot in a timeval struct - * - * @param[out] time A pointer to a timeval struct where the uptime is stored. - * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. - * - * @deprecated, I do not think this should be able to fail, use timeval getUptime() - */ - static ReturnValue_t getUptime(timeval* uptime); + /** + * Get the time since boot in a timeval struct + * + * @param[out] time A pointer to a timeval struct where the uptime is stored. + * @return @c RETURN_OK on success. Otherwise, the OS failure code is returned. + * + * @deprecated, I do not think this should be able to fail, use timeval getUptime() + */ + static ReturnValue_t getUptime(timeval* uptime); - static timeval getUptime(); + static timeval getUptime(); - /** - * Get the time since boot in milliseconds - * - * This value can overflow! Still, it can be used to calculate time intervalls - * between two calls up to 49 days by always using uint32_t in the calculation - * - * @param ms uptime in ms - * @return RETURN_OK on success. Otherwise, the OS failure code is returned. - */ - static ReturnValue_t getUptime(uint32_t* uptimeMs); + /** + * Get the time since boot in milliseconds + * + * This value can overflow! Still, it can be used to calculate time intervalls + * between two calls up to 49 days by always using uint32_t in the calculation + * + * @param ms uptime in ms + * @return RETURN_OK on success. Otherwise, the OS failure code is returned. + */ + static ReturnValue_t getUptime(uint32_t* uptimeMs); - /** - * Returns the time in microseconds since an OS-defined epoch. - * The time is returned in a 64 bit unsigned integer. - * @param time A pointer to a 64 bit unisigned integer where the data is stored. - * @return - * - @c RETURN_OK on success. - * - Otherwise, the OS failure code is returned. - */ - static ReturnValue_t getClock_usecs(uint64_t* time); - /** - * Returns the time in a TimeOfDay_t struct. - * @param time A pointer to a TimeOfDay_t struct. - * @return - * - @c RETURN_OK on success. - * - Otherwise, the OS failure code is returned. - */ - static ReturnValue_t getDateAndTime(TimeOfDay_t* time); + /** + * Returns the time in microseconds since an OS-defined epoch. + * The time is returned in a 64 bit unsigned integer. + * @param time A pointer to a 64 bit unisigned integer where the data is stored. + * @return + * - @c RETURN_OK on success. + * - Otherwise, the OS failure code is returned. + */ + static ReturnValue_t getClock_usecs(uint64_t* time); + /** + * Returns the time in a TimeOfDay_t struct. + * @param time A pointer to a TimeOfDay_t struct. + * @return + * - @c RETURN_OK on success. + * - Otherwise, the OS failure code is returned. + */ + static ReturnValue_t getDateAndTime(TimeOfDay_t* time); - /** - * Converts a time of day struct to POSIX seconds. - * @param time The time of day as input - * @param timeval The corresponding seconds since the epoch. - * @return - * - @c RETURN_OK on success. - * - Otherwise, the OS failure code is returned. - */ - static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from, - timeval* to); + /** + * Converts a time of day struct to POSIX seconds. + * @param time The time of day as input + * @param timeval The corresponding seconds since the epoch. + * @return + * - @c RETURN_OK on success. + * - Otherwise, the OS failure code is returned. + */ + static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from, + timeval* to); - /** - * Converts a time represented as seconds and subseconds since unix - * epoch to days since J2000 - * - * @param time seconds since unix epoch - * @param[out] JD2000 days since J2000 - * @return @c RETURN_OK - */ - static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000); + /** + * Converts a time represented as seconds and subseconds since unix + * epoch to days since J2000 + * + * @param time seconds since unix epoch + * @param[out] JD2000 days since J2000 + * @return @c RETURN_OK + */ + static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000); - /** - * Calculates and adds the offset between UTC and TT - * - * Depends on the leap seconds to be set correctly. - * - * @param utc timeval, corresponding to UTC time - * @param[out] tt timeval, corresponding to Terrestial Time - * @return - * - @c RETURN_OK on success - * - @c RETURN_FAILED if leapSeconds are not set - */ - static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt); + /** + * Calculates and adds the offset between UTC and TT + * + * Depends on the leap seconds to be set correctly. + * + * @param utc timeval, corresponding to UTC time + * @param[out] tt timeval, corresponding to Terrestial Time + * @return + * - @c RETURN_OK on success + * - @c RETURN_FAILED if leapSeconds are not set + */ + static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt); - /** - * Set the Leap Seconds since 1972 - * - * @param leapSeconds_ - * @return - * - @c RETURN_OK on success. - * - Otherwise, the OS failure code is returned. - */ - static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_); + /** + * Set the Leap Seconds since 1972 + * + * @param leapSeconds_ + * @return + * - @c RETURN_OK on success. + * - Otherwise, the OS failure code is returned. + */ + static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_); - /** - * Get the Leap Seconds since 1972 - * - * Must be set before! - * - * @param[out] leapSeconds_ - * @return - * - @c RETURN_OK on success. - * - Otherwise, the OS failure code is returned. - */ - static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); + /** + * Get the Leap Seconds since 1972 + * + * Must be set before! + * + * @param[out] leapSeconds_ + * @return + * - @c RETURN_OK on success. + * - Otherwise, the OS failure code is returned. + */ + static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); - /** - * Function to check and create the Mutex for the clock - * @return - * - @c RETURN_OK on success. - * - Otherwise @c RETURN_FAILED if not able to create one - */ - static ReturnValue_t checkOrCreateClockMutex(); + /** + * Function to check and create the Mutex for the clock + * @return + * - @c RETURN_OK on success. + * - Otherwise @c RETURN_FAILED if not able to create one + */ + static ReturnValue_t checkOrCreateClockMutex(); private: - static MutexIF* timeMutex; - static uint16_t leapSeconds; + static MutexIF* timeMutex; + static uint16_t leapSeconds; };