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: {
|
case Subservice::DUMP_TIME: {
|
||||||
timeval newTime;
|
timeval newTime;
|
||||||
Clock::getClock_timeval(&newTime);
|
ReturnValue_t result = Clock::getClock_timeval(&newTime);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
uint32_t subsecondMs =
|
uint32_t subsecondMs =
|
||||||
static_cast<uint32_t>(std::floor(static_cast<double>(newTime.tv_usec) / 1000.0));
|
static_cast<uint32_t>(std::floor(static_cast<double>(newTime.tv_usec) / 1000.0));
|
||||||
triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs);
|
triggerEvent(CLOCK_DUMP, newTime.tv_sec, subsecondMs);
|
||||||
@ -31,15 +34,21 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
|||||||
}
|
}
|
||||||
case Subservice::RELATIVE_TIMESHIFT: {
|
case Subservice::RELATIVE_TIMESHIFT: {
|
||||||
timeval currentTime;
|
timeval currentTime;
|
||||||
Clock::getClock_timeval(¤tTime);
|
ReturnValue_t result = Clock::getClock_timeval(¤tTime);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentPacket.getUserDataLen() != 8) {
|
if (currentPacket.getUserDataLen() != 8) {
|
||||||
return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA;
|
return AcceptsTelecommandsIF::ILLEGAL_APPLICATION_DATA;
|
||||||
}
|
}
|
||||||
size_t deserLen = 8;
|
size_t deserLen = 8;
|
||||||
int64_t timeshiftNanos = 0;
|
int64_t timeshiftNanos = 0;
|
||||||
SerializeAdapter::deSerialize(×hiftNanos, currentPacket.getUserData(), &deserLen,
|
result = SerializeAdapter::deSerialize(×hiftNanos, currentPacket.getUserData(),
|
||||||
SerializeIF::Endianness::NETWORK);
|
&deserLen, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
bool positiveShift = true;
|
bool positiveShift = true;
|
||||||
if (timeshiftNanos < 0) {
|
if (timeshiftNanos < 0) {
|
||||||
positiveShift = false;
|
positiveShift = false;
|
||||||
@ -54,8 +63,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
|
|||||||
} else {
|
} else {
|
||||||
newTime = currentTime - offset;
|
newTime = currentTime - offset;
|
||||||
}
|
}
|
||||||
Clock::setClock(&newTime);
|
return Clock::setClock(&newTime);
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
||||||
|
Loading…
Reference in New Issue
Block a user