From 863c0af2a1488045714b3ac1414889414c06d87a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 13 Jul 2023 10:53:58 +0200 Subject: [PATCH] what the hell is wrong with the thing? --- linux/acs/StrComHandler.cpp | 19 ++++++++++++++++--- mission/acs/str/StarTrackerHandler.cpp | 13 +++++++------ mission/acs/str/strHelpers.h | 2 +- tmtc | 2 +- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/linux/acs/StrComHandler.cpp b/linux/acs/StrComHandler.cpp index 5ae00c94..f070efd4 100644 --- a/linux/acs/StrComHandler.cpp +++ b/linux/acs/StrComHandler.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -23,6 +24,8 @@ extern "C" { using namespace returnvalue; +static constexpr bool PACKET_WIRETAPPING = false; + StrComHandler::StrComHandler(object_id_t objectId) : SystemObject(objectId) { lock = MutexFactory::instance()->createMutex(); semaphore.acquire(); @@ -51,7 +54,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) { switch (state) { case InternalState::POLL_ONE_REPLY: { // Stopwatch watch; - replyTimeout.setTimeout(200); + replyTimeout.setTimeout(400); replyResult = readOneReply(static_cast(state)); { MutexGuard mg(lock); @@ -680,6 +683,10 @@ ReturnValue_t StrComHandler::sendMessage(CookieIF* cookie, const uint8_t* sendDa const uint8_t* txFrame; size_t frameLen; datalinkLayer.encodeFrame(sendData, sendLen, &txFrame, frameLen); + if(PACKET_WIRETAPPING) { + sif::debug << "Sendign STR frame" << std::endl; + arrayprinter::print(txFrame, frameLen); + } ssize_t bytesWritten = write(serialPort, txFrame, frameLen); if (bytesWritten != static_cast(frameLen)) { sif::warning << "StrComHandler: Sending packet failed" << std::endl; @@ -782,8 +789,10 @@ ReturnValue_t StrComHandler::handleSerialReception() { << std::endl; return FAILED; } else if (bytesRead > 0) { - // sif::info << "Received " << bytesRead << " bytes from the STR" << std::endl; - // arrayprinter::print(recBuf.data(), bytesRead); + if(PACKET_WIRETAPPING) { + sif::info << "Received " << bytesRead << " bytes from the STR" << std::endl; + arrayprinter::print(recBuf.data(), bytesRead); + } datalinkLayer.feedData(recBuf.data(), bytesRead); } return OK; @@ -797,6 +806,10 @@ ReturnValue_t StrComHandler::readOneReply(uint32_t failParameter) { handleSerialReception(); result = datalinkLayer.checkRingBufForFrame(&replyPtr, replyLen); if (result == returnvalue::OK) { + if(PACKET_WIRETAPPING) { + sif::debug << "Received STR reply frame" << std::endl; + arrayprinter::print(replyPtr, replyLen); + } return returnvalue::OK; } else if (result != ArcsecDatalinkLayer::DEC_IN_PROGRESS) { triggerEvent(STR_HELPER_DEC_ERROR, result, failParameter); diff --git a/mission/acs/str/StarTrackerHandler.cpp b/mission/acs/str/StarTrackerHandler.cpp index 004d5f34..3dee6a78 100644 --- a/mission/acs/str/StarTrackerHandler.cpp +++ b/mission/acs/str/StarTrackerHandler.cpp @@ -352,7 +352,7 @@ ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t } case (FwBootState::SET_TIME): { bootState = FwBootState::WAIT_FOR_EXECUTION; - *id = startracker::SET_TIME; + *id = startracker::SET_TIME_FROM_SYS_TIME; return buildCommandFromCommand(*id, nullptr, 0); } case (FwBootState::LOGLEVEL): { @@ -465,7 +465,8 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi preparePingRequest(); return returnvalue::OK; } - case (startracker::SET_TIME): { + case (startracker::SET_TIME_FROM_SYS_TIME): { + // Might be buggy, need more answers from arcsec... SetTimeActionRequest setTimeRequest{}; timeval tv; Clock::getClock(&tv); @@ -674,7 +675,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LOGLEVEL, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::SET_TIME, 3, nullptr, + this->insertInCommandAndReplyMap(startracker::SET_TIME_FROM_SYS_TIME, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LOGSUBSCRIPTION, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); @@ -890,7 +891,7 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema switch (startracker::getReplyFrameType(start)) { case TMTC_ACTIONREPLY: { *foundLen = remainingSize; - arrayprinter::print(start, remainingSize); + // arrayprinter::print(start, remainingSize); return scanForActionReply(startracker::getId(start), foundId); break; } @@ -923,7 +924,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, ReturnValue_t result = returnvalue::OK; switch (id) { - case (startracker::SET_TIME): { + case (startracker::SET_TIME_FROM_SYS_TIME): { result = handleActionReply(packet); break; } @@ -1394,7 +1395,7 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(uint8_t replyId, DeviceComm break; } case (ARC_ACTION_REQ_SETTIME_ID): { - *foundId = startracker::SET_TIME; + *foundId = startracker::SET_TIME_FROM_SYS_TIME; break; } case (startracker::ID::CHECKSUM): { diff --git a/mission/acs/str/strHelpers.h b/mission/acs/str/strHelpers.h index 241f2783..894ceac5 100644 --- a/mission/acs/str/strHelpers.h +++ b/mission/acs/str/strHelpers.h @@ -326,7 +326,7 @@ static const DeviceCommandId_t DEBUG_CAMERA = 83; static const DeviceCommandId_t FIRMWARE_UPDATE = 84; static const DeviceCommandId_t DISABLE_TIMESTAMP_GENERATION = 85; static const DeviceCommandId_t ENABLE_TIMESTAMP_GENERATION = 86; -static constexpr DeviceCommandId_t SET_TIME = 87; +static constexpr DeviceCommandId_t SET_TIME_FROM_SYS_TIME = 87; static const DeviceCommandId_t NONE = 0xFFFFFFFF; static const uint32_t VERSION_SET_ID = REQ_VERSION; diff --git a/tmtc b/tmtc index 9be81f17..1f2f2aac 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 9be81f1725004b55e937718fbaddc4f4e4e74081 +Subproject commit 1f2f2aac13b0b32c22f0a75e557743ad32f7dc70