implement relative timeshift #173

Merged
muellerr merged 10 commits from time-service-relative-timeshift into develop 2024-04-09 13:31:13 +02:00
2 changed files with 30 additions and 0 deletions
Showing only changes of commit 0cfe559b93 - Show all commits

View File

@ -4,6 +4,7 @@
#include "fsfw/events/EventManagerIF.h"
#include "fsfw/pus/servicepackets/Service9Packets.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/CCSDSTime.h"
@ -28,6 +29,34 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs);
return returnvalue::OK;
muellerr marked this conversation as resolved Outdated

either still dump milliseconds for P2 or change the description of the event

either still dump milliseconds for P2 or change the description of the event
}
case Subservice::RELATIVE_TIMESHIFT: {
timeval currentTime;
Clock::getClock_timeval(&currentTime);
if (currentPacket.getUserDataLen() != 8) {
return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA;
}
size_t deserLen = 8;
int64_t timeshiftNanos = 0;
SerializeAdapter::deSerialize(&timeshiftNanos, currentPacket.getUserData(), &deserLen,
SerializeIF::Endianness::NETWORK);
bool positiveShift = true;
if (timeshiftNanos < 0) {
positiveShift = false;
}
timeval offset{};
offset.tv_sec = std::abs(timeshiftNanos) / 1000000000;
offset.tv_usec = (std::abs(timeshiftNanos) % 1000000000) / 1000;
timeval newTime;
if (positiveShift) {
newTime = currentTime + offset;
} else {
newTime = currentTime - offset;
muellerr marked this conversation as resolved Outdated

my man refusing to use 1e-9 so that one has to count the 0 individually

my man refusing to use 1e-9 so that one has to count the 0 individually

Isn't that a float/double implicitely? WE are using C++17 anyway, we can just use 1'000'000'000 I guess

Isn't that a float/double implicitely? WE are using C++17 anyway, we can just use 1'000'000'000 I guess

1e9 is what i meant

1e9 is what i meant
}
Clock::setClock(&newTime);
return returnvalue::OK;
}
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}

View File

@ -36,6 +36,7 @@ class Service9TimeManagement : public PusServiceBase {
enum Subservice {
SET_TIME = 128, //!< [EXPORT] : [COMMAND] Time command in ASCII, CUC or CDS format
DUMP_TIME = 129,
RELATIVE_TIMESHIFT = 130,
};
};