diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp index ed5c1fa75..b0fdb310d 100644 --- a/devicehandlers/DeviceHandlerBase.cpp +++ b/devicehandlers/DeviceHandlerBase.cpp @@ -1286,18 +1286,17 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, } void DeviceHandlerBase::buildInternalCommand(void) { -//Neither Raw nor Direct could build a command + /* Neither raw nor direct could build a command */ ReturnValue_t result = NOTHING_TO_SEND; DeviceCommandId_t deviceCommandId = NO_COMMAND_ID; if (mode == MODE_NORMAL) { result = buildNormalDeviceCommand(&deviceCommandId); if (result == BUSY) { - // so we can track misconfigurations - printWarningOrError(sif::OutputTypes::OUT_WARNING, - "buildInternalCommand", - HasReturnvaluesIF::RETURN_FAILED, - "Busy."); - result = NOTHING_TO_SEND; //no need to report this + /* So we can track misconfigurations */ + printWarningOrError(sif::OutputTypes::OUT_WARNING, "buildInternalCommand", + HasReturnvaluesIF::RETURN_FAILED, "Busy."); + /* No need to report this */ + result = NOTHING_TO_SEND; } } else if (mode == MODE_RAW) { @@ -1319,7 +1318,8 @@ void DeviceHandlerBase::buildInternalCommand(void) { deviceCommandId); if (iter == deviceCommandMap.end()) { result = COMMAND_NOT_SUPPORTED; - } else if (iter->second.isExecuting) { + } + else if (iter->second.isExecuting) { #if FSFW_DISABLE_PRINTOUT == 0 char output[36]; sprintf(output, "Command 0x%08x is executing", diff --git a/osal/host/Clock.cpp b/osal/host/Clock.cpp index 771474c7c..f0543c790 100644 --- a/osal/host/Clock.cpp +++ b/osal/host/Clock.cpp @@ -15,35 +15,34 @@ using SystemClock = std::chrono::system_clock; uint32_t Clock::getTicksPerSecond(void){ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl; + sif::warning << "Clock::getTicksPerSecond: Not implemented for host OSAL" << std::endl; +#else + sif::printWarning("Clock::getTicksPerSecond: Not implemented for host OSAL\n"); #endif - return 0; - //return CLOCKS_PER_SEC; - //uint32_t ticks = sysconf(_SC_CLK_TCK); - //return ticks; + /* To avoid division by zero */ + return 1; } ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { - // do some magic with chrono + /* I don't know why someone would need to set a clock which is probably perfectly fine on a + host system with internet access so this is not implemented for now. */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::setClock: not implemented yet" << std::endl; + sif::warning << "Clock::setClock: Not implemented for host OSAL" << std::endl; +#else + sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Clock::setClock(const timeval* time) { - // do some magic with chrono -#if defined(WIN32) - return HasReturnvaluesIF::RETURN_OK; -#elif defined(LINUX) - return HasReturnvaluesIF::RETURN_OK; -#else - -#endif + /* I don't know why someone would need to set a clock which is probably perfectly fine on a + host system with internet access so this is not implemented for now. */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; + sif::warning << "Clock::setClock: Not implemented for host OSAL" << std::endl; +#else + sif::printWarning("Clock::setClock: Not implemented for host OSAL\n"); #endif - return HasReturnvaluesIF::RETURN_FAILED; + return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t Clock::getClock_timeval(timeval* time) { @@ -76,10 +75,11 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) { } ReturnValue_t Clock::getClock_usecs(uint64_t* time) { - // do some magic with chrono -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl; -#endif + if(time == nullptr) { + return HasReturnvaluesIF::RETURN_FAILED; + } + using namespace std::chrono; + *time = duration_cast(system_clock::now().time_since_epoch()).count(); return HasReturnvaluesIF::RETURN_OK; } @@ -121,9 +121,9 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { - // do some magic with chrono (C++20!) - // Right now, the library doesn't have the new features yet. - // so we work around that for now. + /* Do some magic with chrono (C++20!) */ + /* Right now, the library doesn't have the new features to get the required values yet. + so we work around that for now. */ auto now = SystemClock::now(); auto seconds = std::chrono::time_point_cast(now); auto fraction = now - seconds; @@ -138,10 +138,6 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { time->second = timeInfo->tm_sec; auto usecond = std::chrono::duration_cast(fraction); time->usecond = usecond.count(); - -#if FSFW_CPP_OSTREAM_ENABLED == 1 - //sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl; -#endif return HasReturnvaluesIF::RETURN_OK; }