diff --git a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp b/bsp_q7s/devices/startracker/StarTrackerHandler.cpp deleted file mode 100644 index e5601ac0..00000000 --- a/bsp_q7s/devices/startracker/StarTrackerHandler.cpp +++ /dev/null @@ -1,2107 +0,0 @@ -#include "StarTrackerHandler.h" - -#include -#include -#include - -#include - -#include "OBSWConfig.h" -#include "StarTrackerJsonCommands.h" -extern "C" { -#include -#include -#include - -#include "common/misc.h" -} - -using json = nlohmann::json; - -StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - StrHelper* strHelper) - : DeviceHandlerBase(objectId, comIF, comCookie), - temperatureSet(this), - versionSet(this), - powerSet(this), - interfaceSet(this), - timeSet(this), - solutionSet(this), - histogramSet(this), - contrastSet(this), - checksumSet(this), - downloadCentroidSet(this), - downloadMatchedStar(this), - downloadDbImage(this), - downloadBlobPixel(this), - cameraSet(this), - limitsSet(this), - blobSet(this), - strHelper(strHelper) { - if (comCookie == nullptr) { - sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl; - } - if (strHelper == nullptr) { - sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl; - } - auto mqArgs = MqArgs(this->getObjectId()); - eventQueue = QueueFactory::instance()->createMessageQueue( - EventMessage::EVENT_MESSAGE_SIZE * 5, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); -} - -StarTrackerHandler::~StarTrackerHandler() {} - -ReturnValue_t StarTrackerHandler::initialize() { - ReturnValue_t result = RETURN_OK; - result = DeviceHandlerBase::initialize(); - if (result != RETURN_OK) { - return result; - } - - EventManagerIF* manager = ObjectManager::instance()->get(objects::EVENT_MANAGER); - if (manager == nullptr) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - ; - } - result = manager->registerListener(eventQueue->getId()); - if (result != RETURN_OK) { - return result; - } - result = manager->subscribeToEventRange(eventQueue->getId(), - event::getEventId(StrHelper::IMAGE_UPLOAD_FAILED), - event::getEventId(StrHelper::FPGA_UPLOAD_FAILED)); - if (result != RETURN_OK) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from " - " str helper" - << std::endl; -#endif - return ObjectManagerIF::CHILD_INIT_FAILED; - } - - result = strHelper->setComIF(communicationInterface); - if (result != RETURN_OK) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } - strHelper->setComCookie(comCookie); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, - const uint8_t* data, size_t size) { - ReturnValue_t result = RETURN_OK; - - switch (actionId) { - case (StarTracker::STOP_IMAGE_LOADER): { - strHelper->stopProcess(); - return EXECUTION_FINISHED; - } - case (StarTracker::SET_JSON_FILE_NAME): { - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - paramJsonFile = std::string(reinterpret_cast(data), size); - return EXECUTION_FINISHED; - } - default: - break; - } - - if (strHelperExecuting == true) { - return IMAGE_LOADER_EXECUTING; - } - - result = checkMode(actionId); - if (result != RETURN_OK) { - return result; - } - - // Intercept image loader commands which do not follow the common DHB communication flow - switch (actionId) { - case (StarTracker::UPLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startImageUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case (StarTracker::DOWNLOAD_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = - strHelper->startImageDownload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case (StarTracker::WRITE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeWriteCommand(data, size); - if (result != RETURN_OK) { - return result; - } - - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case (StarTracker::READ): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - result = executeReadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case (StarTracker::CHANGE_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case (StarTracker::CHANGE_FPGA_DOWNLOAD_FILE): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadFpgaImage(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case (StarTracker::SET_READ_FILENAME): { - if (size > MAX_FILE_NAME) { - return FILENAME_TOO_LONG; - } - strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); - return EXECUTION_FINISHED; - } - case (StarTracker::DOWNLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - result = executeFpgaDownloadCommand(data, size); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - case (StarTracker::UPLOAD_FPGA_IMAGE): { - result = DeviceHandlerBase::acceptExternalDeviceCommands(); - if (result != RETURN_OK) { - return result; - } - if (size > MAX_PATH_SIZE + MAX_FILE_NAME) { - return FILE_PATH_TOO_LONG; - } - result = strHelper->startFpgaUpload(std::string(reinterpret_cast(data), size)); - if (result != RETURN_OK) { - return result; - } - strHelperExecuting = true; - return EXECUTION_FINISHED; - } - default: - break; - } - return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size); -} - -void StarTrackerHandler::performOperationHook() { - EventMessage event; - for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == RETURN_OK; - result = eventQueue->receiveMessage(&event)) { - switch (event.getMessageId()) { - case EventMessage::EVENT_MESSAGE: - handleEvent(&event); - break; - default: - sif::debug << "CCSDSHandler::checkEvents: Did not subscribe to this event message" - << std::endl; - break; - } - } -} - -void StarTrackerHandler::doStartUp() { - switch (startupState) { - case StartupState::IDLE: - startupState = StartupState::CHECK_BOOT_STATE; - return; - case StartupState::BOOT_DELAY: - if (bootCountdown.hasTimedOut()) { - startupState = StartupState::LIMITS; - } - return; - case StartupState::DONE: - break; - default: - return; - } - setMode(_MODE_TO_ON); -} - -void StarTrackerHandler::doShutDown() { - // If star tracker is shutdown also stop all running processes in the image loader task - strHelper->stopProcess(); - setMode(_MODE_POWER_DOWN); -} - -void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; } - -ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - switch (internalState) { - case InternalState::TEMPERATURE_REQUEST: - *id = StarTracker::REQ_TEMPERATURE; - break; - default: - sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" - << std::endl; - break; - } - return buildCommandFromCommand(*id, NULL, 0); -} - -ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - if (mode != _MODE_START_UP) { - return NOTHING_TO_SEND; - } - switch (startupState) { - case StartupState::CHECK_BOOT_STATE: - *id = StarTracker::REQ_VERSION; - startupState = StartupState::WAIT_FOR_EXECUTION; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::BOOT: - *id = StarTracker::BOOT; - bootCountdown.setTimeout(BOOT_TIMEOUT); - startupState = StartupState::BOOT_DELAY; - return buildCommandFromCommand(*id, nullptr, 0); - case StartupState::LIMITS: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LIMITS; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::TRACKING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::TRACKING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MOUNTING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MOUNTING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CAMERA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CAMERA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::BLOB: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::BLOB; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::CENTROIDING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::CENTROIDING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::LISA: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::LISA; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::MATCHING: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::MATCHING; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::VALIDATION: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::VALIDATION; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - case StartupState::ALGO: - startupState = StartupState::WAIT_FOR_EXECUTION; - *id = StarTracker::ALGO; - return buildCommandFromCommand(*id, reinterpret_cast(paramJsonFile.c_str()), - paramJsonFile.size()); - default: - break; - } - return NOTHING_TO_SEND; -} - -ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - switch (deviceCommand) { - case (StarTracker::PING_REQUEST): { - preparePingRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_TIME): { - prepareTimeRequest(); - return RETURN_OK; - } - case (StarTracker::BOOT): { - prepareBootCommand(); - return RETURN_OK; - } - case (StarTracker::REQ_VERSION): { - prepareVersionRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_INTERFACE): { - prepareInterfaceRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_POWER): { - preparePowerRequest(); - return RETURN_OK; - } - case (StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); - return RETURN_OK; - } - case (StarTracker::TAKE_IMAGE): { - prepareTakeImageCommand(commandData); - return RETURN_OK; - } - case (StarTracker::SUBSCRIBE_TO_TM): { - prepareSubscriptionCommand(commandData); - return RETURN_OK; - } - case (StarTracker::REQ_SOLUTION): { - prepareSolutionRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_TEMPERATURE): { - prepareTemperatureRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_HISTOGRAM): { - prepareHistogramRequest(); - return RETURN_OK; - } - case (StarTracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; - } - case (StarTracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; - } - case (StarTracker::LIMITS): { - Limits limits; - result = prepareParamCommand(commandData, commandDataLen, limits); - return result; - } - case (StarTracker::MOUNTING): { - Mounting mounting; - result = prepareParamCommand(commandData, commandDataLen, mounting); - return result; - } - case (StarTracker::CAMERA): { - Camera camera; - result = prepareParamCommand(commandData, commandDataLen, camera); - return result; - } - case (StarTracker::BLOB): { - Blob blob; - result = prepareParamCommand(commandData, commandDataLen, blob); - return result; - } - case (StarTracker::CENTROIDING): { - Centroiding centroiding; - result = prepareParamCommand(commandData, commandDataLen, centroiding); - return result; - } - case (StarTracker::LISA): { - Lisa lisa; - result = prepareParamCommand(commandData, commandDataLen, lisa); - return result; - } - case (StarTracker::MATCHING): { - Matching matching; - result = prepareParamCommand(commandData, commandDataLen, matching); - return result; - } - case (StarTracker::VALIDATION): { - Validation validation; - result = prepareParamCommand(commandData, commandDataLen, validation); - return result; - } - case (StarTracker::ALGO): { - Algo algo; - result = prepareParamCommand(commandData, commandDataLen, algo); - return result; - } - case (StarTracker::TRACKING): { - Tracking tracking; - result = prepareParamCommand(commandData, commandDataLen, tracking); - return result; - } - case (StarTracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::CHECKSUM): { - result = prepareChecksumCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::FPGA_ACTION): { - result = prepareFpgaActionCommand(commandData, commandDataLen); - return result; - } - case (StarTracker::REQ_CAMERA): { - result = prepareRequestCameraParams(); - return result; - } - case (StarTracker::REQ_LIMITS): { - result = prepareRequestLimitsParams(); - return result; - } - case (StarTracker::REQ_BLOB_PARAMS): { - result = prepareRequestBlobParams(); - return result; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return HasReturnvaluesIF::RETURN_FAILED; -} - -void StarTrackerHandler::fillCommandAndReplyMap() { - /** Reply lengths are unknown because of the slip encoding. Thus always maximum reply size - * is specified */ - this->insertInCommandAndReplyMap(StarTracker::PING_REQUEST, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::BOOT); - this->insertInCommandAndReplyMap(StarTracker::REQ_VERSION, 3, &versionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TIME, 3, &timeSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandMap(StarTracker::UPLOAD_IMAGE); - this->insertInCommandMap(StarTracker::DOWNLOAD_IMAGE); - this->insertInCommandAndReplyMap(StarTracker::REQ_POWER, 3, &powerSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_INTERFACE, 3, &interfaceSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - // Reboot has no reply. Star tracker reboots immediately - this->insertInCommandMap(StarTracker::SWITCH_TO_BOOTLOADER_PROGRAM); - this->insertInCommandAndReplyMap(StarTracker::SUBSCRIBE_TO_TM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_SOLUTION, 3, &solutionSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_TEMPERATURE, 3, &temperatureSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_HISTOGRAM, 3, &histogramSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CONTRAST, 3, &contrastSet, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MOUNTING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::BLOB, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CENTROIDING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::LISA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::MATCHING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TRACKING, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::VALIDATION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ALGO, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::TAKE_IMAGE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::RESET_ERROR, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::ERASE, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UNLOCK, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::CHECKSUM, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::SET_TIME, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::UPLOAD_CENTROID, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::FPGA_ACTION, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_CAMERA, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_LIMITS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(StarTracker::REQ_BLOB_PARAMS, 3, nullptr, - StarTracker::MAX_FRAME_SIZE * 2 + 2); -} - -ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, - DeviceCommandId_t* foundId, size_t* foundLen) { - ReturnValue_t result = RETURN_OK; - size_t bytesLeft = 0; - - result = dataLinkLayer.decodeFrame(start, remainingSize, &bytesLeft); - switch (result) { - case ArcsecDatalinkLayer::DEC_IN_PROGRESS: { - remainingSize = bytesLeft; - // Need a second doSendRead pass to reaa in whole packet - return IGNORE_REPLY_DATA; - } - case RETURN_OK: { - break; - } - default: - remainingSize = bytesLeft; - return result; - } - - switch (dataLinkLayer.getReplyFrameType()) { - case TMTC_ACTIONREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForActionReply(foundId); - break; - } - case TMTC_SETPARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForSetParameterReply(foundId); - break; - } - case TMTC_PARAMREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForGetParameterReply(foundId); - break; - } - case TMTC_TELEMETRYREPLYA: - case TMTC_TELEMETRYREPLY: { - *foundLen = remainingSize - bytesLeft; - result = scanForTmReply(foundId); - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl; - result = RETURN_FAILED; - } - } - - remainingSize = bytesLeft; - - return result; -} - -ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, - const uint8_t* packet) { - ReturnValue_t result = RETURN_OK; - - switch (id) { - case (StarTracker::SUBSCRIBE_TO_TM): { - result = handleSetParamReply(); - break; - } - case (StarTracker::REQ_TIME): { - result = handleTm(timeSet, StarTracker::TimeSet::SIZE); - break; - } - case (StarTracker::PING_REQUEST): { - result = handlePingReply(); - break; - } - case (StarTracker::BOOT): - case (StarTracker::TAKE_IMAGE): - case (StarTracker::RESET_ERROR): - case (StarTracker::UNLOCK): - case (StarTracker::SET_TIME): - case (StarTracker::FPGA_ACTION): { - result = handleActionReply(); - break; - } - case (StarTracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, StarTracker::DownloadCentroidSet::SIZE); - break; - } - case (StarTracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, StarTracker::DownloadMatchedStar::SIZE); - break; - } - case (StarTracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, StarTracker::DownloadDBImage::SIZE); - break; - } - case (StarTracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, StarTracker::DownloadBlobPixel::SIZE); - break; - } - case (StarTracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; - } - case (StarTracker::ERASE): { - result = handleEraseReply(); - break; - } - case (StarTracker::CHECKSUM): { - result = handleChecksumReply(); - break; - } - case (StarTracker::REQ_VERSION): { - result = handleTm(versionSet, StarTracker::VersionSet::SIZE); - if (result != RETURN_OK) { - return result; - } - result = checkProgram(); - if (result != RETURN_OK) { - return result; - } - break; - } - case (StarTracker::REQ_INTERFACE): { - result = handleTm(interfaceSet, StarTracker::InterfaceSet::SIZE); - break; - } - case (StarTracker::REQ_POWER): { - result = handleTm(powerSet, StarTracker::PowerSet::SIZE); - break; - } - case (StarTracker::REQ_SOLUTION): { - result = handleTm(solutionSet, StarTracker::SolutionSet::SIZE); - break; - } - case (StarTracker::REQ_TEMPERATURE): { - result = handleTm(temperatureSet, StarTracker::TemperatureSet::SIZE); - break; - } - case (StarTracker::REQ_HISTOGRAM): { - result = handleTm(histogramSet, StarTracker::HistogramSet::SIZE); - break; - } - case (StarTracker::REQ_CONTRAST): { - result = handleTm(contrastSet, StarTracker::ContrastSet::SIZE); - break; - } - case (StarTracker::LIMITS): - case (StarTracker::MOUNTING): - case (StarTracker::CAMERA): - case (StarTracker::BLOB): - case (StarTracker::CENTROIDING): - case (StarTracker::LISA): - case (StarTracker::MATCHING): - case (StarTracker::TRACKING): - case (StarTracker::VALIDATION): - case (StarTracker::ALGO): { - result = handleSetParamReply(); - break; - } - case (StarTracker::REQ_CAMERA): { - handleParamRequest(cameraSet, StarTracker::CameraSet::SIZE); - break; - } - case (StarTracker::REQ_LIMITS): { - handleParamRequest(limitsSet, StarTracker::LimitsSet::SIZE); - break; - } - case (StarTracker::REQ_BLOB_PARAMS): { - handleParamRequest(blobSet, StarTracker::BlobSet::SIZE); - break; - } - default: { - sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id - << std::endl; - result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - } - - return result; -} - -void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} - -uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; } - -ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, - LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(StarTracker::TICKS_TIME_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_TIME_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::RUN_TIME, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::UNIX_TIME, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_VERSION_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_VERSION_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::PROGRAM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MAJOR, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MINOR, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_INTERFACE_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_INTERFACE_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FRAME_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CHECKSUM_ERROR_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::SET_PARAM_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::SET_PARAM_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::PARAM_REQUEST_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::PARAM_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::REQ_TM_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TM_REPLY_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::ACTION_REQ_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::ACTION_REPLY_COUNT, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_POWER_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_POWER_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MCU_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MCU_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_CORE_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_18_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_18_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_25_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FPGA_25_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_21_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_21_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_PIX_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_PIX_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_33_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_33_VOLTAGE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_RES_CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMV_RES_VOLTAGE, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_TEMPERATURE_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_TEMPERATURE_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MCU_TEMPERATURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CMOS_TEMPERATURE, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_SOLUTION_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_SOLUTION_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CALI_QW, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CALI_QX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CALI_QY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CALI_QZ, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_CONFIDENCE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_QW, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_QX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_QY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_QZ, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRACK_REMOVED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::STARS_CENTROIDED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::STARS_MATCHED_DATABASE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_QW, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_QX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_QY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_QZ, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_PERC_CLOSE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LISA_NR_CLOSE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TRUST_WORTHY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::STABLE_COUNT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::SOLUTION_STRATEGY, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_HISTOGRAM_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_HISTOGRAM_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINA8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINB8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BINC8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::HISTOGRAM_BIND8, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::TICKS_CONTRAST_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::TIME_CONTRAST_SET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINA8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINB8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BINC8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND0, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND5, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND6, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND7, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CONTRAST_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CHKSUM, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::DWL_ID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_PIXX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_PIXY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_X_UNCORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_X_CORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_Y_CORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_MAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_CXA, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_CYA, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::DWL_QUALITY, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_ID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::BLOBPIX_ID, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_X, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_Y, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_IN_USE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOBPIX_REGION, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::CAMERA_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::FOCALLENGTH, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::EXPOSURE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::INTERVAL, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAMERA_OFFSET, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::PGAGAIN, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::ADCGAIN, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_REG1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_VAL1, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_REG2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_VAL2, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_REG3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_VAL3, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_REG4, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::CAM_VAL4, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::LIMITS_ACTION, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA18CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA25CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_FPGA10CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_MCUCURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOS21CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSPIXCURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOS33CURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSVRESCURRENT, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::LIMITS_CMOSTEMPERATURE, new PoolEntry({0})); - - localDataPoolMap.emplace(StarTracker::BLOB_MODE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_DISTANCE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_DISTANCE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_NEIGHBOUR_BRIGHTPIXELS, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_TOTAL_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_TOTAL_VALUE, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MIN_BRIGHT_NEIGHBOURS, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_MAX_PIXELSTOCONSIDER, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_SIGNAL_THRESHOLD, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_DARK_THRESHOLD, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_HISTOGRAM, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_ENABLE_CONTRAST, new PoolEntry({0})); - localDataPoolMap.emplace(StarTracker::BLOB_BIN_MODE, new PoolEntry({0})); - return RETURN_OK; -} - -size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) { - return StarTracker::MAX_FRAME_SIZE; -} - -ReturnValue_t StarTrackerHandler::doSendReadHook() { - // Prevent DHB from polling UART during commands executed by the image loader task - if (strHelperExecuting) { - return RETURN_FAILED; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) { - switch (actionId) { - case StarTracker::UPLOAD_IMAGE: - case StarTracker::DOWNLOAD_IMAGE: { - return DeviceHandlerBase::acceptExternalDeviceCommands(); - default: - break; - } - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::PING): { - *foundId = StarTracker::PING_REQUEST; - break; - } - case (StarTracker::ID::WRITE): { - *foundId = StarTracker::WRITE; - break; - } - case (StarTracker::ID::BOOT): { - *foundId = StarTracker::BOOT; - break; - } - case (StarTracker::ID::TAKE_IMAGE): { - *foundId = StarTracker::TAKE_IMAGE; - break; - } - case (StarTracker::ID::UPLOAD_IMAGE): { - *foundId = StarTracker::UPLOAD_IMAGE; - break; - } - case (StarTracker::ID::ERROR_RESET): { - *foundId = StarTracker::RESET_ERROR; - break; - } - case (StarTracker::ID::ERASE): { - *foundId = StarTracker::ERASE; - break; - } - case (StarTracker::ID::UNLOCK): { - *foundId = StarTracker::UNLOCK; - break; - } - case (StarTracker::ID::CHECKSUM): { - *foundId = StarTracker::CHECKSUM; - break; - } - case (StarTracker::ID::SET_TIME): { - *foundId = StarTracker::SET_TIME; - break; - } - case (StarTracker::ID::DOWNLOAD_CENTROID): { - *foundId = StarTracker::DOWNLOAD_CENTROID; - break; - } - case (StarTracker::ID::UPLOAD_CENTROID): { - *foundId = StarTracker::UPLOAD_CENTROID; - break; - } - case (StarTracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = StarTracker::DOWNLOAD_MATCHED_STAR; - break; - } - case (StarTracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = StarTracker::DOWNLOAD_DBIMAGE; - break; - } - case (StarTracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = StarTracker::DOWNLOAD_BLOBPIXEL; - break; - } - case (StarTracker::ID::FPGA_ACTION): { - *foundId = StarTracker::FPGA_ACTION; - break; - } - default: - sif::warning << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::scanForSetParameterReply(DeviceCommandId_t* foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::SUBSCRIBE): { - *foundId = StarTracker::SUBSCRIBE_TO_TM; - break; - } - case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::LIMITS; - break; - } - case (StarTracker::ID::MOUNTING): { - *foundId = StarTracker::MOUNTING; - break; - } - case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::CAMERA; - break; - } - case (StarTracker::ID::BLOB): { - *foundId = StarTracker::BLOB; - break; - } - case (StarTracker::ID::CENTROIDING): { - *foundId = StarTracker::CENTROIDING; - break; - } - case (StarTracker::ID::LISA): { - *foundId = StarTracker::LISA; - break; - } - case (StarTracker::ID::MATCHING): { - *foundId = StarTracker::MATCHING; - break; - } - case (StarTracker::ID::TRACKING): { - *foundId = StarTracker::TRACKING; - break; - } - case (StarTracker::ID::VALIDATION): { - *foundId = StarTracker::VALIDATION; - break; - } - case (StarTracker::ID::ALGO): { - *foundId = StarTracker::ALGO; - break; - } - default: - sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id" - << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::scanForGetParameterReply(DeviceCommandId_t* foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::CAMERA): { - *foundId = StarTracker::REQ_CAMERA; - break; - } - case (StarTracker::ID::LIMITS): { - *foundId = StarTracker::REQ_LIMITS; - break; - } - case (StarTracker::ID::BLOB): { - *foundId = StarTracker::REQ_BLOB_PARAMS; - break; - } - default: { - sif::warning << "tarTrackerHandler::scanForGetParameterReply: UnkNown ID" << std::endl; - return RETURN_FAILED; - break; - } - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { - const uint8_t* reply = dataLinkLayer.getReply(); - switch (*reply) { - case (StarTracker::ID::VERSION): { - *foundId = StarTracker::REQ_VERSION; - break; - } - case (StarTracker::ID::INTERFACE): { - *foundId = StarTracker::REQ_INTERFACE; - break; - } - case (StarTracker::ID::POWER): { - *foundId = StarTracker::REQ_POWER; - break; - } - case (StarTracker::ID::TEMPERATURE): { - *foundId = StarTracker::REQ_TEMPERATURE; - break; - } - case (StarTracker::ID::HISTOGRAM): { - *foundId = StarTracker::REQ_HISTOGRAM; - break; - } - case (StarTracker::ID::CONTRAST): { - *foundId = StarTracker::REQ_CONTRAST; - break; - } - case (StarTracker::ID::TIME): { - *foundId = StarTracker::REQ_TIME; - break; - } - case (StarTracker::ID::SOLUTION): { - *foundId = StarTracker::REQ_SOLUTION; - break; - } - default: { - sif::debug << "StarTrackerHandler::scanForTmReply: Reply contains invalid reply id" - << std::endl; - return RETURN_FAILED; - break; - } - } - return RETURN_OK; -} - -void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { - object_id_t objectId = eventMessage->getReporter(); - switch (objectId) { - case objects::STR_HELPER: { - // All events from image loader signal either that the operation was successful or that it - // failed - strHelperExecuting = false; - break; - } - default: - sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl; - break; - } -} - -ReturnValue_t StarTrackerHandler::executeWriteCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < WriteCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + WriteCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of address failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeWriteCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + WriteCmd::FILE_OFFSET; - std::string fullname = std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region)); - result = strHelper->startFlashWrite(fullname, region, address); - if (result != RETURN_OK) { - return result; - } - return result; -} - -ReturnValue_t StarTrackerHandler::executeFpgaDownloadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < FpgaDownloadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Command too short" - << std::endl; - return COMMAND_TOO_SHORT; - } - uint32_t position; - size_t size = sizeof(position); - result = - SerializeAdapter::deSerialize(&position, &commandData, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of position failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - result = - SerializeAdapter::deSerialize(&length, &commandData, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeWriteCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(position) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeFpgaDownloadCommand: Received command with " - " invalid path and filename" - << std::endl; - return FILE_PATH_TOO_LONG; - } - std::string fullname = std::string(reinterpret_cast(commandData), - commandDataLen - sizeof(position) - sizeof(length)); - result = strHelper->startFpgaDownload(fullname, position, length); - if (result != RETURN_OK) { - return result; - } - return result; -} - -ReturnValue_t StarTrackerHandler::executeReadCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { - sif::warning << "StarTrackerHandler::executeReadCommand: Command too short" << std::endl; - return COMMAND_TOO_SHORT; - } - uint8_t region = *(commandData); - uint32_t address; - size_t size = sizeof(address); - const uint8_t* addressPtr = commandData + ReadCmd::ADDRESS_OFFSET; - result = SerializeAdapter::deSerialize(&address, addressPtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of address failed" - << std::endl; - return result; - } - uint32_t length; - size = sizeof(length); - const uint8_t* lengthPtr = commandData + ReadCmd::LENGTH_OFFSET; - result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::executeReadCommand: Deserialization of length failed" - << std::endl; - return result; - } - if (commandDataLen - sizeof(address) - sizeof(region) - sizeof(length) > MAX_PATH_SIZE) { - sif::warning << "StarTrackerHandler::executeReadCommand: Received command with invalid" - << " path and filename" << std::endl; - return FILE_PATH_TOO_LONG; - } - const uint8_t* filePtr = commandData + ReadCmd::FILE_OFFSET; - std::string fullname = - std::string(reinterpret_cast(filePtr), - commandDataLen - sizeof(address) - sizeof(region) - sizeof(length)); - result = strHelper->startFlashRead(fullname, region, address, length); - if (result != RETURN_OK) { - return result; - } - return result; -} - -void StarTrackerHandler::prepareBootCommand() { - uint32_t length = 0; - struct BootActionRequest bootRequest = {BOOT_REGION_ID}; - arc_pack_boot_action_req(&bootRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; -} - -ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - req.region = *commandData; - size_t size = sizeof(req.code); - const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; - result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - -ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, - size_t commandDataLen) { - struct ChecksumActionRequest req; - ReturnValue_t result = RETURN_OK; - if (commandDataLen != ChecksumCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareChecksumCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - req.region = *(commandData); - size_t size = sizeof(req.address); - const uint8_t* addressPtr = commandData + ChecksumCmd::ADDRESS_OFFSET; - result = - SerializeAdapter::deSerialize(&req.address, addressPtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of address " - << "failed" << std::endl; - return result; - } - size = sizeof(req.length); - const uint8_t* lengthPtr = commandData + ChecksumCmd::LENGTH_OFFSET; - result = - SerializeAdapter::deSerialize(&req.length, lengthPtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed" - << std::endl; - return result; - } - uint32_t rawCmdLength = 0; - arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength); - dataLinkLayer.encodeFrame(commandBuffer, rawCmdLength); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - checksumCmd.rememberRegion = req.region; - checksumCmd.rememberAddress = req.address; - checksumCmd.rememberLength = req.length; - return result; -} - -ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - -ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = - std::string(reinterpret_cast(commandData), commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_uncorrected << " does not exist" - << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_uncorrected << " does not exist" - << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(StarTracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << StarTracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; - return result; -} - -void StarTrackerHandler::prepareTimeRequest() { - uint32_t length = 0; - arc_tm_pack_time_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::preparePingRequest() { - uint32_t length = 0; - struct PingActionRequest pingRequest = {PING_ID}; - arc_pack_ping_action_req(&pingRequest, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareVersionRequest() { - uint32_t length = 0; - arc_tm_pack_version_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareInterfaceRequest() { - uint32_t length = 0; - arc_tm_pack_interface_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::preparePowerRequest() { - uint32_t length = 0; - arc_tm_pack_power_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareRebootCommand() { - uint32_t length = 0; - struct RebootActionRequest rebootReq; - arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) { - uint32_t length = 0; - struct CameraActionRequest camReq; - camReq.actionid = *commandData; - arc_pack_camera_action_req(&camReq, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareSubscriptionCommand(const uint8_t* tmId) { - uint32_t length = 18; - commandBuffer[0] = TMTC_SETPARAMREQ; - commandBuffer[1] = StarTracker::ID::SUBSCRIBE; - // Fill all other fields with invalid tm id - commandBuffer[2] = *tmId; - commandBuffer[3] = 0; - commandBuffer[4] = 0; - commandBuffer[5] = 0; - commandBuffer[6] = 0; - commandBuffer[7] = 0; - commandBuffer[8] = 0; - commandBuffer[9] = 0; - commandBuffer[10] = 0; - commandBuffer[11] = 0; - commandBuffer[12] = 0; - commandBuffer[13] = 0; - commandBuffer[14] = 0; - commandBuffer[15] = 0; - commandBuffer[16] = 0; - commandBuffer[17] = 0; - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareSolutionRequest() { - uint32_t length = 0; - arc_tm_pack_solution_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareTemperatureRequest() { - uint32_t length = 0; - arc_tm_pack_temperature_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareHistogramRequest() { - uint32_t length = 0; - arc_tm_pack_histogram_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, - size_t commandDataLen, - ArcsecJsonParamBase& paramSet) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - std::string fullName(reinterpret_cast(commandData), commandDataLen); - - result = paramSet.create(fullName, commandBuffer); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareParamCommand: Failed to create parameter " - "command" - << std::endl; - return result; - } - dataLinkLayer.encodeFrame(commandBuffer, paramSet.getSize()); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { - uint32_t length = 0; - arc_pack_camera_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareRequestLimitsParams() { - uint32_t length = 0; - arc_pack_limits_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareRequestBlobParams() { - uint32_t length = 0; - arc_pack_blob_parameter_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleSetParamReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " - " command with parameter ID" - << static_cast(*(reply + PARAMETER_ID_OFFSET)) << std::endl; - if (startupState != StartupState::IDLE) { - startupState = StartupState::IDLE; - } - return SET_PARAM_FAILED; - } - if (startupState != StartupState::IDLE) { - handleStartup(reply + PARAMETER_ID_OFFSET); - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleActionReply() { - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = *(reply + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action " - << "command with action ID " - << static_cast(*(reply + ACTION_ID_OFFSET)) << " and status " - << static_cast(status) << std::endl; - return ACTION_FAILED; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - return result; -} - -ReturnValue_t StarTrackerHandler::handleChecksumReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - StarTracker::ChecksumReply checksumReply(replyData); - if (checksumReply.getRegion() != checksumCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - if (checksumReply.getAddress() != checksumCmd.rememberAddress) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Address mismatch" << std::endl; - return ADDRESS_MISMATCH; - } - if (checksumReply.getLength() != checksumCmd.rememberLength) { - sif::warning << "StarTrackerHandler::handleChecksumReply: Length mismatch" << std::endl; - return LENGTH_MISSMATCH; - } - PoolReadGuard rg(&checksumSet); - checksumSet.checksum = checksumReply.getChecksum(); - handleDeviceTM(&checksumSet, StarTracker::CHECKSUM); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - checksumReply.printChecksum(); -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleParamRequest(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + PARAMS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif - return result; -} - -ReturnValue_t StarTrackerHandler::handlePingReply() { - ReturnValue_t result = RETURN_OK; - uint32_t pingId = 0; - const uint8_t* reply = dataLinkLayer.getReply(); - uint8_t status = dataLinkLayer.getStatusField(); - const uint8_t* buffer = reply + ACTION_DATA_OFFSET; - size_t size = sizeof(pingId); - SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE); -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping status: " << static_cast(status) << std::endl; - sif::info << "Ping id: 0x" << std::hex << pingId << std::endl; -#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */ - if (status != StarTracker::STATUS_OK || pingId != PING_ID) { - sif::warning << "StarTrackerHandler::handlePingReply: Ping failed" << std::endl; - result = PING_FAILED; - } else { -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - sif::info << "StarTracker: Ping successful" << std::endl; -#endif - } - return result; -} - -ReturnValue_t StarTrackerHandler::checkProgram() { - PoolReadGuard pg(&versionSet); - switch (versionSet.program.value) { - case StarTracker::Program::BOOTLOADER: - // Star tracker currently in bootloader program. Need to send boot command to switch to - // firmware program - if (startupState != StartupState::IDLE) { - startupState = StartupState::BOOT; - } - break; - case StarTracker::Program::FIRMWARE: - // Firmware already booted - if (startupState != StartupState::IDLE) { - startupState = StartupState::LIMITS; - } - break; - default: - sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID" - << std::endl; - return INVALID_PROGRAM; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleTm(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleTm: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + TICKS_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleTm: Deserialization failed" << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif - return result; -} - -ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dataset, size_t size) { - ReturnValue_t result = RETURN_OK; - uint8_t status = *(dataLinkLayer.getReply() + STATUS_OFFSET); - if (status != StarTracker::STATUS_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: " - << static_cast(status) << std::endl; - return REPLY_ERROR; - } - result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - dataset.setValidityBufferGeneration(false); - result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl; - } - dataset.setValidityBufferGeneration(true); - dataset.setValidity(true, true); - result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT); - if (result != RETURN_OK) { - return result; - } -#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 - dataset.printSet(); -#endif - return result; -} - -void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { - switch (*parameterId) { - case (StarTracker::ID::LIMITS): { - startupState = StartupState::TRACKING; - break; - } - case (StarTracker::ID::TRACKING): { - startupState = StartupState::MOUNTING; - break; - } - case (StarTracker::ID::MOUNTING): { - startupState = StartupState::CAMERA; - break; - } - case (StarTracker::ID::CAMERA): { - startupState = StartupState::BLOB; - break; - } - case (StarTracker::ID::BLOB): { - startupState = StartupState::CENTROIDING; - break; - } - case (StarTracker::ID::CENTROIDING): { - startupState = StartupState::LISA; - break; - } - case (StarTracker::ID::LISA): { - startupState = StartupState::MATCHING; - break; - } - case (StarTracker::ID::MATCHING): { - startupState = StartupState::VALIDATION; - break; - } - case (StarTracker::ID::VALIDATION): { - startupState = StartupState::ALGO; - break; - } - case (StarTracker::ID::ALGO): { - startupState = StartupState::DONE; - break; - } - default: { - sif::debug << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected" - << " parameter ID" << std::endl; - break; - } - } -} diff --git a/fsfw b/fsfw index 09c1918c..eacb4ac4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 09c1918c1fe36a07ce611a33ff20799187d8d962 +Subproject commit eacb4ac4079ff2bf5e0648626332e59046a409da diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 3696424d..df87a2a2 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -82,11 +82,11 @@ 10902;SWITCH_ALREADY_ON;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h 10903;SWITCH_ALREADY_OFF;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h 10904;MAIN_SWITCH_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/HeaterHandler.h -11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h -11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/linux/devices/SolarArrayDeploymentHandler.h +11000;MAIN_SWITCH_ON_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/SolarArrayDeploymentHandler.h +11001;MAIN_SWITCH_OFF_TIMEOUT;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/SolarArrayDeploymentHandler.h +11002;DEPLOYMENT_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/SolarArrayDeploymentHandler.h +11003;DEPL_SA1_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/SolarArrayDeploymentHandler.h +11004;DEPL_SA2_GPIO_SWTICH_ON_FAILED;HIGH;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/SolarArrayDeploymentHandler.h 11101;MEMORY_READ_RPT_CRC_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h 11102;ACK_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h 11103;EXE_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/PlocMPSoCHandler.h @@ -101,6 +101,7 @@ 11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h 11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\eive-software\eive_obsw/mission/devices/RwHandler.h 11401;BOOTING_FIRMWARE_FAILED;LOW;Failed to boot firmware;C:\Users\jakob\eive-software\eive_obsw/linux/devices/startracker/StarTrackerHandler.h +11402;BOOTING_BOOTLOADER_FAILED;LOW;Failed to boot star tracker into bootloader mode;C:\Users\jakob\eive-software\eive_obsw/linux/devices/startracker/StarTrackerHandler.h 11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h 11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h 11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index dc72a0f6..933a027b 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 138 translations. + * @brief Auto-generated event translation file. Contains 139 translations. * @details - * Generated on: 2022-02-22 09:46:40 + * Generated on: 2022-02-27 15:36:42 */ #include "translateEvents.h" @@ -108,6 +108,7 @@ const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAIL const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *ERROR_STATE_STRING = "ERROR_STATE"; const char *BOOTING_FIRMWARE_FAILED_STRING = "BOOTING_FIRMWARE_FAILED"; +const char *BOOTING_BOOTLOADER_FAILED_STRING = "BOOTING_BOOTLOADER_FAILED"; const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; @@ -352,6 +353,8 @@ const char * translateEvents(Event event) { return ERROR_STATE_STRING; case(11401): return BOOTING_FIRMWARE_FAILED_STRING; + case(11402): + return BOOTING_BOOTLOADER_FAILED_STRING; case(11501): return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; case(11502): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 45bebccf..dcd950fd 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 112 translations. - * Generated on: 2022-02-25 14:35:18 + * Generated on: 2022-02-27 15:36:48 */ #include "translateObjects.h" diff --git a/linux/devices/devicedefinitions/StarTrackerDefinitions.h b/linux/devices/devicedefinitions/StarTrackerDefinitions.h index 277025e7..3299ce4f 100644 --- a/linux/devices/devicedefinitions/StarTrackerDefinitions.h +++ b/linux/devices/devicedefinitions/StarTrackerDefinitions.h @@ -122,83 +122,7 @@ enum PoolIds : lp_id_t { HISTOGRAM_BIND6, HISTOGRAM_BIND7, HISTOGRAM_BIND8, - TICKS_CONTRAST_SET, - TIME_CONTRAST_SET, - CONTRAST_BINA0, - CONTRAST_BINA1, - CONTRAST_BINA2, - CONTRAST_BINA3, - CONTRAST_BINA4, - CONTRAST_BINA5, - CONTRAST_BINA6, - CONTRAST_BINA7, - CONTRAST_BINA8, - CONTRAST_BINB0, - CONTRAST_BINB1, - CONTRAST_BINB2, - CONTRAST_BINB3, - CONTRAST_BINB4, - CONTRAST_BINB5, - CONTRAST_BINB6, - CONTRAST_BINB7, - CONTRAST_BINB8, - CONTRAST_BINC0, - CONTRAST_BINC1, - CONTRAST_BINC2, - CONTRAST_BINC3, - CONTRAST_BINC4, - CONTRAST_BINC5, - CONTRAST_BINC6, - CONTRAST_BINC7, - CONTRAST_BINC8, - CONTRAST_BIND0, - CONTRAST_BIND1, - CONTRAST_BIND2, - CONTRAST_BIND3, - CONTRAST_BIND4, - CONTRAST_BIND5, - CONTRAST_BIND6, - CONTRAST_BIND7, - CONTRAST_BIND8, CHKSUM, - DWL_ID, - DWL_PIXX, - DWL_PIXY, - DWL_X_UNCORRECTED, - DWL_Y_UNCORRECTED, - DWL_X_CORRECTED, - DWL_Y_CORRECTED, - DWL_MAGNITUDE, - DWL_CXA, - DWL_CYA, - DWL_QUALITY, - MATCHEDSTR_ID, - MATCHEDSTR_CAMFPX, - MATCHEDSTR_CAMFPY, - MATCHEDSTR_CAMCARTX, - MATCHEDSTR_CAMCARTY, - MATCHEDSTR_CAMCARTZ, - MATCHEDSTR_CAMMAGNITUDE, - MATCHEDSTR_DBFPX, - MATCHEDSTR_DBFPY, - MATCHEDSTR_DBCARTX, - MATCHEDSTR_DBCARTY, - MATCHEDSTR_DBCARTZ, - MATCHEDSTR_DBMAGNITUDE, - MATCHEDSTR_CATALOGID, - DBIMAGE_ID, - DBIMAGE_PIXX, - DBIMAGE_PIXY, - DBIMAGE_X, - DBIMAGE_Y, - DBIMAGE_MAGNITUDE, - BLOBPIX_ID, - BLOBPIX_X, - BLOBPIX_Y, - BLOBPIX_TOT_VAL, - BLOBPIX_IN_USE, - BLOBPIX_BRIGHT_NEIGHBOURS, - BLOBPIX_REGION, CAMERA_MODE, FOCALLENGTH, EXPOSURE, @@ -346,21 +270,16 @@ static const DeviceCommandId_t BOOT = 1; static const DeviceCommandId_t REQ_VERSION = 2; static const DeviceCommandId_t REQ_INTERFACE = 3; static const DeviceCommandId_t REQ_TIME = 4; -static const DeviceCommandId_t ERASE = 5; -static const DeviceCommandId_t UNLOCK = 6; static const DeviceCommandId_t SWITCH_TO_BOOTLOADER_PROGRAM = 7; static const DeviceCommandId_t DOWNLOAD_IMAGE = 9; static const DeviceCommandId_t UPLOAD_IMAGE = 10; static const DeviceCommandId_t REQ_POWER = 11; static const DeviceCommandId_t TAKE_IMAGE = 15; -static const DeviceCommandId_t DOWNLOAD_CENTROID = 16; -static const DeviceCommandId_t UPLOAD_CENTROID = 17; static const DeviceCommandId_t SUBSCRIPTION = 18; static const DeviceCommandId_t IMAGE_PROCESSOR = 19; static const DeviceCommandId_t REQ_SOLUTION = 24; static const DeviceCommandId_t REQ_TEMPERATURE = 25; static const DeviceCommandId_t REQ_HISTOGRAM = 28; -static const DeviceCommandId_t REQ_CONTRAST = 29; static const DeviceCommandId_t LIMITS = 40; static const DeviceCommandId_t MOUNTING = 41; static const DeviceCommandId_t CAMERA = 42; @@ -372,15 +291,10 @@ static const DeviceCommandId_t VALIDATION = 48; static const DeviceCommandId_t ALGO = 49; static const DeviceCommandId_t CHECKSUM = 50; static const DeviceCommandId_t FLASH_READ = 51; -static const DeviceCommandId_t DOWNLOAD_MATCHED_STAR = 53; static const DeviceCommandId_t STOP_IMAGE_LOADER = 55; -static const DeviceCommandId_t RESET_ERROR = 56; -static const DeviceCommandId_t CHANGE_DOWNLOAD_FILE = 57; +static const DeviceCommandId_t CHANGE_IMAGE_DOWNLOAD_FILE = 57; static const DeviceCommandId_t SET_JSON_FILE_NAME = 58; -static const DeviceCommandId_t SET_READ_FILENAME = 59; -static const DeviceCommandId_t SET_TIME = 60; -static const DeviceCommandId_t DOWNLOAD_DBIMAGE = 61; -static const DeviceCommandId_t DOWNLOAD_BLOBPIXEL = 62; +static const DeviceCommandId_t SET_FLASH_READ_FILENAME = 59; static const DeviceCommandId_t REQ_CAMERA = 67; static const DeviceCommandId_t REQ_LIMITS = 68; static const DeviceCommandId_t REQ_LOG_LEVEL = 69; @@ -410,12 +324,7 @@ static const uint32_t TEMPERATURE_SET_ID = REQ_TEMPERATURE; static const uint32_t TIME_SET_ID = REQ_TIME; static const uint32_t SOLUTION_SET_ID = REQ_SOLUTION; static const uint32_t HISTOGRAM_SET_ID = REQ_HISTOGRAM; -static const uint32_t CONTRAST_SET_ID = REQ_CONTRAST; static const uint32_t CHECKSUM_SET_ID = CHECKSUM; -static const uint32_t DOWNLOADCENTROID_SET_ID = DOWNLOAD_CENTROID; -static const uint32_t DOWNLOAD_MATCHED_STAR_SET_ID = DOWNLOAD_MATCHED_STAR; -static const uint32_t DOWNLOAD_DBIMAGE_SET_ID = DOWNLOAD_DBIMAGE; -static const uint32_t DOWNLOAD_BLOBPIXEL_SET_ID = DOWNLOAD_BLOBPIXEL; static const uint32_t CAMERA_SET_ID = REQ_CAMERA; static const uint32_t LIMITS_SET_ID = REQ_LIMITS; static const uint32_t LOG_LEVEL_SET_ID = REQ_LOG_LEVEL; @@ -441,12 +350,7 @@ static const uint8_t POWER_SET_ENTRIES = 18; static const uint8_t TIME_SET_ENTRIES = 4; static const uint8_t SOLUTION_SET_ENTRIES = 23; static const uint8_t HISTOGRAM_SET_ENTRIES = 38; -static const uint8_t CONTRAST_SET_ENTRIES = 38; static const uint8_t CHECKSUM_SET_ENTRIES = 1; -static const uint8_t DOWNLOAD_CENTROID_SET_ENTRIES = 11; -static const uint8_t DOWNLOAD_MATCHED_STAR_SET_ENTRIES = 14; -static const uint8_t DOWNLOAD_DBIMAGE_SET_ENTRIES = 6; -static const uint8_t DOWNLOAD_BLOBPIXEL_SET_ENTRIES = 7; static const uint8_t CAMERA_SET_ENTRIES = 24; static const uint8_t LIMITS_SET_ENTRIES = 11; static const uint8_t LOG_LEVEL_SET_ENTRIES = 16; @@ -491,15 +395,7 @@ static const uint8_t TIME = 1; static const uint8_t WRITE = 2; static const uint8_t READ = 3; static const uint8_t CHECKSUM = 4; -static const uint8_t ERASE = 5; -static const uint8_t UNLOCK = 6; static const uint8_t TAKE_IMAGE = 15; -static const uint8_t ERROR_RESET = 12; -static const uint8_t DOWNLOAD_CENTROID = 16; -static const uint8_t UPLOAD_CENTROID = 17; -static const uint8_t DOWNLOAD_MATCHED_STAR = 18; -static const uint8_t DOWNLOAD_DBIMAGE = 19; -static const uint8_t DOWNLOAD_BLOBPIXEL = 24; static const uint8_t LOG_LEVEL = 3; static const uint8_t LOG_SUBSCRIPTION = 19; static const uint8_t DEBUG_CAMERA = 20; @@ -929,100 +825,6 @@ class HistogramSet : public StaticLocalDataSet { } }; -/** - * @brief Dataset to store the contrast telemetry data - */ -class ContrastSet : public StaticLocalDataSet { - public: - // Size of dataset - static const size_t SIZE = 156; - - ContrastSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, CONTRAST_SET_ID) {} - - ContrastSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, CONTRAST_SET_ID)) {} - - lp_var_t ticks = lp_var_t(sid.objectId, PoolIds::TICKS_CONTRAST_SET, this); - lp_var_t time = lp_var_t(sid.objectId, PoolIds::TIME_CONTRAST_SET, this); - lp_var_t binA0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA0, this); - lp_var_t binA1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA1, this); - lp_var_t binA2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA2, this); - lp_var_t binA3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA3, this); - lp_var_t binA4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA4, this); - lp_var_t binA5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA5, this); - lp_var_t binA6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA6, this); - lp_var_t binA7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA7, this); - lp_var_t binA8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINA8, this); - lp_var_t binb0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB0, this); - lp_var_t binB1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB1, this); - lp_var_t binB2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB2, this); - lp_var_t binB3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB3, this); - lp_var_t binB4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB4, this); - lp_var_t binB5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB5, this); - lp_var_t binB6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB6, this); - lp_var_t binB7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB7, this); - lp_var_t binB8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINB8, this); - lp_var_t binC0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC0, this); - lp_var_t binC1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC1, this); - lp_var_t binC2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC2, this); - lp_var_t binC3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC3, this); - lp_var_t binC4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC4, this); - lp_var_t binC5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC5, this); - lp_var_t binC6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC6, this); - lp_var_t binC7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC7, this); - lp_var_t binC8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BINC8, this); - lp_var_t binD0 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND0, this); - lp_var_t binD1 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND1, this); - lp_var_t binD2 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND2, this); - lp_var_t binD3 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND3, this); - lp_var_t binD4 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND4, this); - lp_var_t binD5 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND5, this); - lp_var_t binD6 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND6, this); - lp_var_t binD7 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND7, this); - lp_var_t binD8 = lp_var_t(sid.objectId, PoolIds::CONTRAST_BIND8, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "ContrastSet::printSet: Ticks: " << this->ticks << std::endl; - sif::info << "ContrastSet::printSet: Time (time stamp): " << this->time << " us" << std::endl; - sif::info << "ContrastSet::printSet: BinA0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinA1: " << this->binA1 << std::endl; - sif::info << "ContrastSet::printSet: BinA2: " << this->binA2 << std::endl; - sif::info << "ContrastSet::printSet: BinA3: " << this->binA3 << std::endl; - sif::info << "ContrastSet::printSet: BinA4: " << this->binA4 << std::endl; - sif::info << "ContrastSet::printSet: BinA5: " << this->binA5 << std::endl; - sif::info << "ContrastSet::printSet: BinA6: " << this->binA6 << std::endl; - sif::info << "ContrastSet::printSet: BinA7: " << this->binA7 << std::endl; - sif::info << "ContrastSet::printSet: BinA8: " << this->binA8 << std::endl; - sif::info << "ContrastSet::printSet: BinB0: " << this->binA0 << std::endl; - sif::info << "ContrastSet::printSet: BinB1: " << this->binB1 << std::endl; - sif::info << "ContrastSet::printSet: BinB2: " << this->binB2 << std::endl; - sif::info << "ContrastSet::printSet: BinB3: " << this->binB3 << std::endl; - sif::info << "ContrastSet::printSet: BinB4: " << this->binB4 << std::endl; - sif::info << "ContrastSet::printSet: BinB5: " << this->binB5 << std::endl; - sif::info << "ContrastSet::printSet: BinB6: " << this->binB6 << std::endl; - sif::info << "ContrastSet::printSet: BinB7: " << this->binB7 << std::endl; - sif::info << "ContrastSet::printSet: BinB8: " << this->binB8 << std::endl; - sif::info << "ContrastSet::printSet: BinC0: " << this->binC0 << std::endl; - sif::info << "ContrastSet::printSet: BinC1: " << this->binC1 << std::endl; - sif::info << "ContrastSet::printSet: BinC2: " << this->binC2 << std::endl; - sif::info << "ContrastSet::printSet: BinC3: " << this->binC3 << std::endl; - sif::info << "ContrastSet::printSet: BinC4: " << this->binC4 << std::endl; - sif::info << "ContrastSet::printSet: BinC5: " << this->binC5 << std::endl; - sif::info << "ContrastSet::printSet: BinC6: " << this->binC6 << std::endl; - sif::info << "ContrastSet::printSet: BinC7: " << this->binC7 << std::endl; - sif::info << "ContrastSet::printSet: BinC8: " << this->binC8 << std::endl; - sif::info << "ContrastSet::printSet: BinD0: " << this->binD0 << std::endl; - sif::info << "ContrastSet::printSet: BinD1: " << this->binD1 << std::endl; - sif::info << "ContrastSet::printSet: BinD2: " << this->binD2 << std::endl; - sif::info << "ContrastSet::printSet: BinD3: " << this->binD3 << std::endl; - sif::info << "ContrastSet::printSet: BinD4: " << this->binD4 << std::endl; - sif::info << "ContrastSet::printSet: BinD5: " << this->binD5 << std::endl; - sif::info << "ContrastSet::printSet: BinD6: " << this->binD6 << std::endl; - sif::info << "ContrastSet::printSet: BinD7: " << this->binD7 << std::endl; - sif::info << "ContrastSet::printSet: BinD8: " << this->binD8 << std::endl; - } -}; - /** * @brief Helper Class to extract information from bytestream. */ @@ -1083,16 +885,6 @@ class ChecksumReply { uint32_t checksum = 0; }; -class EraseReply { - public: - EraseReply(const uint8_t* datafield) { region = *datafield; } - - uint8_t getRegion() { return region; } - - private: - uint8_t region = 0; -}; - class ChecksumSet : public StaticLocalDataSet { public: // Size of dataset @@ -1105,185 +897,6 @@ class ChecksumSet : public StaticLocalDataSet { lp_var_t checksum = lp_var_t(sid.objectId, PoolIds::CHKSUM, this); }; -/** - * @brief Dataset to store download centroid response - */ -class DownloadCentroidSet : public StaticLocalDataSet { - public: - // Size of dataset - static const size_t SIZE = 38; - - DownloadCentroidSet(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, DOWNLOADCENTROID_SET_ID) {} - - DownloadCentroidSet(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, DOWNLOADCENTROID_SET_ID)) {} - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DWL_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DWL_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DWL_PIXY, this); - lp_var_t xUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_UNCORRECTED, this); - lp_var_t yUncorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_UNCORRECTED, this); - lp_var_t xCorrected = lp_var_t(sid.objectId, PoolIds::DWL_X_CORRECTED, this); - lp_var_t yCorrected = lp_var_t(sid.objectId, PoolIds::DWL_Y_CORRECTED, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DWL_MAGNITUDE, this); - lp_var_t cxa = lp_var_t(sid.objectId, PoolIds::DWL_CXA, this); - lp_var_t cya = lp_var_t(sid.objectId, PoolIds::DWL_CYA, this); - lp_var_t quality = lp_var_t(sid.objectId, PoolIds::DWL_QUALITY, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadCentroidSet::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "DownloadCentroidSet::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadCentroidSet::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadCentroidSet::printSet: xUncorrected: " << this->xUncorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: yUncorrected: " << this->yUncorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: xCorrected: " << this->xCorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: yCorrected: " << this->yCorrected << std::endl; - sif::info << "DownloadCentroidSet::printSet: magnitude: " << this->magnitude << std::endl; - sif::info << "DownloadCentroidSet::printSet: cxa: " << this->cxa << std::endl; - sif::info << "DownloadCentroidSet::printSet: cya: " << this->cya << std::endl; - sif::info << "DownloadCentroidSet::printSet: quality: " << this->quality << std::endl; - } -}; - -namespace UploadCentroidKeys { -static const char id[] = "id"; -static const char pixx[] = "pixx"; -static const char pixy[] = "pixy"; -static const char x_uncorrected[] = "x_uncorrected"; -static const char y_uncorrected[] = "y_uncorrected"; -static const char x_corrected[] = "x_corrected"; -static const char y_corrected[] = "y_corrected"; -static const char magnitude[] = "magnitude"; -static const char cxa[] = "cxa"; -static const char cya[] = "cya"; -static const char quality[] = "quality"; -}; // namespace UploadCentroidKeys - -/** - * @brief Dataset to store matched star information - */ -class DownloadMatchedStar : public StaticLocalDataSet { - public: - // Size of dataset - static const size_t SIZE = 53; - - DownloadMatchedStar(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, DOWNLOAD_MATCHED_STAR_SET_ID) {} - - DownloadMatchedStar(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_MATCHED_STAR_SET_ID)) {} - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_ID, this); - lp_var_t camfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPX, this); - lp_var_t camfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMFPY, this); - lp_var_t camcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTX, this); - lp_var_t camcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTY, this); - lp_var_t camcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMCARTZ, this); - lp_var_t cammagnitude = - lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CAMMAGNITUDE, this); - lp_var_t dbfpx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPX, this); - lp_var_t dbfpy = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBFPY, this); - lp_var_t dbcartx = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTX, this); - lp_var_t dbcarty = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTY, this); - lp_var_t dbcartz = lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBCARTZ, this); - lp_var_t dbmagnitude = - lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_DBMAGNITUDE, this); - lp_var_t catalogid = - lp_var_t(sid.objectId, PoolIds::MATCHEDSTR_CATALOGID, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadMatchedStar::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpx: " << this->camfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camfpy: " << this->camfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartx: " << this->camcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcarty: " << this->camcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: camcartz: " << this->camcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: cammagnitude: " << this->cammagnitude << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpx: " << this->dbfpx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbfpy: " << this->dbfpy << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartx: " << this->dbcartx << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcarty: " << this->dbcarty << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbcartz: " << this->dbcartz << std::endl; - sif::info << "DownloadMatchedStar::printSet: dbmagnitude: " << this->dbmagnitude << std::endl; - sif::info << "DownloadMatchedStar::printSet: catalogid: " << this->catalogid << std::endl; - } -}; - -/** - * @brief Dataset to store the response to the DownloadDBImage request - */ -class DownloadDBImage : public StaticLocalDataSet { - public: - // Size of dataset - static const size_t SIZE = 21; - - DownloadDBImage(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, DOWNLOAD_DBIMAGE_SET_ID) {} - - DownloadDBImage(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_DBIMAGE_SET_ID)) {} - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::DBIMAGE_ID, this); - lp_var_t pixx = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXX, this); - lp_var_t pixy = lp_var_t(sid.objectId, PoolIds::DBIMAGE_PIXY, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::DBIMAGE_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::DBIMAGE_Y, this); - lp_var_t magnitude = lp_var_t(sid.objectId, PoolIds::DBIMAGE_MAGNITUDE, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadDBImage::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "DownloadDBImage::printSet: pixx: " << this->pixx << std::endl; - sif::info << "DownloadDBImage::printSet: pixy: " << this->pixy << std::endl; - sif::info << "DownloadDBImage::printSet: x: " << this->x << std::endl; - sif::info << "DownloadDBImage::printSet: y: " << this->y << std::endl; - sif::info << "DownloadDBImage::printSet: magnitude: " << this->magnitude << std::endl; - } -}; - -/** - * @brief Dataset to store the response to the download blob pixel action request - */ -class DownloadBlobPixel : public StaticLocalDataSet { - public: - // Size of dataset - static const size_t SIZE = 22; - - DownloadBlobPixel(HasLocalDataPoolIF* owner) - : StaticLocalDataSet(owner, DOWNLOAD_BLOBPIXEL_SET_ID) {} - - DownloadBlobPixel(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, DOWNLOAD_BLOBPIXEL_SET_ENTRIES)) {} - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::BLOBPIX_ID, this); - lp_var_t x = lp_var_t(sid.objectId, PoolIds::BLOBPIX_X, this); - lp_var_t y = lp_var_t(sid.objectId, PoolIds::BLOBPIX_Y, this); - lp_var_t totalValue = lp_var_t(sid.objectId, PoolIds::BLOBPIX_TOT_VAL, this); - lp_var_t inUse = lp_var_t(sid.objectId, PoolIds::BLOBPIX_IN_USE, this); - lp_var_t brightNeighbours = - lp_var_t(sid.objectId, PoolIds::BLOBPIX_BRIGHT_NEIGHBOURS, this); - lp_var_t region = lp_var_t(sid.objectId, PoolIds::BLOBPIX_REGION, this); - - void printSet() { - PoolReadGuard rg(this); - sif::info << "DownloadBlobPixel::printSet: id: " << static_cast(this->id.value) - << std::endl; - sif::info << "DownloadBlobPixel::printSet: x: " << this->x << std::endl; - sif::info << "DownloadBlobPixel::printSet: y: " << this->y << std::endl; - sif::info << "DownloadBlobPixel::printSet: totalValue: " << this->totalValue << std::endl; - sif::info << "DownloadBlobPixel::printSet: inUse: " - << static_cast(this->inUse.value) << std::endl; - sif::info << "DownloadBlobPixel::printSet: brightNeighbours: " << this->brightNeighbours - << std::endl; - sif::info << "DownloadBlobPixel::printSet: region: " << this->region << std::endl; - } -}; - /** * @brief Will store the camera parameters set in the star tracker which are retrieved with * a get parameter request. diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 78ef5e83..144d9a4c 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -1,8 +1,6 @@ #include "StarTrackerHandler.h" -#include #include -#include #include @@ -12,12 +10,9 @@ extern "C" { #include #include #include - #include "common/misc.h" } -using json = nlohmann::json; - StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, StrHelper* strHelper) : DeviceHandlerBase(objectId, comIF, comCookie), @@ -28,12 +23,7 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, timeSet(this), solutionSet(this), histogramSet(this), - contrastSet(this), checksumSet(this), - downloadCentroidSet(this), - downloadMatchedStar(this), - downloadDbImage(this), - downloadBlobPixel(this), cameraSet(this), limitsSet(this), loglevelSet(this), @@ -117,10 +107,10 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu } case (startracker::DISABLE_TIMESTAMP_GENERATION): strHelper->disableTimestamping(); - break; + return EXECUTION_FINISHED; case (startracker::ENABLE_TIMESTAMP_GENERATION): strHelper->enableTimestamping(); - break; + return EXECUTION_FINISHED; default: break; } @@ -184,18 +174,18 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu strHelperExecuting = true; return EXECUTION_FINISHED; } - case (startracker::CHANGE_DOWNLOAD_FILE): { + case (startracker::CHANGE_IMAGE_DOWNLOAD_FILE): { if (size > MAX_FILE_NAME) { return FILENAME_TOO_LONG; } strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } - case (startracker::SET_READ_FILENAME): { + case (startracker::SET_FLASH_READ_FILENAME): { if (size > MAX_FILE_NAME) { return FILENAME_TOO_LONG; } - strHelper->setDownloadImageName(std::string(reinterpret_cast(data), size)); + strHelper->setFlashReadFilename(std::string(reinterpret_cast(data), size)); return EXECUTION_FINISHED; } case (startracker::FIRMWARE_UPDATE): { @@ -272,11 +262,16 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id switch (normalState) { case NormalState::TEMPERATURE_REQUEST: *id = startracker::REQ_TEMPERATURE; + normalState = NormalState::SOLUTION_REQUEST; + break; + case NormalState::SOLUTION_REQUEST: + *id = startracker::REQ_SOLUTION; + normalState = NormalState::TEMPERATURE_REQUEST; break; default: sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid normal step" << std::endl; - break; + return NOTHING_TO_SEND; } return buildCommandFromCommand(*id, NULL, 0); } @@ -415,7 +410,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi return RETURN_OK; } case (startracker::SWITCH_TO_BOOTLOADER_PROGRAM): { - prepareRebootCommand(); + prepareSwitchToBootloaderCmd(); return RETURN_OK; } case (startracker::TAKE_IMAGE): { @@ -439,14 +434,6 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi prepareHistogramRequest(); return RETURN_OK; } - case (startracker::REQ_CONTRAST): { - prepareContrastRequest(); - return RETURN_OK; - } - case (startracker::RESET_ERROR): { - prepareErrorResetRequest(); - return RETURN_OK; - } case (startracker::LIMITS): { Limits limits; result = prepareParamCommand(commandData, commandDataLen, limits); @@ -512,42 +499,10 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi result = prepareParamCommand(commandData, commandDataLen, debugCamera); return result; } - case (startracker::ERASE): { - result = prepareEraseCommand(commandData, commandDataLen); - return result; - } - case (startracker::UNLOCK): { - result = prepareUnlockCommand(commandData, commandDataLen); - return result; - } case (startracker::CHECKSUM): { result = prepareChecksumCommand(commandData, commandDataLen); return result; } - case (startracker::SET_TIME): { - result = prepareSetTimeCommand(commandData, commandDataLen); - return result; - } - case (startracker::DOWNLOAD_CENTROID): { - result = prepareDownloadCentroidCommand(commandData, commandDataLen); - return result; - } - case (startracker::UPLOAD_CENTROID): { - result = prepareUploadCentroidCommand(commandData, commandDataLen); - return result; - } - case (startracker::DOWNLOAD_MATCHED_STAR): { - result = prepareDownloadMatchedStarCommand(commandData, commandDataLen); - return result; - } - case (startracker::DOWNLOAD_DBIMAGE): { - result = prepareDownloadDbImageCommand(commandData, commandDataLen); - return result; - } - case (startracker::DOWNLOAD_BLOBPIXEL): { - result = prepareDownloadBlobPixelCommand(commandData, commandDataLen); - return result; - } case (startracker::REQ_CAMERA): { result = prepareRequestCameraParams(); return result; @@ -636,8 +591,6 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_HISTOGRAM, 3, &histogramSet, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::REQ_CONTRAST, 3, &contrastSet, - startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LOGLEVEL, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LOGSUBSCRIPTION, 3, nullptr, @@ -652,8 +605,6 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::CAMERA, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::CAMERA, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::CENTROIDING, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::LISA, 3, nullptr, @@ -668,25 +619,7 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::TAKE_IMAGE, 3, nullptr, startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::RESET_ERROR, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::ERASE, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::UNLOCK, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::CHECKSUM, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::SET_TIME, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::DOWNLOAD_CENTROID, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::UPLOAD_CENTROID, 3, nullptr, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::DOWNLOAD_MATCHED_STAR, 3, &downloadMatchedStar, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::DOWNLOAD_DBIMAGE, 3, &downloadDbImage, - startracker::MAX_FRAME_SIZE * 2 + 2); - this->insertInCommandAndReplyMap(startracker::DOWNLOAD_BLOBPIXEL, 3, &downloadBlobPixel, + this->insertInCommandAndReplyMap(startracker::CHECKSUM, 3, &checksumSet, startracker::MAX_FRAME_SIZE * 2 + 2); this->insertInCommandAndReplyMap(startracker::REQ_CAMERA, 3, &cameraSet, startracker::MAX_FRAME_SIZE * 2 + 2); @@ -890,34 +823,7 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, } case (startracker::BOOT): case (startracker::TAKE_IMAGE): - case (startracker::RESET_ERROR): - case (startracker::UNLOCK): - case (startracker::SET_TIME): break; - case (startracker::DOWNLOAD_CENTROID): { - result = handleActionReplySet(downloadCentroidSet, startracker::DownloadCentroidSet::SIZE); - break; - } - case (startracker::DOWNLOAD_MATCHED_STAR): { - result = handleActionReplySet(downloadMatchedStar, startracker::DownloadMatchedStar::SIZE); - break; - } - case (startracker::DOWNLOAD_DBIMAGE): { - result = handleActionReplySet(downloadDbImage, startracker::DownloadDBImage::SIZE); - break; - } - case (startracker::DOWNLOAD_BLOBPIXEL): { - result = handleActionReplySet(downloadBlobPixel, startracker::DownloadBlobPixel::SIZE); - break; - } - case (startracker::UPLOAD_CENTROID): { - result = handleUploadCentroidReply(); - break; - } - case (startracker::ERASE): { - result = handleEraseReply(); - break; - } case (startracker::CHECKSUM): { result = handleChecksumReply(); break; @@ -953,10 +859,6 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, result = handleTm(histogramSet, startracker::HistogramSet::SIZE); break; } - case (startracker::REQ_CONTRAST): { - result = handleTm(contrastSet, startracker::ContrastSet::SIZE); - break; - } case (startracker::SUBSCRIPTION): case (startracker::LOGLEVEL): case (startracker::LOGSUBSCRIPTION): @@ -1042,11 +944,6 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id, void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { - // if (modeTo == MODE_ON && (submode == SUBMODE_NONE || submode == SUBMODE_BOOTLOADER)) { - // return BOOTLOADER_TRANSITION_DELAY; - // } else if (modeTo == MODE_ON && submode == SUBMODE_FIRMWARE && modeFrom == MODE_) { - // return FIRMWARE_TRANSITION_DELAY; - // } return DEFAULT_TRANSITION_DELAY; } @@ -1164,82 +1061,6 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::HISTOGRAM_BIND7, new PoolEntry({0})); localDataPoolMap.emplace(startracker::HISTOGRAM_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::TICKS_CONTRAST_SET, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::TIME_CONTRAST_SET, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA0, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA1, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA2, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA3, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA4, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA5, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA6, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA7, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINA8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB0, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB1, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB2, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB3, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB4, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB5, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB6, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB7, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINB8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC0, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC1, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC2, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC3, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC4, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC5, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC6, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC7, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BINC8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND0, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND1, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND2, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND3, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND4, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND5, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND6, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND7, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CONTRAST_BIND8, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry({0})); - - localDataPoolMap.emplace(startracker::DWL_ID, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_PIXX, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_PIXY, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_X_UNCORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_Y_UNCORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_X_CORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_Y_CORRECTED, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_MAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_CXA, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_CYA, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::DWL_QUALITY, new PoolEntry({0})); - - localDataPoolMap.emplace(startracker::MATCHEDSTR_ID, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMFPX, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMFPY, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMCARTX, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMCARTY, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMCARTZ, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CAMMAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBFPX, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBFPY, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBCARTX, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBCARTY, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBCARTZ, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_DBMAGNITUDE, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::MATCHEDSTR_CATALOGID, new PoolEntry({0})); - - localDataPoolMap.emplace(startracker::BLOBPIX_ID, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_X, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_Y, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_TOT_VAL, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_IN_USE, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_BRIGHT_NEIGHBOURS, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::BLOBPIX_REGION, new PoolEntry({0})); - localDataPoolMap.emplace(startracker::CAMERA_MODE, new PoolEntry({0})); localDataPoolMap.emplace(startracker::FOCALLENGTH, new PoolEntry({0})); localDataPoolMap.emplace(startracker::EXPOSURE, new PoolEntry({0})); @@ -1384,6 +1205,8 @@ ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& l localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TIMING, new PoolEntry({0})); localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TEST, new PoolEntry({0})); + + localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry({0})); return RETURN_OK; } @@ -1432,46 +1255,10 @@ ReturnValue_t StarTrackerHandler::scanForActionReply(DeviceCommandId_t* foundId) *foundId = startracker::UPLOAD_IMAGE; break; } - case (startracker::ID::ERROR_RESET): { - *foundId = startracker::RESET_ERROR; - break; - } - case (startracker::ID::ERASE): { - *foundId = startracker::ERASE; - break; - } - case (startracker::ID::UNLOCK): { - *foundId = startracker::UNLOCK; - break; - } case (startracker::ID::CHECKSUM): { *foundId = startracker::CHECKSUM; break; } - case (startracker::ID::SET_TIME): { - *foundId = startracker::SET_TIME; - break; - } - case (startracker::ID::DOWNLOAD_CENTROID): { - *foundId = startracker::DOWNLOAD_CENTROID; - break; - } - case (startracker::ID::UPLOAD_CENTROID): { - *foundId = startracker::UPLOAD_CENTROID; - break; - } - case (startracker::ID::DOWNLOAD_MATCHED_STAR): { - *foundId = startracker::DOWNLOAD_MATCHED_STAR; - break; - } - case (startracker::ID::DOWNLOAD_DBIMAGE): { - *foundId = startracker::DOWNLOAD_DBIMAGE; - break; - } - case (startracker::ID::DOWNLOAD_BLOBPIXEL): { - *foundId = startracker::DOWNLOAD_BLOBPIXEL; - break; - } default: sif::warning << "StarTrackerHandler::scanForActionReply: Unknown parameter reply id" << std::endl; @@ -1638,10 +1425,6 @@ ReturnValue_t StarTrackerHandler::scanForTmReply(DeviceCommandId_t* foundId) { *foundId = startracker::REQ_HISTOGRAM; break; } - case (startracker::ID::CONTRAST): { - *foundId = startracker::REQ_CONTRAST; - break; - } case (startracker::ID::TIME): { *foundId = startracker::REQ_TIME; break; @@ -1678,7 +1461,7 @@ void StarTrackerHandler::handleEvent(EventMessage* eventMessage) { ReturnValue_t StarTrackerHandler::executeFlashReadCommand(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = RETURN_OK; - if (commandDataLen < ReadCmd::MIN_LENGTH) { + if (commandDataLen < FlashReadCmd::MIN_LENGTH) { sif::warning << "StarTrackerHandler::executeFlashReadCommand: Command too short" << std::endl; return COMMAND_TOO_SHORT; } @@ -1716,42 +1499,6 @@ void StarTrackerHandler::prepareBootCommand() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -ReturnValue_t StarTrackerHandler::prepareEraseCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - if (commandDataLen != EraseCmd::LENGTH) { - return INVALID_LENGTH; - } - uint32_t length = 0; - struct EraseActionRequest req; - req.region = *commandData; - arc_pack_erase_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - eraseCmd.rememberRegion = req.region; - return result; -} - -ReturnValue_t StarTrackerHandler::prepareUnlockCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - uint32_t length = 0; - struct UnlockActionRequest req; - req.region = *commandData; - size_t size = sizeof(req.code); - const uint8_t* codePtr = commandData + UnlockCmd::CODE_OFFSET; - result = SerializeAdapter::deSerialize(&req.code, &codePtr, &size, SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - return result; - } - arc_pack_unlock_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen) { struct ChecksumActionRequest req; @@ -1790,140 +1537,6 @@ ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandD return result; } -ReturnValue_t StarTrackerHandler::prepareSetTimeCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct SetTimeActionRequest req; - if (commandDataLen != SetTimeCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareSetTimeCommand: Invalid length" << std::endl; - return INVALID_LENGTH; - } - size_t size = sizeof(req.unixTime); - result = SerializeAdapter::deSerialize(&req.unixTime, commandData, &size, - SerializeIF::Endianness::BIG); - if (result != RETURN_OK) { - sif::debug << "StarTrackerHandler::prepareSetTimeCommand: Deserialization failed" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_settime_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - ReturnValue_t result = RETURN_OK; - struct DownloadCentroidActionRequest req; - if (commandDataLen != DownloadCentroidCmd::LENGTH) { - sif::warning << "StarTrackerHandler::prepareDownloadCentroidCommand: Invalid length" - << std::endl; - return INVALID_LENGTH; - } - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return result; -} - -ReturnValue_t StarTrackerHandler::prepareUploadCentroidCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen > MAX_PATH_SIZE) { - return FILE_PATH_TOO_LONG; - } - ReturnValue_t result = RETURN_OK; - struct UploadCentroidActionRequest req; - std::string jsonFileName = - std::string(reinterpret_cast(commandData), commandDataLen); - NVMParameterBase j(jsonFileName); - result = j.readJsonFile(); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: " << jsonFileName - << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::id, &req.id); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::id << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::pixx, &req.pixx); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::pixx << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::pixy, &req.pixy); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::pixy << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::x_uncorrected, &req.x_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::x_uncorrected << " does not exist" - << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::y_uncorrected, &req.y_uncorrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::y_uncorrected << " does not exist" - << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::x_corrected, &req.x_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::x_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::y_corrected, &req.y_corrected); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::y_corrected << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::magnitude, &req.magnitude); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::magnitude << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::cxa, &req.cxa); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::cxa << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::cya, &req.cya); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::cya << " does not exist" << std::endl; - return result; - } - result = j.getValue(startracker::UploadCentroidKeys::quality, &req.quality); - if (result != RETURN_OK) { - sif::warning << "StarTrackerHandler::prepareUploadCentroidCommand: The key " - << startracker::UploadCentroidKeys::quality << " does not exist" << std::endl; - return result; - } - uint32_t length = 0; - arc_pack_uploadcentroid_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - uploadCentroid.rememberId = req.id; - return result; -} - void StarTrackerHandler::prepareTimeRequest() { uint32_t length = 0; arc_tm_pack_time_req(commandBuffer, &length); @@ -1965,7 +1578,7 @@ void StarTrackerHandler::preparePowerRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -void StarTrackerHandler::prepareRebootCommand() { +void StarTrackerHandler::prepareSwitchToBootloaderCmd() { uint32_t length = 0; struct RebootActionRequest rebootReq; arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length); @@ -2008,23 +1621,6 @@ void StarTrackerHandler::prepareHistogramRequest() { rawPacketLen = dataLinkLayer.getEncodedLength(); } -void StarTrackerHandler::prepareContrastRequest() { - uint32_t length = 0; - arc_tm_pack_contrast_req(commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - -void StarTrackerHandler::prepareErrorResetRequest() { - uint32_t length = 0; - struct ResetErrorSignalActionRequest req; - arc_pack_reseterrorsignal_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); -} - ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet) { @@ -2044,73 +1640,6 @@ ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData return RETURN_OK; } -ReturnValue_t StarTrackerHandler::prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadMatchedStarCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadMatchedStarActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloadmatchedstar_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadDbImageCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadDbImageCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadDBImageActionRequest req; - req.id = *commandData; - uint32_t length = 0; - arc_pack_downloaddbimage_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareDownloadBlobPixelCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != DownloadBlobPixCmd::LENGTH) { - return INVALID_LENGTH; - } - struct DownloadBlobPixelActionRequest req; - req.id = *commandData; - req.type = *(commandData + 1); - if ((req.type != DownloadBlobPixCmd::NORMAL) && (req.type != DownloadBlobPixCmd::FAST)) { - return INVALID_TYPE; - } - uint32_t length = 0; - arc_pack_downloadblobpixel_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::prepareFpgaActionCommand(const uint8_t* commandData, - size_t commandDataLen) { - if (commandDataLen != FpgaActionCmd::LENGTH) { - return INVALID_LENGTH; - } - struct FPGAActionActionRequest req; - req.id = *commandData; - if (req.id != FpgaActionCmd::ID) { - return INVALID_ID; - } - uint32_t length = 0; - arc_pack_fpgaaction_action_req(&req, commandBuffer, &length); - dataLinkLayer.encodeFrame(commandBuffer, length); - rawPacket = dataLinkLayer.getEncodedFrame(); - rawPacketLen = dataLinkLayer.getEncodedLength(); - return RETURN_OK; -} - ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() { uint32_t length = 0; arc_pack_camera_parameter_req(commandBuffer, &length); @@ -2268,34 +1797,6 @@ ReturnValue_t StarTrackerHandler::handleActionReply() { return RETURN_OK; } -ReturnValue_t StarTrackerHandler::handleUploadCentroidReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* reply = dataLinkLayer.getReply(); - if (*(reply + ACTION_DATA_OFFSET) != uploadCentroid.rememberId) { - return UPLOAD_CENTROID_ID_MISMATCH; - } - return RETURN_OK; -} - -ReturnValue_t StarTrackerHandler::handleEraseReply() { - ReturnValue_t result = RETURN_OK; - result = handleActionReply(); - if (result != RETURN_OK) { - return result; - } - const uint8_t* replyData = dataLinkLayer.getReply() + ACTION_DATA_OFFSET; - startracker::EraseReply eraseReply(replyData); - if (eraseReply.getRegion() != eraseCmd.rememberRegion) { - sif::warning << "StarTrackerHandler::handleEraseReply: Region mismatch" << std::endl; - return REGION_MISMATCH; - } - return result; -} - ReturnValue_t StarTrackerHandler::handleChecksumReply() { ReturnValue_t result = RETURN_OK; result = handleActionReply(); @@ -2538,21 +2039,30 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { case startracker::UPLOAD_IMAGE: case startracker::REQ_POWER: case startracker::TAKE_IMAGE: - case startracker::DOWNLOAD_CENTROID: - case startracker::UPLOAD_CENTROID: case startracker::REQ_SOLUTION: case startracker::REQ_TEMPERATURE: case startracker::REQ_HISTOGRAM: - case startracker::REQ_CONTRAST: - case startracker::DOWNLOAD_MATCHED_STAR: - case startracker::DOWNLOAD_DBIMAGE: - case startracker::DOWNLOAD_BLOBPIXEL: - if (!(mode == MODE_ON && submode == startracker::Program::FIRMWARE)) { + case startracker::REQ_CAMERA: + case startracker::REQ_LIMITS: + case startracker::REQ_LOG_LEVEL: + case startracker::REQ_MOUNTING: + case startracker::REQ_IMAGE_PROCESSOR: + case startracker::REQ_CENTROIDING: + case startracker::REQ_LISA: + case startracker::REQ_MATCHING: + case startracker::REQ_TRACKING: + case startracker::REQ_VALIDATION: + case startracker::REQ_ALGO: + case startracker::REQ_SUBSCRIPTION: + case startracker::REQ_LOG_SUBSCRIPTION: + case startracker::REQ_DEBUG_CAMERA: + if (not (mode == MODE_ON && submode == startracker::Program::FIRMWARE)) { return STARTRACKER_RUNNING_BOOTLOADER; } break; case startracker::FIRMWARE_UPDATE: - if (!(mode == MODE_ON && submode == startracker::Program::BOOTLOADER)) { + case startracker::FLASH_READ: + if (not (mode == MODE_ON && submode == startracker::Program::BOOTLOADER)) { return STARTRACKER_RUNNING_FIRMWARE; } break; diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index b414aeb8..f13f78d2 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -85,65 +85,53 @@ class StarTrackerHandler : public DeviceHandlerBase { //! [EXPORT] : [COMMENT] Ping command failed static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1); //! [EXPORT] : [COMMENT] Status in version reply signals error - static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA3); + static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA2); //! [EXPORT] : [COMMENT] Status in interface reply signals error - static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA4); + static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA3); //! [EXPORT] : [COMMENT] Status in power reply signals error - static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA5); + static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA4); //! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error - static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA6); + static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA5); //! [EXPORT] : [COMMENT] Status of reply to action command signals error - static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA7); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t UPLOAD_TOO_SHORT = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Received upload image command with invalid position field - static const ReturnValue_t UPLOAD_INVALID_POSITION = MAKE_RETURN_CODE(0xA8); - //! [EXPORT] : [COMMENT] Position value in upload image reply not matching sent position - static const ReturnValue_t UPLOAD_IMAGE_FAILED = MAKE_RETURN_CODE(0xA9); - //! [EXPORT] : [COMMENT] Received upload image command with invalid length - static const ReturnValue_t INVALID_UPLOAD_COMMAND = MAKE_RETURN_CODE(0xAA); + static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA6); //! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length - static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xAB); + static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xA7); //! [EXPORT] : [COMMENT] Name of file received with command is too long - static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xAC); + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA8); //! [EXPORT] : [COMMENT] Received version reply with invalid program ID - static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xAD); + static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xA9); //! [EXPORT] : [COMMENT] Status field reply signals error - static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAE); - //! [EXPORT] : [COMMENT] Status field of contrast reply signals error - static const ReturnValue_t CONTRAST_REQ_FAILED = MAKE_RETURN_CODE(0xAE); + static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAA); //! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper //! execution) - static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAF); + static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAB); //! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters) - static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xB0); + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xAC); //! [EXPORT] : [COMMENT] Region mismatch between send and received data - static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xB1); + static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xAD); //! [EXPORT] : [COMMENT] Address mismatch between send and received data - static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xB2); + static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xAE); //! [EXPORT] : [COMMENT] Length field mismatch between send and received data - static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xB3); + static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xAF); //! [EXPORT] : [COMMENT] Specified file does not exist - static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB4); - //! [EXPORT] : [COMMENT] Reply to upload centroid does not match commanded centroid id - static const ReturnValue_t UPLOAD_CENTROID_ID_MISMATCH = MAKE_RETURN_CODE(0xB5); + static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB0); //! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field - static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB6); + static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB1); //! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID - static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB7); + static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB2); //! [EXPORT] : [COMMENT] Received reply is too short - static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB8); + static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB3); //! [EXPORT] : [COMMENT] Received reply with invalid CRC - static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB9); + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB4); //! [EXPORT] : [COMMENT] Star tracker handler currently executing a command and using the //! communication interface - static const ReturnValue_t STR_HELPER_EXECUTING = MAKE_RETURN_CODE(0xBA); + static const ReturnValue_t STR_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB5); //! [EXPORT] : [COMMENT] Star tracker is already in firmware mode - static const ReturnValue_t STARTRACKER_ALREADY_BOOTED = MAKE_RETURN_CODE(0xBB); + static const ReturnValue_t STARTRACKER_ALREADY_BOOTED = MAKE_RETURN_CODE(0xB6); //! [EXPORT] : [COMMENT] Star tracker is in firmware mode but must be in bootloader mode to execute this command - static const ReturnValue_t STARTRACKER_RUNNING_FIRMWARE = MAKE_RETURN_CODE(0xBC); + static const ReturnValue_t STARTRACKER_RUNNING_FIRMWARE = MAKE_RETURN_CODE(0xB7); //! [EXPORT] : [COMMENT] Star tracker is in bootloader mode but must be in firmware mode to execute this command - static const ReturnValue_t STARTRACKER_RUNNING_BOOTLOADER = MAKE_RETURN_CODE(0xBD); + static const ReturnValue_t STARTRACKER_RUNNING_BOOTLOADER = MAKE_RETURN_CODE(0xB8); static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER; @@ -155,10 +143,6 @@ class StarTrackerHandler : public DeviceHandlerBase { static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_FILE_NAME = 30; - // position (uint32) + 1024 image data - static const size_t UPLOAD_COMMAND_LEN = 1028; - // Max valid position value in upload image command - static const uint16_t MAX_POSITION = 4095; static const uint8_t STATUS_OFFSET = 1; static const uint8_t PARAMS_OFFSET = 1; static const uint8_t TICKS_OFFSET = 2; @@ -175,33 +159,12 @@ class StarTrackerHandler : public DeviceHandlerBase { static const uint32_t BOOT_TIMEOUT = 1000; static const uint32_t DEFAULT_TRANSITION_DELAY = 15000; - class WriteCmd { - public: - static const uint8_t ADDRESS_OFFSET = 1; - static const uint8_t FILE_OFFSET = 5; - // Minimum length of a write command (region, address and filename) - static const size_t MIN_LENGTH = 7; - }; - - class ReadCmd { + class FlashReadCmd { public: // Minimum length of a read command (region, length and filename) static const size_t MIN_LENGTH = 7; }; - class EraseCmd { - public: - static const uint8_t LENGTH = 1; - uint8_t rememberRegion = 0; - }; - - EraseCmd eraseCmd; - - class UnlockCmd { - public: - static const uint8_t CODE_OFFSET = 1; - }; - class ChecksumCmd { public: static const uint8_t ADDRESS_OFFSET = 1; @@ -215,51 +178,6 @@ class StarTrackerHandler : public DeviceHandlerBase { ChecksumCmd checksumCmd; - class SetTimeCmd { - public: - static const uint8_t LENGTH = 8; - }; - - class DownloadCentroidCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class UploadCentroid { - public: - uint8_t rememberId = 0; - }; - - UploadCentroid uploadCentroid; - - class DownloadMatchedStarCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadDbImageCmd { - public: - static const uint8_t LENGTH = 1; - }; - - class DownloadBlobPixCmd { - public: - static const uint8_t LENGTH = 2; - static const uint8_t NORMAL = 0; - static const uint8_t FAST = 1; - }; - - class FpgaDownloadCmd { - public: - static const uint8_t MIN_LENGTH = 10; - }; - - class FpgaActionCmd { - public: - static const uint8_t LENGTH = 1; - static const uint8_t ID = 3; - }; - MessageQueueIF* eventQueue = nullptr; ArcsecDatalinkLayer dataLinkLayer; @@ -271,12 +189,7 @@ class StarTrackerHandler : public DeviceHandlerBase { startracker::TimeSet timeSet; startracker::SolutionSet solutionSet; startracker::HistogramSet histogramSet; - startracker::ContrastSet contrastSet; startracker::ChecksumSet checksumSet; - startracker::DownloadCentroidSet downloadCentroidSet; - startracker::DownloadMatchedStar downloadMatchedStar; - startracker::DownloadDBImage downloadDbImage; - startracker::DownloadBlobPixel downloadBlobPixel; startracker::CameraSet cameraSet; startracker::LimitsSet limitsSet; startracker::LogLevelSet loglevelSet; @@ -312,7 +225,8 @@ class StarTrackerHandler : public DeviceHandlerBase { #endif enum class NormalState { - TEMPERATURE_REQUEST + TEMPERATURE_REQUEST, + SOLUTION_REQUEST }; NormalState normalState = NormalState::TEMPERATURE_REQUEST; @@ -415,36 +329,11 @@ class StarTrackerHandler : public DeviceHandlerBase { */ void prepareBootCommand(); - /** - * @brief Fills command buffer with command to erase a flash region - */ - ReturnValue_t prepareEraseCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to unlock flash region - */ - ReturnValue_t prepareUnlockCommand(const uint8_t* commandData, size_t commandDataLen); - /** * @brief Fills command buffer with command to get the checksum of a flash part */ ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen); - /** - * @brief Fills command buffer with command to set the unix time - */ - ReturnValue_t prepareSetTimeCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to request a centroid - */ - ReturnValue_t prepareDownloadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with command to upload a centroid for testing purpose - */ - ReturnValue_t prepareUploadCentroidCommand(const uint8_t* commandData, size_t commandDataLen); - /** * @brief Fills the command buffer with the command to take an image. */ @@ -468,7 +357,7 @@ class StarTrackerHandler : public DeviceHandlerBase { /** * @brief Fills command buffer with data to reboot star tracker. */ - void prepareRebootCommand(); + void prepareSwitchToBootloaderCmd(); /** * @brief Fills command buffer with data to subscribe to a telemetry packet. @@ -493,13 +382,6 @@ class StarTrackerHandler : public DeviceHandlerBase { */ void prepareHistogramRequest(); - void prepareContrastRequest(); - - /** - * @brief Fills command buffer with command to reset the error signal of the star tracker - */ - void prepareErrorResetRequest(); - /** * @brief Reads parameters from json file specified by string in commandData and * prepares the command to apply the parameter set to the star tracker @@ -513,27 +395,6 @@ class StarTrackerHandler : public DeviceHandlerBase { ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen, ArcsecJsonParamBase& paramSet); - /** - * @brief Fills command buffer with data to request matched star. - */ - ReturnValue_t prepareDownloadMatchedStarCommand(const uint8_t* commandData, - size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request matched star coordinates. - */ - ReturnValue_t prepareDownloadDbImageCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief Fills command buffer with data to request output of the blob filter algorithm. - */ - ReturnValue_t prepareDownloadBlobPixelCommand(const uint8_t* commandData, size_t commandDataLen); - - /** - * @brief With this command the FPGA update will be applied to the star tracker - */ - ReturnValue_t prepareFpgaActionCommand(const uint8_t* commandData, size_t commandDataLen); - /** * @brief The following function will fill the command buffer with the command to request * a parameter set. @@ -568,11 +429,6 @@ class StarTrackerHandler : public DeviceHandlerBase { */ ReturnValue_t handleUploadCentroidReply(); - /** - * @brief Handles reply to erase command - */ - ReturnValue_t handleEraseReply(); - /** * @brief Handles reply to checksum command */ diff --git a/linux/devices/startracker/StrHelper.cpp b/linux/devices/startracker/StrHelper.cpp index 8d42b2e5..ef914727 100644 --- a/linux/devices/startracker/StrHelper.cpp +++ b/linux/devices/startracker/StrHelper.cpp @@ -430,6 +430,9 @@ ReturnValue_t StrHelper::performFlashRead() { req.region++; } retries = 0; +#if OBSW_DEBUG_STARTRACKER == 1 + printProgress(bytesRead, flashRead.size); +#endif /* OBSW_DEBUG_STARTRACKER == 1 */ } file.close(); return RETURN_OK; diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index dc72a0f6..933a027b 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 138 translations. + * @brief Auto-generated event translation file. Contains 139 translations. * @details - * Generated on: 2022-02-22 09:46:40 + * Generated on: 2022-02-27 15:36:42 */ #include "translateEvents.h" @@ -108,6 +108,7 @@ const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAIL const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *ERROR_STATE_STRING = "ERROR_STATE"; const char *BOOTING_FIRMWARE_FAILED_STRING = "BOOTING_FIRMWARE_FAILED"; +const char *BOOTING_BOOTLOADER_FAILED_STRING = "BOOTING_BOOTLOADER_FAILED"; const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; @@ -352,6 +353,8 @@ const char * translateEvents(Event event) { return ERROR_STATE_STRING; case(11401): return BOOTING_FIRMWARE_FAILED_STRING; + case(11402): + return BOOTING_BOOTLOADER_FAILED_STRING; case(11501): return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; case(11502): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 45bebccf..dcd950fd 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 112 translations. - * Generated on: 2022-02-25 14:35:18 + * Generated on: 2022-02-27 15:36:48 */ #include "translateObjects.h" diff --git a/scripts/egse-port.sh b/scripts/egse-port.sh index edcd05e2..b76cd0b2 100644 --- a/scripts/egse-port.sh +++ b/scripts/egse-port.sh @@ -1,6 +1,6 @@ #!/bin/bash -echo "-L 1534:localhost:1534 portforwarding for tcf agent" -echo "-L 1537:localhost:7301 for TMTC commanding using the TCP/IP IF" +echo "-L 1534:localhost:1534 pi@192.168.18.31 portforwarding for tcf agent" +echo "-L 1537:localhost:7301 pi@192.168.18.31 for TMTC commanding using the TCP/IP IF" ssh -L 1534:localhost:1534 \ -L 1537:localhost:7301 pi@192.168.18.31 \ No newline at end of file