eive-obsw/mission/acs/str/StarTrackerHandler.cpp

2159 lines
86 KiB
C++
Raw Normal View History

2021-12-06 19:36:21 +01:00
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <mission/acs/str/StarTrackerHandler.h>
#include <mission/acs/str/strHelpers.h>
#include <mission/acs/str/strJsonCommands.h>
2022-01-17 15:58:27 +01:00
2023-04-13 18:09:02 +02:00
extern "C" {
2023-04-15 15:15:06 +02:00
#include <sagitta/client/actionreq.h>
#include <sagitta/client/client_tm_structs.h>
#include <sagitta/client/parameter.h>
#include <sagitta/client/telemetry.h>
#include <wire/common/genericstructs.h>
2023-04-13 18:09:02 +02:00
}
2023-04-13 17:55:56 +02:00
2023-03-08 01:21:18 +01:00
#include <atomic>
2022-01-17 15:58:27 +01:00
#include <fstream>
2023-03-08 01:21:18 +01:00
#include <thread>
2022-01-17 15:58:27 +01:00
#include "OBSWConfig.h"
2023-05-11 20:21:44 +02:00
#include "eive/definitions.h"
2021-07-07 12:12:01 +02:00
2023-03-08 01:21:18 +01:00
std::atomic_bool JCFG_DONE(false);
2022-01-17 15:58:27 +01:00
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
2023-03-21 20:35:28 +01:00
const char* jsonFileStr, StrComHandler* strHelper,
2023-03-07 18:47:16 +01:00
power::Switch_t powerSwitch)
2022-02-25 14:24:51 +01:00
: DeviceHandlerBase(objectId, comIF, comCookie),
temperatureSet(this),
versionSet(this),
powerSet(this),
interfaceSet(this),
timeSet(this),
solutionSet(this),
histogramSet(this),
checksumSet(this),
cameraSet(this),
limitsSet(this),
loglevelSet(this),
mountingSet(this),
imageProcessorSet(this),
centroidingSet(this),
lisaSet(this),
matchingSet(this),
trackingSet(this),
validationSet(this),
algoSet(this),
subscriptionSet(this),
logSubscriptionSet(this),
debugCameraSet(this),
2022-03-30 09:19:30 +02:00
strHelper(strHelper),
2023-03-07 18:47:16 +01:00
paramJsonFile(jsonFileStr),
2022-03-30 09:19:30 +02:00
powerSwitch(powerSwitch) {
2022-02-25 14:24:51 +01:00
if (comCookie == nullptr) {
sif::error << "StarTrackerHandler: Invalid com cookie" << std::endl;
}
if (strHelper == nullptr) {
sif::error << "StarTrackerHandler: Invalid str image loader" << std::endl;
}
eventQueue = QueueFactory::instance()->createMessageQueue(EventMessage::EVENT_MESSAGE_SIZE * 5);
}
StarTrackerHandler::~StarTrackerHandler() {}
2021-12-02 08:05:33 +01:00
void StarTrackerHandler::doStartUp() {
switch (startupState) {
case StartupState::IDLE:
startupState = StartupState::CHECK_PROGRAM;
return;
case StartupState::BOOT_BOOTLOADER:
// This step is required in case the star tracker is already in firmware mode to harmonize
// the device handler's submode to the star tracker's mode
return;
case StartupState::DONE:
if (jcfgCountdown.isBusy()) {
startupState = StartupState::WAIT_JCFG;
return;
}
startupState = StartupState::IDLE;
break;
case StartupState::WAIT_JCFG: {
if (jcfgCountdown.hasTimedOut()) {
startupState = StartupState::IDLE;
break;
}
return;
}
default:
return;
}
solutionSet.setReportingEnabled(true);
startupState = StartupState::DONE;
internalState = InternalState::IDLE;
setMode(_MODE_TO_ON);
}
void StarTrackerHandler::doShutDown() {
// If the star tracker is shutdown also stop all running processes in the image loader task
strHelper->stopProcess();
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
bootState = FwBootState::NONE;
solutionSet.setReportingEnabled(false);
2023-06-17 19:17:50 +02:00
{
PoolReadGuard pg(&solutionSet);
solutionSet.caliQw.value = 0.0;
solutionSet.caliQx.value = 0.0;
solutionSet.caliQy.value = 0.0;
solutionSet.caliQz.value = 0.0;
solutionSet.isTrustWorthy.value = 0;
solutionSet.setValidity(false, true);
}
{
PoolReadGuard pg(&temperatureSet);
temperatureSet.setValidity(false, true);
}
reinitNextSetParam = false;
setMode(_MODE_POWER_DOWN);
}
2021-12-02 08:05:33 +01:00
ReturnValue_t StarTrackerHandler::initialize() {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
result = DeviceHandlerBase::initialize();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-08 01:21:18 +01:00
// Spin up a thread to do the JSON initialization, takes 200-250 ms which would
// delay whole satellite boot process.
jcfgCountdown.resetTimer();
jsonCfgTask = std::thread{setUpJsonCfgs, std::ref(jcfgs), paramJsonFile.c_str()};
2023-03-07 18:47:16 +01:00
2022-02-25 14:24:51 +01:00
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) {
2021-12-02 08:05:33 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-02-25 14:24:51 +01:00
sif::error << "StarTrackerHandler::initialize: Invalid event manager" << std::endl;
2021-12-02 08:05:33 +01:00
#endif
2022-02-25 14:24:51 +01:00
return ObjectManagerIF::CHILD_INIT_FAILED;
;
}
result = manager->registerListener(eventQueue->getId());
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
result = manager->subscribeToEventRange(eventQueue->getId(),
2023-03-21 20:35:28 +01:00
event::getEventId(StrComHandler::IMAGE_UPLOAD_FAILED),
event::getEventId(StrComHandler::FIRMWARE_UPDATE_FAILED));
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2021-12-02 08:05:33 +01:00
#if FSFW_CPP_OSTREAM_ENABLED == 1
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::initialize: Failed to subscribe to events from "
" str helper"
<< std::endl;
2021-12-02 08:05:33 +01:00
#endif
2022-02-25 14:24:51 +01:00
return ObjectManagerIF::CHILD_INIT_FAILED;
}
2022-01-17 15:58:27 +01:00
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-30 16:01:02 +01:00
}
2021-12-02 08:05:33 +01:00
ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
2022-02-25 14:24:51 +01:00
const uint8_t* data, size_t size) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
switch (actionId) {
case (startracker::STOP_IMAGE_LOADER): {
strHelper->stopProcess();
return EXECUTION_FINISHED;
}
case (startracker::SET_JSON_FILE_NAME): {
2023-05-11 20:21:44 +02:00
if (size > config::MAX_PATH_SIZE) {
2022-02-25 14:24:51 +01:00
return FILE_PATH_TOO_LONG;
}
paramJsonFile = std::string(reinterpret_cast<const char*>(data), size);
return EXECUTION_FINISHED;
}
case (startracker::DISABLE_TIMESTAMP_GENERATION):
strHelper->disableTimestamping();
2022-02-27 15:46:06 +01:00
return EXECUTION_FINISHED;
2022-02-25 14:24:51 +01:00
case (startracker::ENABLE_TIMESTAMP_GENERATION):
strHelper->enableTimestamping();
2022-02-27 15:46:06 +01:00
return EXECUTION_FINISHED;
2022-02-25 14:24:51 +01:00
default:
break;
}
if (strHelperHandlingSpecialRequest == true) {
2022-02-25 14:24:51 +01:00
return STR_HELPER_EXECUTING;
}
result = checkMode(actionId);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
result = checkCommand(actionId);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
// Intercept image loader commands which do not follow the common DHB communication flow
switch (actionId) {
case (startracker::UPLOAD_IMAGE): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-05-11 20:21:44 +02:00
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
2022-02-25 14:24:51 +01:00
return FILE_PATH_TOO_LONG;
}
result = strHelper->startImageUpload(std::string(reinterpret_cast<const char*>(data), size));
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
strHelperHandlingSpecialRequest = true;
2022-02-25 14:24:51 +01:00
return EXECUTION_FINISHED;
}
case (startracker::DOWNLOAD_IMAGE): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-05-11 20:21:44 +02:00
if (size > config::MAX_PATH_SIZE) {
2022-02-25 14:24:51 +01:00
return FILE_PATH_TOO_LONG;
}
result =
strHelper->startImageDownload(std::string(reinterpret_cast<const char*>(data), size));
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
strHelperHandlingSpecialRequest = true;
2022-02-25 14:24:51 +01:00
return EXECUTION_FINISHED;
}
case (startracker::FLASH_READ): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
result = executeFlashReadCommand(data, size);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
strHelperHandlingSpecialRequest = true;
2022-02-25 14:24:51 +01:00
return EXECUTION_FINISHED;
}
2022-02-27 15:46:06 +01:00
case (startracker::CHANGE_IMAGE_DOWNLOAD_FILE): {
2023-05-11 20:21:44 +02:00
if (size > config::MAX_FILENAME_SIZE) {
2022-02-25 14:24:51 +01:00
return FILENAME_TOO_LONG;
}
strHelper->setDownloadImageName(std::string(reinterpret_cast<const char*>(data), size));
return EXECUTION_FINISHED;
}
2022-02-27 15:46:06 +01:00
case (startracker::SET_FLASH_READ_FILENAME): {
2023-05-11 20:21:44 +02:00
if (size > config::MAX_FILENAME_SIZE) {
2022-02-25 14:24:51 +01:00
return FILENAME_TOO_LONG;
}
2022-02-27 15:46:06 +01:00
strHelper->setFlashReadFilename(std::string(reinterpret_cast<const char*>(data), size));
2022-02-25 14:24:51 +01:00
return EXECUTION_FINISHED;
}
case (startracker::FIRMWARE_UPDATE): {
result = DeviceHandlerBase::acceptExternalDeviceCommands();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-05-11 20:21:44 +02:00
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
2022-02-25 14:24:51 +01:00
return FILE_PATH_TOO_LONG;
}
result =
strHelper->startFirmwareUpdate(std::string(reinterpret_cast<const char*>(data), size));
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
strHelperHandlingSpecialRequest = true;
2022-02-25 14:24:51 +01:00
return EXECUTION_FINISHED;
}
default:
break;
}
2023-03-31 18:51:16 +02:00
// In case the JSON has changed, reinitiate the next parameter set to update.
reinitNextSetParam = true;
2022-02-25 14:24:51 +01:00
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
2021-12-02 08:05:33 +01:00
}
void StarTrackerHandler::performOperationHook() {
2022-02-25 14:24:51 +01:00
EventMessage event;
2022-08-24 17:27:47 +02:00
for (ReturnValue_t result = eventQueue->receiveMessage(&event); result == returnvalue::OK;
2022-02-25 14:24:51 +01:00
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;
}
}
}
2023-04-05 15:11:37 +02:00
Submode_t StarTrackerHandler::getInitialSubmode() { return startracker::SUBMODE_BOOTLOADER; }
2021-07-07 12:12:01 +02:00
2022-01-17 15:58:27 +01:00
ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (strHelperHandlingSpecialRequest) {
return NOTHING_TO_SEND;
}
2022-02-25 14:24:51 +01:00
switch (normalState) {
case NormalState::TEMPERATURE_REQUEST:
*id = startracker::REQ_TEMPERATURE;
2022-02-27 15:46:06 +01:00
normalState = NormalState::SOLUTION_REQUEST;
break;
case NormalState::SOLUTION_REQUEST:
*id = startracker::REQ_SOLUTION;
normalState = NormalState::TEMPERATURE_REQUEST;
2022-02-25 14:24:51 +01:00
break;
default:
sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid normal step"
<< std::endl;
2022-02-27 15:46:06 +01:00
return NOTHING_TO_SEND;
2022-02-25 14:24:51 +01:00
}
return buildCommandFromCommand(*id, NULL, 0);
2021-07-07 12:12:01 +02:00
}
2022-01-17 15:58:27 +01:00
ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
2022-02-25 14:24:51 +01:00
switch (internalState) {
2023-03-20 17:51:10 +01:00
case InternalState::BOOT_FIRMWARE: {
if (bootState == FwBootState::WAIT_FOR_EXECUTION or bootState == FwBootState::VERIFY_BOOT) {
return NOTHING_TO_SEND;
}
if (bootState == FwBootState::NONE) {
*id = startracker::BOOT;
bootCountdown.setTimeout(BOOT_TIMEOUT);
bootState = FwBootState::BOOT_DELAY;
return buildCommandFromCommand(*id, nullptr, 0);
}
if (bootState == FwBootState::BOOT_DELAY) {
if (bootCountdown.isBusy()) {
return NOTHING_TO_SEND;
}
2023-03-31 18:51:16 +02:00
// Was already done.
reinitNextSetParam = false;
2023-03-20 17:51:10 +01:00
bootState = FwBootState::REQ_VERSION;
}
switch (bootState) {
case (FwBootState::REQ_VERSION): {
bootState = FwBootState::VERIFY_BOOT;
// Again read program to check if firmware boot was successful
*id = startracker::REQ_VERSION;
return buildCommandFromCommand(*id, nullptr, 0);
}
case (FwBootState::LOGLEVEL): {
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::LOGLEVEL;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case (FwBootState::LIMITS): {
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::LIMITS;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case (FwBootState::TRACKING): {
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::TRACKING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case FwBootState::MOUNTING:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::MOUNTING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::IMAGE_PROCESSOR:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::IMAGE_PROCESSOR;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::CAMERA:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::CAMERA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::CENTROIDING:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::CENTROIDING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::LISA:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::LISA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::MATCHING:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::MATCHING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::VALIDATION:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::VALIDATION;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::ALGO:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::ALGO;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::LOG_SUBSCRIPTION:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::LOGSUBSCRIPTION;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::DEBUG_CAMERA:
bootState = FwBootState::WAIT_FOR_EXECUTION;
*id = startracker::DEBUG_CAMERA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
default: {
sif::error << "STR: Unexpected boot state" << (int)bootState << std::endl;
return NOTHING_TO_SEND;
}
}
}
2022-02-25 14:24:51 +01:00
case InternalState::BOOT_BOOTLOADER:
internalState = InternalState::BOOTLOADER_CHECK;
*id = startracker::SWITCH_TO_BOOTLOADER_PROGRAM;
return buildCommandFromCommand(*id, nullptr, 0);
case InternalState::BOOTLOADER_CHECK:
*id = startracker::REQ_VERSION;
return buildCommandFromCommand(*id, nullptr, 0);
default:
break;
}
switch (startupState) {
case StartupState::CHECK_PROGRAM:
startupState = StartupState::WAIT_CHECK_PROGRAM;
*id = startracker::REQ_VERSION;
return buildCommandFromCommand(*id, nullptr, 0);
break;
case StartupState::BOOT_BOOTLOADER:
startupState = StartupState::CHECK_PROGRAM;
*id = startracker::SWITCH_TO_BOOTLOADER_PROGRAM;
return buildCommandFromCommand(*id, nullptr, 0);
break;
default:
break;
}
return NOTHING_TO_SEND;
2021-07-07 12:12:01 +02:00
}
ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
2022-02-25 14:24:51 +01:00
const uint8_t* commandData,
size_t commandDataLen) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
switch (deviceCommand) {
case (startracker::PING_REQUEST): {
preparePingRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_TIME): {
prepareTimeRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::BOOT): {
prepareBootCommand();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_VERSION): {
prepareVersionRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_INTERFACE): {
prepareInterfaceRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_POWER): {
preparePowerRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::SWITCH_TO_BOOTLOADER_PROGRAM): {
2022-02-27 15:46:06 +01:00
prepareSwitchToBootloaderCmd();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::TAKE_IMAGE): {
prepareTakeImageCommand(commandData);
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::SUBSCRIPTION): {
2023-04-01 15:33:02 +02:00
result =
prepareParamCommand(commandData, commandDataLen, jcfgs.subscription, reinitNextSetParam);
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_SOLUTION): {
prepareSolutionRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_TEMPERATURE): {
prepareTemperatureRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::REQ_HISTOGRAM): {
prepareHistogramRequest();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
}
case (startracker::LIMITS): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.limits, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::MOUNTING): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.mounting, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::IMAGE_PROCESSOR): {
2023-04-01 15:33:02 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.imageProcessor,
reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::CAMERA): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.camera, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::CENTROIDING): {
2023-04-01 15:33:02 +02:00
result =
prepareParamCommand(commandData, commandDataLen, jcfgs.centroiding, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::LISA): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.lisa, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::MATCHING): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.matching, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::VALIDATION): {
2023-04-01 15:33:02 +02:00
result =
prepareParamCommand(commandData, commandDataLen, jcfgs.validation, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::ALGO): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.algo, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::TRACKING): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.tracking, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::LOGLEVEL): {
2023-03-31 18:51:16 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.logLevel, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::LOGSUBSCRIPTION): {
2023-04-01 15:33:02 +02:00
result = prepareParamCommand(commandData, commandDataLen, jcfgs.logSubscription,
reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::DEBUG_CAMERA): {
2023-04-01 15:33:02 +02:00
result =
prepareParamCommand(commandData, commandDataLen, jcfgs.debugCamera, reinitNextSetParam);
2022-02-25 14:24:51 +01:00
return result;
}
case (startracker::CHECKSUM): {
result = prepareChecksumCommand(commandData, commandDataLen);
return result;
}
case (startracker::REQ_CAMERA): {
result = prepareRequestCameraParams();
return result;
}
case (startracker::REQ_LIMITS): {
result = prepareRequestLimitsParams();
return result;
}
case (startracker::REQ_LOG_LEVEL): {
result = prepareRequestLogLevelParams();
return result;
}
case (startracker::REQ_MOUNTING): {
result = prepareRequestMountingParams();
return result;
}
case (startracker::REQ_IMAGE_PROCESSOR): {
result = prepareRequestImageProcessorParams();
return result;
}
case (startracker::REQ_CENTROIDING): {
result = prepareRequestCentroidingParams();
return result;
}
case (startracker::REQ_LISA): {
result = prepareRequestLisaParams();
return result;
}
case (startracker::REQ_MATCHING): {
result = prepareRequestMatchingParams();
return result;
}
case (startracker::REQ_TRACKING): {
result = prepareRequestTrackingParams();
return result;
}
case (startracker::REQ_VALIDATION): {
result = prepareRequestValidationParams();
return result;
}
case (startracker::REQ_ALGO): {
result = prepareRequestAlgoParams();
return result;
}
case (startracker::REQ_SUBSCRIPTION): {
result = prepareRequestSubscriptionParams();
return result;
}
case (startracker::REQ_LOG_SUBSCRIPTION): {
result = prepareRequestLogSubscriptionParams();
return result;
}
case (startracker::REQ_DEBUG_CAMERA): {
result = prepareRequestDebugCameraParams();
return result;
}
default:
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
}
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2021-07-07 12:12:01 +02:00
}
void StarTrackerHandler::fillCommandAndReplyMap() {
2022-02-25 14:24:51 +01:00
/** 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::SUBSCRIPTION, 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::LOGLEVEL, 3, nullptr,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::LOGSUBSCRIPTION, 3, nullptr,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::DEBUG_CAMERA, 3, nullptr,
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::IMAGE_PROCESSOR, 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,
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);
2022-02-27 15:46:06 +01:00
this->insertInCommandAndReplyMap(startracker::CHECKSUM, 3, &checksumSet,
2022-02-25 14:24:51 +01:00
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CAMERA, 3, &cameraSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_LIMITS, 3, &limitsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_LOG_LEVEL, 3, &loglevelSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_MOUNTING, 3, &mountingSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_IMAGE_PROCESSOR, 3, &imageProcessorSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CENTROIDING, 3, &centroidingSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_LISA, 3, &lisaSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_MATCHING, 3, &matchingSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_TRACKING, 3, &trackingSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_VALIDATION, 3, &validationSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_ALGO, 3, &algoSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_SUBSCRIPTION, 3, &subscriptionSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_LOG_SUBSCRIPTION, 3, &logSubscriptionSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_DEBUG_CAMERA, 3, &debugCameraSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
2021-07-07 12:12:01 +02:00
}
ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) {
if (getMode() == MODE_NORMAL && mode == MODE_ON) {
2022-02-25 14:24:51 +01:00
return TRANS_NOT_ALLOWED;
}
switch (mode) {
case MODE_OFF:
case MODE_NORMAL:
case MODE_RAW:
if (submode == SUBMODE_NONE) {
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
} else {
return INVALID_SUBMODE;
}
case MODE_ON:
2023-04-05 15:11:37 +02:00
if (submode == startracker::SUBMODE_BOOTLOADER || submode == startracker::SUBMODE_FIRMWARE) {
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-25 14:24:51 +01:00
} else {
return INVALID_SUBMODE;
}
default:
return HasModesIF::INVALID_MODE;
}
}
2022-02-23 18:15:34 +01:00
void StarTrackerHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
switch (getMode()) {
2022-02-25 14:24:51 +01:00
case _MODE_TO_ON:
doOnTransition(subModeFrom);
break;
case _MODE_TO_RAW:
setMode(MODE_RAW);
break;
case _MODE_TO_NORMAL:
doNormalTransition(modeFrom, subModeFrom);
break;
case _MODE_POWER_DOWN:
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
break;
default:
break;
}
2022-02-23 18:15:34 +01:00
}
void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) {
2023-04-05 15:11:37 +02:00
using namespace startracker;
uint8_t dhbSubmode = getSubmode();
2023-03-20 15:16:20 +01:00
// We hide that the transition to submode firmware actually goes through the submode bootloader.
// This is because the startracker always starts in bootloader mode but we want to allow direct
// transitions to firmware mode.
2023-03-20 17:51:10 +01:00
if (startupState == StartupState::DONE) {
2023-03-20 15:16:20 +01:00
subModeFrom = SUBMODE_BOOTLOADER;
}
if (dhbSubmode == SUBMODE_NONE) {
bootFirmware(MODE_ON);
}
if (dhbSubmode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_FIRMWARE) {
2022-02-25 14:24:51 +01:00
bootBootloader();
} else if (dhbSubmode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_FIRMWARE) {
2022-02-25 14:24:51 +01:00
setMode(MODE_ON);
} else if (dhbSubmode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_BOOTLOADER) {
2022-02-25 14:24:51 +01:00
bootFirmware(MODE_ON);
} else if (dhbSubmode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_BOOTLOADER) {
2022-02-25 14:24:51 +01:00
setMode(MODE_ON);
} else if (dhbSubmode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_NONE) {
2022-02-25 14:24:51 +01:00
setMode(MODE_ON);
} else if (dhbSubmode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_NONE) {
2022-02-25 14:24:51 +01:00
setMode(MODE_ON);
}
2022-02-23 18:15:34 +01:00
}
void StarTrackerHandler::doNormalTransition(Mode_t modeFrom, Submode_t subModeFrom) {
2023-04-05 15:11:37 +02:00
using namespace startracker;
2022-02-25 14:24:51 +01:00
if (subModeFrom == SUBMODE_FIRMWARE) {
setMode(MODE_NORMAL);
} else if (subModeFrom == SUBMODE_BOOTLOADER) {
bootFirmware(MODE_NORMAL);
} else if (modeFrom == MODE_NORMAL && subModeFrom == SUBMODE_NONE) {
// Device handler already in mode normal
setMode(MODE_NORMAL);
}
2022-02-23 18:15:34 +01:00
}
void StarTrackerHandler::bootFirmware(Mode_t toMode) {
2022-02-25 14:24:51 +01:00
switch (internalState) {
case InternalState::IDLE:
2023-03-20 17:51:10 +01:00
sif::info << "STR: Booting to firmware mode" << std::endl;
internalState = InternalState::BOOT_FIRMWARE;
2022-02-25 14:24:51 +01:00
break;
2023-03-20 17:51:10 +01:00
case InternalState::BOOT_FIRMWARE:
2022-02-25 14:24:51 +01:00
break;
case InternalState::FAILED_FIRMWARE_BOOT:
internalState = InternalState::IDLE;
break;
case InternalState::DONE:
2023-03-20 15:16:20 +01:00
if (toMode == MODE_NORMAL) {
setMode(toMode, 0);
} else {
2023-04-05 15:11:37 +02:00
setMode(toMode, startracker::SUBMODE_FIRMWARE);
2023-03-20 15:16:20 +01:00
}
2023-03-20 17:51:10 +01:00
sif::info << "STR: Firmware boot success" << std::endl;
2022-02-25 14:24:51 +01:00
internalState = InternalState::IDLE;
2023-03-20 17:51:10 +01:00
startupState = StartupState::IDLE;
2022-02-25 14:24:51 +01:00
break;
default:
return;
}
2022-02-23 18:15:34 +01:00
}
2023-03-08 01:21:18 +01:00
void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonFile) {
cfgs.tracking.init(paramJsonFile);
cfgs.logLevel.init(paramJsonFile);
cfgs.logSubscription.init(paramJsonFile);
cfgs.debugCamera.init(paramJsonFile);
cfgs.algo.init(paramJsonFile);
cfgs.validation.init(paramJsonFile);
cfgs.matching.init(paramJsonFile);
cfgs.lisa.init(paramJsonFile);
cfgs.centroiding.init(paramJsonFile);
cfgs.camera.init(paramJsonFile);
cfgs.imageProcessor.init(paramJsonFile);
cfgs.mounting.init(paramJsonFile);
cfgs.limits.init(paramJsonFile);
cfgs.subscription.init(paramJsonFile);
JCFG_DONE = true;
}
2022-02-23 18:15:34 +01:00
void StarTrackerHandler::bootBootloader() {
2022-02-25 14:24:51 +01:00
if (internalState == InternalState::IDLE) {
internalState = InternalState::BOOT_BOOTLOADER;
2023-03-20 17:51:10 +01:00
} else if (internalState == InternalState::FAILED_BOOTLOADER_BOOT) {
2022-02-25 14:24:51 +01:00
internalState = InternalState::IDLE;
} else if (internalState == InternalState::DONE) {
internalState = InternalState::IDLE;
2023-03-20 17:51:10 +01:00
startupState = StartupState::IDLE;
2022-02-25 14:24:51 +01:00
setMode(MODE_ON);
}
2022-02-23 18:15:34 +01:00
}
2022-01-17 15:58:27 +01:00
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize,
2022-02-25 14:24:51 +01:00
DeviceCommandId_t* foundId, size_t* foundLen) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
2023-03-21 20:35:28 +01:00
if (remainingSize == 0) {
*foundLen = remainingSize;
return returnvalue::OK;
}
if (remainingSize < 3) {
sif::error << "StarTrackerHandler: Reply packet with length less than 3 is invalid"
<< std::endl;
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
switch (startracker::getReplyFrameType(start)) {
2022-02-25 14:24:51 +01:00
case TMTC_ACTIONREPLY: {
*foundLen = remainingSize;
return scanForActionReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
break;
}
case TMTC_SETPARAMREPLY: {
*foundLen = remainingSize;
return scanForSetParameterReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
break;
}
case TMTC_PARAMREPLY: {
*foundLen = remainingSize;
return scanForGetParameterReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
break;
}
case TMTC_TELEMETRYREPLYA:
case TMTC_TELEMETRYREPLY: {
*foundLen = remainingSize;
return scanForTmReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
break;
}
default: {
sif::debug << "StarTrackerHandler::scanForReply: Reply has invalid type id" << std::endl;
2022-08-24 17:27:47 +02:00
result = returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
}
return result;
2021-07-07 12:12:01 +02:00
}
2022-01-17 15:58:27 +01:00
ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
2022-02-25 14:24:51 +01:00
const uint8_t* packet) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
switch (id) {
case (startracker::REQ_TIME): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, timeSet, startracker::TimeSet::SIZE, "REQ_TIME");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::PING_REQUEST): {
2023-03-21 20:35:28 +01:00
result = handlePingReply(packet);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::BOOT):
case (startracker::TAKE_IMAGE):
break;
case (startracker::CHECKSUM): {
2023-03-21 20:35:28 +01:00
result = handleChecksumReply(packet);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_VERSION): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, versionSet, startracker::VersionSet::SIZE, "REQ_VERSION");
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
result = checkProgram();
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
break;
}
case (startracker::REQ_INTERFACE): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, interfaceSet, startracker::InterfaceSet::SIZE, "REQ_INTERFACE");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_POWER): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, powerSet, startracker::PowerSet::SIZE, "REQ_POWER");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_SOLUTION): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, solutionSet, startracker::SolutionSet::SIZE, "REQ_SOLUTION");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_TEMPERATURE): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, temperatureSet, startracker::TemperatureSet::SIZE, "REQ_TEMP");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_HISTOGRAM): {
2023-04-16 04:04:57 +02:00
result = handleTm(packet, histogramSet, startracker::HistogramSet::SIZE, "REQ_HISTO");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::SUBSCRIPTION):
case (startracker::LOGLEVEL):
case (startracker::LOGSUBSCRIPTION):
case (startracker::DEBUG_CAMERA):
case (startracker::LIMITS):
case (startracker::MOUNTING):
case (startracker::CAMERA):
case (startracker::CENTROIDING):
case (startracker::LISA):
case (startracker::MATCHING):
case (startracker::TRACKING):
case (startracker::VALIDATION):
case (startracker::IMAGE_PROCESSOR):
case (startracker::ALGO): {
2023-03-21 20:35:28 +01:00
result = handleSetParamReply(packet);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_CAMERA): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, cameraSet, startracker::CameraSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_LIMITS): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, limitsSet, startracker::LimitsSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_LOG_LEVEL): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, loglevelSet, startracker::LogLevelSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_MOUNTING): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, mountingSet, startracker::MountingSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_IMAGE_PROCESSOR): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, imageProcessorSet, startracker::ImageProcessorSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_CENTROIDING): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, centroidingSet, startracker::CentroidingSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_LISA): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, lisaSet, startracker::LisaSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_MATCHING): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, matchingSet, startracker::MatchingSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_TRACKING): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, trackingSet, startracker::TrackingSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_VALIDATION): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, validationSet, startracker::ValidationSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_ALGO): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, algoSet, startracker::AlgoSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_SUBSCRIPTION): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, subscriptionSet, startracker::SubscriptionSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_LOG_SUBSCRIPTION): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, logSubscriptionSet, startracker::LogSubscriptionSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_DEBUG_CAMERA): {
2023-03-21 20:35:28 +01:00
handleParamRequest(packet, debugCameraSet, startracker::DebugCameraSet::SIZE);
2022-02-25 14:24:51 +01:00
break;
}
default: {
sif::debug << "StarTrackerHandler::interpretDeviceReply: Unknown device reply id:" << id
<< std::endl;
result = DeviceHandlerIF::UNKNOWN_DEVICE_REPLY;
}
}
return result;
}
void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {}
2021-11-27 19:40:52 +01:00
2022-02-23 18:15:34 +01:00
uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
2022-02-25 14:24:51 +01:00
return DEFAULT_TRANSITION_DELAY;
2022-02-23 18:15:34 +01:00
}
2021-07-07 12:12:01 +02:00
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
2022-02-25 14:24:51 +01:00
LocalDataPoolManager& poolManager) {
localDataPoolMap.emplace(startracker::TICKS_TIME_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_TIME_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::RUN_TIME, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::UNIX_TIME, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::TICKS_VERSION_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_VERSION_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::PROGRAM, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::MAJOR, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::MINOR, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::TICKS_INTERFACE_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_INTERFACE_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::FRAME_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::CHECKSUM_ERROR_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::SET_PARAM_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::SET_PARAM_REPLY_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::PARAM_REQUEST_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::PARAM_REPLY_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::REQ_TM_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TM_REPLY_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::ACTION_REQ_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::ACTION_REPLY_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TICKS_POWER_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_POWER_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::MCU_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MCU_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_CORE_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_CORE_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_18_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_18_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_25_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_25_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_21_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_21_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_PIX_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_PIX_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_33_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_33_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_RES_CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMV_RES_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TICKS_TEMPERATURE_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_TEMPERATURE_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::MCU_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CMOS_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::FPGA_TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TICKS_SOLUTION_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_SOLUTION_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::CALI_QW, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CALI_QX, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CALI_QY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CALI_QZ, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_CONFIDENCE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_QW, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_QX, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_QY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_QZ, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACK_REMOVED, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::STARS_CENTROIDED, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::STARS_MATCHED_DATABASE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LISA_QW, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_QX, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_QY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_QZ, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_PERC_CLOSE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_NR_CLOSE, new PoolEntry<uint8_t>({0}));
2023-04-14 18:31:56 +02:00
localDataPoolMap.emplace(startracker::STR_MODE, new PoolEntry<uint8_t>({0}));
2022-02-25 14:24:51 +01:00
localDataPoolMap.emplace(startracker::TRUST_WORTHY, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::STABLE_COUNT, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::SOLUTION_STRATEGY, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::TICKS_HISTOGRAM_SET, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::TIME_HISTOGRAM_SET, new PoolEntry<uint64_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA0, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA3, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA4, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA5, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA6, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA7, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINA8, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB0, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB3, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB4, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB5, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB6, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB7, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINB8, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC0, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC3, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC4, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC5, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC6, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC7, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BINC8, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND0, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND1, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND2, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND3, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND4, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND5, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND6, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND7, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::HISTOGRAM_BIND8, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::CAMERA_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::FOCALLENGTH, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::EXPOSURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::INTERVAL, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CAMERA_OFFSET, new PoolEntry<int16_t>({0}));
localDataPoolMap.emplace(startracker::PGAGAIN, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::ADCGAIN, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_REG8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_VAL8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CAM_FREQ_1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LIMITS_ACTION, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LIMITS_FPGA18CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_FPGA25CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_FPGA10CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_MCUCURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_CMOS21CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_CMOSPIXCURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_CMOS33CURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_CMOSVRESCURRENT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LIMITS_CMOSTEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL9, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL10, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL11, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL12, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL13, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL14, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL15, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOGLEVEL16, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::MOUNTING_QW, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MOUNTING_QX, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MOUNTING_QY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MOUNTING_QZ, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::IMAGE_PROCESSOR_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::IMAGE_PROCESSOR_STORE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::IMAGE_PROCESSOR_SIGNALTHRESHOLD,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(startracker::IMAGE_PROCESSOR_DARKTHRESHOLD,
new PoolEntry<uint16_t>({0}));
localDataPoolMap.emplace(startracker::IMAGE_PROCESSOR_BACKGROUNDCOMPENSATION,
new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_ENABLE_FILTER, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_MAX_QUALITY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_DARK_THRESHOLD, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_MIN_QUALITY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_MAX_INTENSITY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_MIN_INTENSITY, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_MAX_MAGNITUDE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_GAUSSIAN_CMAX, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_GAUSSIAN_CMIN, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_TRANSMATRIX00, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_TRANSMATRIX01, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_TRANSMATRIX10, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::CENTROIDING_TRANSMATRIX11, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_MODE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::LISA_PREFILTER_DIST_THRESHOLD, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_PREFILTER_ANGLE_THRESHOLD, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_FOV_WIDTH, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_FOV_HEIGHT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_FLOAT_STAR_LIMIT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_CLOSE_STAR_LIMIT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_RATING_WEIGHT_CLOSE_STAR_COUNT,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_RATING_WEIGHT_FRACTION_CLOSE,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_RATING_WEIGHT_MEAN_SUM, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_RATING_WEIGHT_DB_STAR_COUNT,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::LISA_MAX_COMBINATIONS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LISA_NR_STARS_STOP, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LISA_FRACTION_CLOSE_STOP, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MATCHING_SQUARED_DISTANCE_LIMIT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::MATCHING_SQUARED_SHIFT_LIMIT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACKING_THIN_LIMIT, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACKING_OUTLIER_THRESHOLD, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACKING_OUTLIER_THRESHOLD_QUEST,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::TRACKING_TRACKER_CHOICE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::VALIDATION_STABLE_COUNT, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::VALIDATION_MAX_DIFFERENCE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::VALIDATION_MIN_TRACKER_CONFIDENCE,
new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::VALIDATION_MIN_MATCHED_STARS, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::ALGO_MODE, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::ALGO_I2T_MIN_CONFIDENCE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::ALGO_I2T_MIN_MATCHED, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::ALGO_I2L_MIN_CONFIDENCE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(startracker::ALGO_I2L_MIN_MATCHED, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM3, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM4, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM5, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM6, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM7, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM8, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM9, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM10, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM11, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM12, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM13, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM14, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM15, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::SUBSCRIPTION_TM16, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOG_SUBSCRIPTION_LEVEL1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOG_SUBSCRIPTION_MODULE1, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOG_SUBSCRIPTION_LEVEL2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::LOG_SUBSCRIPTION_MODULE2, new PoolEntry<uint8_t>({0}));
localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TIMING, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(startracker::DEBUG_CAMERA_TEST, new PoolEntry<uint32_t>({0}));
2022-02-27 15:46:06 +01:00
localDataPoolMap.emplace(startracker::CHKSUM, new PoolEntry<uint32_t>({0}));
2023-01-24 12:24:29 +01:00
2023-01-24 13:18:29 +01:00
poolManager.subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams(temperatureSet.getSid(), false, 10.0));
2023-01-24 12:24:29 +01:00
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(powerSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(interfaceSet.getSid(), false, 10.0));
poolManager.subscribeForDiagPeriodicPacket(
2023-03-26 15:28:00 +02:00
subdp::DiagnosticsHkPeriodicParams(solutionSet.getSid(), false, 12.0));
2023-01-24 12:24:29 +01:00
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(cameraSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(histogramSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(lisaSet.getSid(), false, 10.0));
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-07-07 12:12:01 +02:00
}
2022-01-17 15:58:27 +01:00
size_t StarTrackerHandler::getNextReplyLength(DeviceCommandId_t commandId) {
2022-02-25 14:24:51 +01:00
return startracker::MAX_FRAME_SIZE;
2021-07-07 12:12:01 +02:00
}
2021-12-06 19:36:21 +01:00
ReturnValue_t StarTrackerHandler::doSendReadHook() {
2022-02-25 14:24:51 +01:00
// Prevent DHB from polling UART during commands executed by the image loader task
if (strHelperHandlingSpecialRequest) {
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-12-06 19:36:21 +01:00
}
2022-03-30 09:19:30 +02:00
ReturnValue_t StarTrackerHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
if (powerSwitch == power::NO_SWITCH) {
return DeviceHandlerBase::NO_SWITCH;
}
2022-03-29 07:58:22 +02:00
*numberOfSwitches = 1;
*switches = &powerSwitch;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-03-29 07:58:22 +02:00
}
2021-12-14 19:24:31 +01:00
ReturnValue_t StarTrackerHandler::checkMode(ActionId_t actionId) {
2022-02-25 14:24:51 +01:00
switch (actionId) {
case startracker::UPLOAD_IMAGE:
case startracker::DOWNLOAD_IMAGE:
case startracker::FLASH_READ:
case startracker::FIRMWARE_UPDATE: {
return DeviceHandlerBase::acceptExternalDeviceCommands();
default:
break;
}
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-12-14 19:24:31 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::scanForActionReply(uint8_t replyId, DeviceCommandId_t* foundId) {
switch (replyId) {
2022-02-25 14:24:51 +01:00
case (startracker::ID::PING): {
*foundId = startracker::PING_REQUEST;
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::CHECKSUM): {
*foundId = startracker::CHECKSUM;
break;
}
default:
sif::warning << "StarTrackerHandler::scanForActionReply: Unknown parameter reply id"
<< std::endl;
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-27 19:40:52 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::scanForSetParameterReply(uint8_t replyId,
DeviceCommandId_t* foundId) {
switch (replyId) {
2022-02-25 14:24:51 +01:00
case (startracker::ID::SUBSCRIPTION): {
*foundId = startracker::SUBSCRIPTION;
break;
}
case (startracker::ID::LIMITS): {
*foundId = startracker::LIMITS;
break;
}
case (startracker::ID::MOUNTING): {
*foundId = startracker::MOUNTING;
break;
}
case (startracker::ID::IMAGE_PROCESSOR): {
*foundId = startracker::IMAGE_PROCESSOR;
break;
}
case (startracker::ID::CAMERA): {
*foundId = startracker::CAMERA;
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;
}
case (startracker::ID::LOG_LEVEL): {
*foundId = startracker::LOGLEVEL;
break;
}
case (startracker::ID::DEBUG_CAMERA): {
*foundId = startracker::DEBUG_CAMERA;
break;
}
case (startracker::ID::LOG_SUBSCRIPTION): {
*foundId = startracker::LOGSUBSCRIPTION;
break;
}
default:
sif::debug << "StarTrackerHandler::scanForParameterReply: Unknown parameter reply id"
<< std::endl;
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-27 19:40:52 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::scanForGetParameterReply(uint8_t replyId,
DeviceCommandId_t* foundId) {
switch (replyId) {
2022-02-25 14:24:51 +01:00
case (startracker::ID::CAMERA): {
*foundId = startracker::REQ_CAMERA;
break;
}
case (startracker::ID::LIMITS): {
*foundId = startracker::REQ_LIMITS;
break;
}
case (startracker::ID::LOG_LEVEL): {
*foundId = startracker::REQ_LOG_LEVEL;
break;
}
case (startracker::ID::MOUNTING): {
*foundId = startracker::REQ_MOUNTING;
break;
}
case (startracker::ID::IMAGE_PROCESSOR): {
*foundId = startracker::REQ_IMAGE_PROCESSOR;
break;
}
case (startracker::ID::CENTROIDING): {
*foundId = startracker::REQ_CENTROIDING;
break;
}
case (startracker::ID::LISA): {
*foundId = startracker::REQ_LISA;
break;
}
case (startracker::ID::MATCHING): {
*foundId = startracker::REQ_MATCHING;
break;
}
case (startracker::ID::TRACKING): {
*foundId = startracker::REQ_TRACKING;
break;
}
case (startracker::ID::VALIDATION): {
*foundId = startracker::REQ_VALIDATION;
break;
}
case (startracker::ID::ALGO): {
*foundId = startracker::REQ_ALGO;
break;
}
case (startracker::ID::SUBSCRIPTION): {
*foundId = startracker::REQ_SUBSCRIPTION;
break;
}
case (startracker::ID::LOG_SUBSCRIPTION): {
*foundId = startracker::REQ_LOG_SUBSCRIPTION;
break;
}
case (startracker::ID::DEBUG_CAMERA): {
*foundId = startracker::REQ_DEBUG_CAMERA;
break;
}
default: {
sif::warning << "tarTrackerHandler::scanForGetParameterReply: UnkNown ID" << std::endl;
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
break;
}
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-07-07 12:12:01 +02:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::scanForTmReply(uint8_t replyId, DeviceCommandId_t* foundId) {
switch (replyId) {
2022-02-25 14:24:51 +01:00
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::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: "
2023-03-21 20:35:28 +01:00
<< static_cast<unsigned int>(replyId) << std::endl;
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
break;
}
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-27 19:40:52 +01:00
}
2021-12-02 08:05:33 +01:00
void StarTrackerHandler::handleEvent(EventMessage* eventMessage) {
2022-02-25 14:24:51 +01:00
object_id_t objectId = eventMessage->getReporter();
switch (objectId) {
2023-03-22 02:20:14 +01:00
case objects::STR_COM_IF: {
2022-02-25 14:24:51 +01:00
// All events from image loader signal either that the operation was successful or that it
// failed
strHelperHandlingSpecialRequest = false;
2022-02-25 14:24:51 +01:00
break;
}
default:
sif::debug << "StarTrackerHandler::handleEvent: Did not subscribe to this event" << std::endl;
break;
}
}
ReturnValue_t StarTrackerHandler::executeFlashReadCommand(const uint8_t* commandData,
2022-02-27 15:48:42 +01:00
size_t commandDataLen) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-27 15:46:06 +01:00
if (commandDataLen < FlashReadCmd::MIN_LENGTH) {
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::executeFlashReadCommand: Command too short" << std::endl;
return COMMAND_TOO_SHORT;
}
uint8_t startRegion = *(commandData);
uint32_t length;
size_t size = sizeof(length);
const uint8_t* lengthPtr = commandData + sizeof(startRegion);
result = SerializeAdapter::deSerialize(&length, lengthPtr, &size, SerializeIF::Endianness::BIG);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
sif::debug << "StarTrackerHandler::executeFlashReadCommand: Deserialization of length failed"
<< std::endl;
return result;
}
2023-05-11 20:21:44 +02:00
if (commandDataLen - sizeof(startRegion) - sizeof(length) > config::MAX_PATH_SIZE) {
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::executeFlashReadCommand: Received command with invalid"
<< " path and filename" << std::endl;
return FILE_PATH_TOO_LONG;
}
const uint8_t* filePtr = commandData + sizeof(startRegion) + sizeof(length);
std::string fullname = std::string(reinterpret_cast<const char*>(filePtr),
commandDataLen - sizeof(startRegion) - sizeof(length));
result = strHelper->startFlashRead(fullname, startRegion, length);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
return result;
2021-12-22 16:06:30 +01:00
}
2021-11-27 19:40:52 +01:00
void StarTrackerHandler::prepareBootCommand() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
struct BootActionRequest bootRequest = {BOOT_REGION_ID};
arc_pack_boot_action_req(&bootRequest, commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-27 19:40:52 +01:00
}
2021-12-23 18:33:31 +01:00
ReturnValue_t StarTrackerHandler::prepareChecksumCommand(const uint8_t* commandData,
2022-02-25 14:24:51 +01:00
size_t commandDataLen) {
struct ChecksumActionRequest req;
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
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);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
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);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
sif::debug << "StarTrackerHandler::prepareChecksumCommand: Deserialization of length failed"
<< std::endl;
return result;
}
uint32_t rawCmdLength = 0;
arc_pack_checksum_action_req(&req, commandBuffer, &rawCmdLength);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = rawCmdLength;
2022-02-25 14:24:51 +01:00
checksumCmd.rememberRegion = req.region;
checksumCmd.rememberAddress = req.address;
checksumCmd.rememberLength = req.length;
return result;
2021-12-23 18:33:31 +01:00
}
2021-11-27 19:40:52 +01:00
void StarTrackerHandler::prepareTimeRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_time_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-27 19:40:52 +01:00
}
2021-11-26 09:14:41 +01:00
void StarTrackerHandler::preparePingRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
struct PingActionRequest pingRequest = {PING_ID};
arc_pack_ping_action_req(&pingRequest, commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-26 09:14:41 +01:00
}
2021-11-26 15:24:52 +01:00
void StarTrackerHandler::prepareVersionRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_version_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-26 15:24:52 +01:00
}
2021-11-27 19:40:52 +01:00
void StarTrackerHandler::prepareInterfaceRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_interface_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-29 11:04:56 +01:00
}
2021-11-27 19:40:52 +01:00
void StarTrackerHandler::preparePowerRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_power_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-27 19:40:52 +01:00
}
2022-02-27 15:46:06 +01:00
void StarTrackerHandler::prepareSwitchToBootloaderCmd() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
struct RebootActionRequest rebootReq {};
2022-02-25 14:24:51 +01:00
arc_pack_reboot_action_req(&rebootReq, commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-26 13:16:05 +01:00
}
2021-12-10 10:07:23 +01:00
void StarTrackerHandler::prepareTakeImageCommand(const uint8_t* commandData) {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
struct CameraActionRequest camReq;
camReq.actionid = *commandData;
arc_pack_camera_action_req(&camReq, commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-12-09 15:02:58 +01:00
}
2021-11-27 19:40:52 +01:00
void StarTrackerHandler::prepareSolutionRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_solution_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-11-27 19:40:52 +01:00
}
2021-07-07 12:12:01 +02:00
void StarTrackerHandler::prepareTemperatureRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_temperature_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-07-07 12:12:01 +02:00
}
2021-12-15 19:32:43 +01:00
void StarTrackerHandler::prepareHistogramRequest() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_tm_pack_histogram_req(commandBuffer, &length);
2023-03-22 02:20:14 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2021-12-15 19:32:43 +01:00
}
ReturnValue_t StarTrackerHandler::prepareParamCommand(const uint8_t* commandData,
2022-02-25 14:24:51 +01:00
size_t commandDataLen,
2023-03-31 18:51:16 +02:00
ArcsecJsonParamBase& paramSet,
bool reinitSet) {
2023-03-08 18:09:50 +01:00
// Stopwatch watch;
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2023-05-11 20:21:44 +02:00
if (commandDataLen > config::MAX_PATH_SIZE) {
2022-02-25 14:24:51 +01:00
return FILE_PATH_TOO_LONG;
}
2023-04-01 15:33:02 +02:00
if (reinitSet) {
2023-03-31 18:51:16 +02:00
result = paramSet.init(paramJsonFile);
2023-04-01 15:33:02 +02:00
if (result != returnvalue::OK) {
2023-03-31 18:52:35 +02:00
return result;
}
2023-03-31 18:51:16 +02:00
}
2022-02-25 14:24:51 +01:00
2023-03-22 02:20:14 +01:00
result = paramSet.create(commandBuffer);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = paramSet.getSize();
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-12-06 19:36:21 +01:00
}
2022-01-17 13:15:18 +01:00
ReturnValue_t StarTrackerHandler::prepareRequestCameraParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_camera_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-01-17 13:15:18 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestLimitsParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_limits_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
}
2022-02-10 18:39:37 +01:00
ReturnValue_t StarTrackerHandler::prepareRequestLogLevelParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_loglevel_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-09 19:20:19 +01:00
}
2022-02-10 18:39:37 +01:00
ReturnValue_t StarTrackerHandler::prepareRequestMountingParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_mounting_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestImageProcessorParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_imageprocessor_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestCentroidingParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_centroiding_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestLisaParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_lisa_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestMatchingParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_matching_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestTrackingParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_tracking_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestValidationParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_validation_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestAlgoParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_algo_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestSubscriptionParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_subscription_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestLogSubscriptionParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_logsubscription_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
ReturnValue_t StarTrackerHandler::prepareRequestDebugCameraParams() {
2022-02-25 14:24:51 +01:00
uint32_t length = 0;
arc_pack_debugcamera_parameter_req(commandBuffer, &length);
2023-03-21 20:35:28 +01:00
rawPacket = commandBuffer;
rawPacketLen = length;
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-10 18:39:37 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleSetParamReply(const uint8_t* rawFrame) {
uint8_t status = startracker::getStatusField(rawFrame);
2022-02-25 14:24:51 +01:00
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set "
" command with parameter ID"
2023-03-21 20:35:28 +01:00
<< static_cast<unsigned int>(*(rawFrame + PARAMETER_ID_OFFSET)) << std::endl;
2022-02-25 14:24:51 +01:00
if (internalState != InternalState::IDLE) {
internalState = InternalState::IDLE;
}
return SET_PARAM_FAILED;
}
if (internalState != InternalState::IDLE) {
2023-03-22 02:20:14 +01:00
handleStartup(*(rawFrame + PARAMETER_ID_OFFSET));
2022-02-25 14:24:51 +01:00
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-27 19:40:52 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleActionReply(const uint8_t* rawFrame) {
uint8_t status = startracker::getStatusField(rawFrame);
2022-02-25 14:24:51 +01:00
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleActionReply: Failed to execute action "
<< "command with action ID "
2023-03-21 20:35:28 +01:00
<< static_cast<unsigned int>(*(rawFrame + ACTION_ID_OFFSET)) << " and status "
2022-02-25 14:24:51 +01:00
<< static_cast<unsigned int>(status) << std::endl;
return ACTION_FAILED;
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-11-27 19:40:52 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleChecksumReply(const uint8_t* rawFrame) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2023-03-21 20:35:28 +01:00
result = handleActionReply(rawFrame);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-21 20:35:28 +01:00
const uint8_t* replyData = rawFrame + ACTION_DATA_OFFSET;
2022-02-25 14:24:51 +01:00
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();
2022-08-30 23:54:05 +02:00
handleDeviceTm(checksumSet, startracker::CHECKSUM);
2021-12-23 18:33:31 +01:00
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
2022-02-25 14:24:51 +01:00
checksumReply.printChecksum();
2021-12-23 18:33:31 +01:00
#endif /* OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1 */
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-12-23 18:33:31 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleParamRequest(const uint8_t* rawFrame,
LocalPoolDataSetBase& dataset, size_t size) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-21 20:35:28 +01:00
const uint8_t* reply = rawFrame + PARAMS_OFFSET;
2022-02-25 14:24:51 +01:00
dataset.setValidityBufferGeneration(false);
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::handleParamRequest Deserialization failed" << std::endl;
}
dataset.setValidityBufferGeneration(true);
dataset.setValidity(true, true);
result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2022-01-17 13:15:18 +01:00
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
2022-02-25 14:24:51 +01:00
dataset.printSet();
2022-01-17 13:15:18 +01:00
#endif
2022-02-25 14:24:51 +01:00
return result;
2022-01-17 13:15:18 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handlePingReply(const uint8_t* rawFrame) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
2022-02-25 14:24:51 +01:00
uint32_t pingId = 0;
uint8_t status = startracker::getStatusField(rawFrame);
2023-03-21 20:35:28 +01:00
const uint8_t* buffer = rawFrame + ACTION_DATA_OFFSET;
2022-02-25 14:24:51 +01:00
size_t size = sizeof(pingId);
SerializeAdapter::deSerialize(&pingId, &buffer, &size, SerializeIF::Endianness::LITTLE);
sif::info << "StarTracker: Ping status: " << static_cast<unsigned int>(status) << std::endl;
2023-03-21 20:35:28 +01:00
sif::info << "Ping ID: 0x" << std::hex << pingId << std::endl;
2022-02-25 14:24:51 +01:00
if (status != startracker::STATUS_OK || pingId != PING_ID) {
2023-03-21 20:35:28 +01:00
sif::warning << "STR: Ping failed" << std::endl;
2022-02-25 14:24:51 +01:00
result = PING_FAILED;
} else {
2023-03-21 20:35:28 +01:00
sif::info << "STR: Ping OK" << std::endl;
2022-02-25 14:24:51 +01:00
}
return result;
2021-11-26 09:14:41 +01:00
}
2021-12-14 19:24:31 +01:00
ReturnValue_t StarTrackerHandler::checkProgram() {
2022-02-25 14:24:51 +01:00
PoolReadGuard pg(&versionSet);
switch (versionSet.program.value) {
case startracker::Program::BOOTLOADER:
if (startupState == StartupState::WAIT_CHECK_PROGRAM) {
startupState = StartupState::DONE;
}
2023-03-20 17:51:10 +01:00
if (bootState == FwBootState::VERIFY_BOOT) {
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::checkProgram: Failed to boot firmware" << std::endl;
// Device handler will run into timeout and fall back to transition source mode
2023-02-17 12:19:53 +01:00
triggerEvent(BOOTING_FIRMWARE_FAILED_EVENT);
2022-02-25 14:24:51 +01:00
internalState = InternalState::FAILED_FIRMWARE_BOOT;
} else if (internalState == InternalState::BOOTLOADER_CHECK) {
internalState = InternalState::DONE;
}
break;
case startracker::Program::FIRMWARE:
if (startupState == StartupState::WAIT_CHECK_PROGRAM) {
startupState = StartupState::BOOT_BOOTLOADER;
}
2023-03-20 17:51:10 +01:00
if (bootState == FwBootState::VERIFY_BOOT) {
bootState = FwBootState::LOGLEVEL;
2022-02-25 14:24:51 +01:00
} else if (internalState == InternalState::BOOTLOADER_CHECK) {
2023-02-17 12:19:53 +01:00
triggerEvent(BOOTING_BOOTLOADER_FAILED_EVENT);
2023-03-20 17:51:10 +01:00
internalState = InternalState::FAILED_BOOTLOADER_BOOT;
2022-02-25 14:24:51 +01:00
}
break;
default:
sif::warning << "StarTrackerHandler::checkProgram: Version set has invalid program ID"
<< std::endl;
return INVALID_PROGRAM;
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2021-12-14 19:24:31 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
2023-04-16 04:04:57 +02:00
size_t size, const char* context) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
uint8_t status = startracker::getStatusField(rawFrame);
2022-02-25 14:24:51 +01:00
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
}
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-21 20:35:28 +01:00
const uint8_t* reply = rawFrame + TICKS_OFFSET;
2022-02-25 14:24:51 +01:00
dataset.setValidityBufferGeneration(false);
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2023-04-16 04:04:57 +02:00
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context
<< std::endl;
2022-02-25 14:24:51 +01:00
}
dataset.setValidityBufferGeneration(true);
dataset.setValidity(true, true);
result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2021-12-15 19:32:43 +01:00
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
2022-02-25 14:24:51 +01:00
dataset.printSet();
2021-12-15 19:32:43 +01:00
#endif
2022-02-25 14:24:51 +01:00
return result;
2021-12-15 19:32:43 +01:00
}
2023-03-21 20:35:28 +01:00
ReturnValue_t StarTrackerHandler::handleActionReplySet(const uint8_t* rawFrame,
LocalPoolDataSetBase& dataset, size_t size) {
2022-08-24 17:27:47 +02:00
ReturnValue_t result = returnvalue::OK;
uint8_t status = startracker::getStatusField(rawFrame);
2022-02-25 14:24:51 +01:00
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleActionReplySet: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
}
result = dataset.read(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2023-03-21 20:35:28 +01:00
const uint8_t* reply = rawFrame + ACTION_DATA_OFFSET;
2022-02-25 14:24:51 +01:00
dataset.setValidityBufferGeneration(false);
result = dataset.deSerialize(&reply, &size, SerializeIF::Endianness::LITTLE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
sif::warning << "StarTrackerHandler::handleActionReplySet Deserialization failed" << std::endl;
}
dataset.setValidityBufferGeneration(true);
dataset.setValidity(true, true);
result = dataset.commit(TIMEOUT_TYPE, MUTEX_TIMEOUT);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2022-02-25 14:24:51 +01:00
return result;
}
2021-12-29 20:33:20 +01:00
#if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_STARTRACKER == 1
2022-02-25 14:24:51 +01:00
dataset.printSet();
2021-12-29 20:33:20 +01:00
#endif
2022-02-25 14:24:51 +01:00
return result;
2021-12-29 20:33:20 +01:00
}
2023-03-22 02:20:14 +01:00
void StarTrackerHandler::handleStartup(uint8_t parameterId) {
switch (parameterId) {
2022-02-25 14:24:51 +01:00
case (startracker::ID::LOG_LEVEL): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::LIMITS;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::LIMITS): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::TRACKING;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::TRACKING): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::MOUNTING;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::MOUNTING): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::IMAGE_PROCESSOR;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::IMAGE_PROCESSOR): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::CAMERA;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::CAMERA): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::CENTROIDING;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::CENTROIDING): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::LISA;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::LISA): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::MATCHING;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::MATCHING): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::VALIDATION;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::VALIDATION): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::ALGO;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::ALGO): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::LOG_SUBSCRIPTION;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::LOG_SUBSCRIPTION): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::DEBUG_CAMERA;
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::ID::DEBUG_CAMERA): {
2023-03-20 17:51:10 +01:00
bootState = FwBootState::NONE;
2022-02-25 14:24:51 +01:00
internalState = InternalState::DONE;
break;
}
default: {
2023-03-22 02:20:14 +01:00
sif::warning << "StarTrackerHandler::handleStartup: Received parameter reply with unexpected"
<< " parameter ID " << (int)parameterId << std::endl;
2022-02-25 14:24:51 +01:00
break;
}
}
2021-12-14 19:24:31 +01:00
}
2022-02-14 11:28:15 +01:00
ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) {
2022-02-25 14:24:51 +01:00
switch (actionId) {
case startracker::REQ_INTERFACE:
case startracker::REQ_TIME:
case startracker::SWITCH_TO_BOOTLOADER_PROGRAM:
case startracker::DOWNLOAD_IMAGE:
case startracker::UPLOAD_IMAGE:
case startracker::REQ_POWER:
case startracker::TAKE_IMAGE:
case startracker::REQ_SOLUTION:
case startracker::REQ_TEMPERATURE:
case startracker::REQ_HISTOGRAM:
2022-02-27 15:46:06 +01:00
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:
2023-03-21 17:37:39 +01:00
if (getMode() == MODE_ON and getSubmode() != startracker::Program::FIRMWARE) {
2023-03-21 17:35:36 +01:00
return STARTRACKER_NOT_RUNNING_FIRMWARE;
2022-02-25 14:24:51 +01:00
}
break;
case startracker::FIRMWARE_UPDATE:
2022-02-27 15:46:06 +01:00
case startracker::FLASH_READ:
2023-03-21 17:37:39 +01:00
if (getMode() != MODE_ON or getSubmode() != startracker::Program::BOOTLOADER) {
2023-03-21 17:35:36 +01:00
return STARTRACKER_NOT_RUNNING_BOOTLOADER;
2022-02-25 14:24:51 +01:00
}
break;
default:
break;
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
2022-02-14 11:28:15 +01:00
}