implement relative timeshift #173

Merged
muellerr merged 10 commits from time-service-relative-timeshift into develop 2024-04-09 13:31:13 +02:00
Showing only changes of commit 0e2fa8dc83 - Show all commits

View File

@ -23,7 +23,10 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
}

if we are doing this twice, why did we not use the CLOCK_SET event then? it already contained old and new time. or are we really interessted in microseconds here?

if we are doing this twice, why did we not use the CLOCK_SET event then? it already contained old and new time. or are we really interessted in microseconds here?

events are cheap, and why lose resolution here? The correct approach probably would be to delete the weird CLOCK_SET event. If we still want to distinguish events which come from time changes, we could introduce, TIME_DUMP_BEFORE_CLOCK_UPDATE and TIME_DUMP_AFTER_CLOCK_UPDATE..

events are cheap, and why lose resolution here? The correct approach probably would be to delete the weird `CLOCK_SET` event. If we still want to distinguish events which come from time changes, we could introduce, `TIME_DUMP_BEFORE_CLOCK_UPDATE` and `TIME_DUMP_AFTER_CLOCK_UPDATE`..

I would advise splitting the events in those two types yes. Otherwise, this might be confusing for the operator. Calculating the time delta on ground is going to be more tricky now (but still possible if we store the parameter tm as actual tm). Maybe ask OPS what they prefer here

I would advise splitting the events in those two types yes. Otherwise, this might be confusing for the operator. Calculating the time delta on ground is going to be more tricky now (but still possible if we store the parameter tm as actual tm). Maybe ask OPS what they prefer here

done

done
case Subservice::DUMP_TIME: {
timeval newTime;
Clock::getClock_timeval(&newTime);
ReturnValue_t result = Clock::getClock_timeval(&newTime);
if (result != returnvalue::OK) {
return result;
}
uint32_t subsecondMs =
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
static_cast<uint32_t>(std::floor(static_cast<double>(newTime.tv_usec) / 1000.0));
triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs);
@ -31,15 +34,21 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
}
case Subservice::RELATIVE_TIMESHIFT: {
timeval currentTime;
Clock::getClock_timeval(&currentTime);
ReturnValue_t result = Clock::getClock_timeval(&currentTime);
if (result != returnvalue::OK) {
return result;
}
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);
result = SerializeAdapter::deSerialize(&timeshiftNanos, currentPacket.getUserData(),
&deserLen, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
bool positiveShift = true;
if (timeshiftNanos < 0) {
positiveShift = false;
@ -54,8 +63,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
} else {
newTime = currentTime - offset;
}
Clock::setClock(&newTime);
return returnvalue::OK;
return Clock::setClock(&newTime);
}
muellerr marked this conversation as resolved Outdated

see above

see above
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;

the same here

the same here