Updated CCSDS CuC Functions
This commit is contained in:
@ -428,7 +428,7 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from, size_t
|
||||
from++;
|
||||
ReturnValue_t result = convertFromCUC(to, pField, from, foundLength, maxLength - 1);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
if (foundLength != NULL) {
|
||||
if (foundLength != nullptr) {
|
||||
*foundLength += 1;
|
||||
}
|
||||
}
|
||||
@ -588,18 +588,18 @@ ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, const uint8
|
||||
uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1;
|
||||
uint8_t nFine = (pField & 0b11);
|
||||
size_t totalLength = nCoarse + nFine;
|
||||
if (foundLength != NULL) {
|
||||
if (foundLength != nullptr) {
|
||||
*foundLength = totalLength;
|
||||
}
|
||||
if (totalLength > maxLength) {
|
||||
return LENGTH_MISMATCH;
|
||||
}
|
||||
for (int count = 0; count < nCoarse; count++) {
|
||||
secs += *from << ((nCoarse * 8 - 8) * (1 + count));
|
||||
for (int count = nCoarse; count > 0; count--) {
|
||||
secs += *from << (count * 8 - 8);
|
||||
from++;
|
||||
}
|
||||
for (int count = 0; count < nFine; count++) {
|
||||
subSeconds += *from << ((nFine * 8 - 8) * (1 + count));
|
||||
for (int count = nFine; count > 0; count--) {
|
||||
subSeconds += *from << (count * 8 - 8);
|
||||
from++;
|
||||
}
|
||||
// Move to POSIX epoch.
|
||||
|
@ -161,18 +161,37 @@ class CCSDSTime : public HasReturnvaluesIF {
|
||||
*/
|
||||
static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from, size_t *foundLength,
|
||||
size_t maxLength);
|
||||
|
||||
/**
|
||||
* @brief Currently unsupported conversion due to leapseconds
|
||||
*
|
||||
* @param to Time Of Day (UTC)
|
||||
* @param from Buffer to take the CUC from
|
||||
* @param length Length of buffer
|
||||
* @return ReturnValue_t UNSUPPORTED_TIME_FORMAT in any case ATM
|
||||
*/
|
||||
static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length);
|
||||
|
||||
/**
|
||||
* @brief Converts from CCSDS CUC to timeval
|
||||
*
|
||||
* If input is CCSDS Epoch this is TAI! -> No leapsecond support.
|
||||
*
|
||||
* Currently, it only supports seconds + 2 Byte Subseconds (1/65536 seconds)
|
||||
*
|
||||
*
|
||||
* @param to Timeval to write the result to
|
||||
* @param from Buffer to read from
|
||||
* @param foundLength Length found by this function (can be nullptr if unused)
|
||||
* @param maxLength Max length of the buffer to be read
|
||||
* @return ReturnValue_t - RETURN_OK if successful
|
||||
* - LENGTH_MISMATCH if expected length is larger than maxLength
|
||||
*/
|
||||
static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from, size_t *foundLength,
|
||||
size_t maxLength);
|
||||
|
||||
static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField, uint8_t const *from,
|
||||
size_t *foundLength, size_t maxLength);
|
||||
|
||||
static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from, size_t *foundLength,
|
||||
size_t maxLength);
|
||||
|
||||
static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField, uint8_t const *from,
|
||||
size_t *foundLength, size_t maxLength);
|
||||
|
||||
|
Reference in New Issue
Block a user