lets not forget error handling
This commit is contained in:
parent
0cfe559b93
commit
0e2fa8dc83
@ -23,7 +23,10 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
||||
}
|
||||
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 =
|
||||
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(¤tTime);
|
||||
ReturnValue_t result = Clock::getClock_timeval(¤tTime);
|
||||
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(×hiftNanos, currentPacket.getUserData(), &deserLen,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
result = SerializeAdapter::deSerialize(×hiftNanos, 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);
|
||||
}
|
||||
default:
|
||||
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
||||
|
Loading…
Reference in New Issue
Block a user