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 5 additions and 3 deletions
Showing only changes of commit aff6bb673b - Show all commits

View File

@ -52,8 +52,8 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
positiveShift = false;
}
timeval offset{};
offset.tv_sec = std::abs(timeshiftNanos) / 1000000000;
offset.tv_usec = (std::abs(timeshiftNanos) % 1000000000) / 1000;
offset.tv_sec = std::abs(timeshiftNanos) / NANOS_PER_SECOND;
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
offset.tv_usec = (std::abs(timeshiftNanos) % NANOS_PER_SECOND) / 1000;
timeval newTime;
if (positiveShift) {

View File

@ -7,9 +7,11 @@ class Service9TimeManagement : public PusServiceBase {
public:
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_9;
static constexpr uint32_t NANOS_PER_SECOND= 1'000'000'000;
//!< Clock has been set. P1: old timeval seconds. P2: new timeval seconds.
static constexpr Event CLOCK_SET = MAKE_EVENT(0, severity::INFO);
//!< Clock dump event. P1: timeval seconds P2: timeval milliseconds.
//!< Clock dump event. P1: timeval seconds P2: timeval microseconds.
static constexpr Event CLOCK_DUMP = MAKE_EVENT(1, severity::INFO);
//!< Clock could not be set. P1: Returncode.
static constexpr Event CLOCK_SET_FAILURE = MAKE_EVENT(2, severity::LOW);