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

2856 lines
112 KiB
C++
Raw Normal View History

2023-07-12 17:59:07 +02:00
#include <fsfw/globalfunctions/arrayprinter.h>
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-11-21 14:54:21 +01:00
#include "fsfw/ipc/MessageQueueIF.h"
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"
#include "fsfw/thermal/tcsDefinitions.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-11-16 16:57:36 +01:00
StrComHandler* strHelper, power::Switch_t powerSwitch,
startracker::SdCardConfigPathGetter& cfgPathGetter)
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),
2023-10-19 09:26:28 +02:00
autoBlobSet(this),
matchedCentroidsSet(this),
2023-10-09 15:16:48 +02:00
blobSet(this),
2023-10-06 11:23:31 +02:00
blobsSet(this),
2023-10-09 15:16:48 +02:00
centroidSet(this),
centroidsSet(this),
2023-10-27 11:24:51 +02:00
contrastSet(this),
2022-03-30 09:19:30 +02:00
strHelper(strHelper),
2023-11-16 16:57:36 +01:00
powerSwitch(powerSwitch),
cfgPathGetter(cfgPathGetter) {
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);
2023-10-09 15:29:04 +02:00
additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE);
currentSecondaryTmIter = additionalRequestedTm.begin();
2022-02-25 14:24:51 +01:00
}
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:
2023-11-21 14:17:19 +01:00
if (!JCFG_DONE) {
startupState = StartupState::WAIT_JCFG;
return;
}
break;
case StartupState::WAIT_JCFG: {
return;
}
default:
return;
}
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);
2023-06-22 11:29:30 +02:00
temperatureSet.fpgaTemperature = thermal::INVALID_TEMPERATURE;
temperatureSet.cmosTemperature = thermal::INVALID_TEMPERATURE;
temperatureSet.mcuTemperature = thermal::INVALID_TEMPERATURE;
2023-06-17 19:17:50 +02:00
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.
reloadJsonCfgFile();
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
}
bool StarTrackerHandler::reloadJsonCfgFile() {
jcfgCountdown.resetTimer();
auto strCfgPath = cfgPathGetter.getCfgPath();
if (strCfgPath.has_value()) {
2023-11-21 14:17:19 +01:00
jcfgPending = true;
2023-11-21 14:34:15 +01:00
JCFG_DONE = false;
jsonCfgTask = std::thread{setUpJsonCfgs, std::ref(jcfgs), strCfgPath.value()};
return true;
}
// Simplified FDIR: Just continue as usual..
JCFG_DONE = true;
return false;
}
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) {
2023-10-09 15:56:48 +02:00
case (startracker::ADD_SECONDARY_TM_TO_NORMAL_MODE): {
if (size < 4) {
return HasActionsIF::INVALID_PARAMETERS;
}
DeviceCommandId_t idToAdd;
result =
SerializeAdapter::deSerialize(&idToAdd, data, &size, SerializeIF::Endianness::NETWORK);
if (result != returnvalue::OK) {
return result;
}
addSecondaryTmForNormalMode(idToAdd);
return EXECUTION_FINISHED;
}
case (startracker::RESET_SECONDARY_TM_SET): {
resetSecondaryTmSet();
return EXECUTION_FINISHED;
}
case (startracker::READ_SECONDARY_TM_SET): {
std::vector<uint8_t> dataVec(additionalRequestedTm.size() * 4);
unsigned idx = 0;
size_t serLen = 0;
for (const auto& cmd : additionalRequestedTm) {
SerializeAdapter::serialize(&cmd, dataVec.data() + idx * 4, &serLen, dataVec.size(),
SerializeIF::Endianness::NETWORK);
idx++;
}
actionHelper.reportData(commandedBy, actionId, dataVec.data(), dataVec.size());
return EXECUTION_FINISHED;
}
2022-02-25 14:24:51 +01:00
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-11-21 14:17:19 +01:00
if (jcfgPending) {
if (JCFG_DONE) {
2023-11-29 15:15:29 +01:00
if (startupState == StartupState::WAIT_JCFG) {
2023-11-21 15:22:24 +01:00
startupState = StartupState::DONE;
}
2023-11-21 14:17:19 +01:00
jsonCfgTask.join();
jcfgPending = false;
2023-11-21 14:54:21 +01:00
auto iter = deviceCommandMap.find(startracker::RELOAD_JSON_CFG_FILE);
if (iter != deviceCommandMap.end() and iter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
actionHelper.finish(true, iter->second.sendReplyTo, startracker::RELOAD_JSON_CFG_FILE);
}
2023-11-21 14:17:19 +01:00
} else if (jcfgCountdown.hasTimedOut()) {
2023-11-21 14:54:21 +01:00
auto iter = deviceCommandMap.find(startracker::RELOAD_JSON_CFG_FILE);
if (iter != deviceCommandMap.end() and iter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
actionHelper.finish(false, iter->second.sendReplyTo, startracker::RELOAD_JSON_CFG_FILE);
}
2023-11-21 14:17:19 +01:00
}
}
2022-02-25 14:24:51 +01:00
}
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) {
2023-10-09 15:29:04 +02:00
case NormalState::SECONDARY_REQUEST:
if (additionalRequestedTm.size() == 0) {
break;
}
*id = *currentSecondaryTmIter;
currentSecondaryTmIter++;
if (currentSecondaryTmIter == additionalRequestedTm.end()) {
currentSecondaryTmIter = additionalRequestedTm.begin();
}
2022-02-27 15:46:06 +01:00
normalState = NormalState::SOLUTION_REQUEST;
break;
case NormalState::SOLUTION_REQUEST:
*id = startracker::REQ_SOLUTION;
2023-10-09 15:29:04 +02:00
normalState = NormalState::SECONDARY_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: {
2023-07-13 16:38:20 +02:00
if (bootState == FwBootState::VERIFY_BOOT or isAwaitingReply()) {
2023-03-20 17:51:10 +01:00
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);
}
2023-04-16 11:35:30 +02:00
case (FwBootState::SET_TIME): {
2023-07-13 10:53:58 +02:00
*id = startracker::SET_TIME_FROM_SYS_TIME;
2023-04-16 11:25:10 +02:00
return buildCommandFromCommand(*id, nullptr, 0);
}
2023-03-20 17:51:10 +01:00
case (FwBootState::LOGLEVEL): {
*id = startracker::LOGLEVEL;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case (FwBootState::LIMITS): {
*id = startracker::LIMITS;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case (FwBootState::TRACKING): {
*id = startracker::TRACKING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
}
case FwBootState::MOUNTING:
*id = startracker::MOUNTING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::IMAGE_PROCESSOR:
*id = startracker::IMAGE_PROCESSOR;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::CAMERA:
*id = startracker::CAMERA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::CENTROIDING:
*id = startracker::CENTROIDING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::LISA:
*id = startracker::LISA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::MATCHING:
*id = startracker::MATCHING;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::VALIDATION:
*id = startracker::VALIDATION;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::ALGO:
*id = startracker::ALGO;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::LOG_SUBSCRIPTION:
*id = startracker::LOGSUBSCRIPTION;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
case FwBootState::DEBUG_CAMERA:
*id = startracker::DEBUG_CAMERA;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
2023-07-13 20:49:42 +02:00
case FwBootState::AUTO_THRESHOLD:
*id = startracker::AUTO_THRESHOLD;
return buildCommandFromCommand(
*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), paramJsonFile.size());
2023-03-20 17:51:10 +01:00
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
}
2023-11-21 14:54:21 +01:00
case (startracker::RELOAD_JSON_CFG_FILE): {
if (jcfgPending) {
return HasActionsIF::IS_BUSY;
}
// It should be noted that this just reloads the JSON config structure in memory from the
// JSON file. The configuration still needs to be sent to the STR. The easiest way to achieve
// this is to simply reboot the device after a reload.
reloadJsonCfgFile();
return returnvalue::OK;
}
2023-07-13 10:53:58 +02:00
case (startracker::SET_TIME_FROM_SYS_TIME): {
2023-07-12 18:17:00 +02:00
SetTimeActionRequest setTimeRequest{};
2023-04-16 11:25:10 +02:00
timeval tv;
Clock::getClock(&tv);
2023-07-13 14:52:32 +02:00
setTimeRequest.unixTime =
(static_cast<uint64_t>(tv.tv_sec) * 1000 * 1000) + (static_cast<uint64_t>(tv.tv_usec));
2023-04-16 11:25:10 +02:00
arc_pack_settime_action_req(&setTimeRequest, commandBuffer, &rawPacketLen);
size_t serLen = 0;
2023-07-12 17:59:07 +02:00
// Time in milliseconds. Manual serialization because arcsec API ignores endianness.
SerializeAdapter::serialize(&setTimeRequest.unixTime, commandBuffer + 2, &serLen,
sizeof(commandBuffer) - 2, SerializeIF::Endianness::LITTLE);
2023-07-12 17:59:07 +02:00
rawPacket = commandBuffer;
2023-04-16 11:25:10 +02:00
return returnvalue::OK;
}
2023-11-21 14:34:15 +01:00
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
}
2023-10-09 15:16:48 +02:00
case (startracker::REQ_CENTROID): {
2023-10-09 15:18:40 +02:00
prepareRequestCentroidTm();
2023-10-09 15:16:48 +02:00
return returnvalue::OK;
}
case (startracker::REQ_CENTROIDS): {
2023-10-09 15:18:40 +02:00
prepareRequestCentroidsTm();
2023-10-09 15:16:48 +02:00
return returnvalue::OK;
}
2023-10-27 11:24:51 +02:00
case (startracker::REQ_CONTRAST): {
2023-10-27 12:17:54 +02:00
prepareRequestContrastTm();
2023-10-27 11:24:51 +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;
}
2023-07-13 20:49:42 +02:00
case (startracker::AUTO_THRESHOLD): {
result =
prepareParamCommand(commandData, commandDataLen, jcfgs.autoThreshold, reinitNextSetParam);
return result;
}
2022-02-25 14:24:51 +01:00
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;
}
2023-10-02 16:11:17 +02:00
case (startracker::REQ_MATCHED_CENTROIDS): {
2023-10-19 14:54:12 +02:00
result = prepareRequestMatchedCentroidsTm();
2023-10-02 16:11:17 +02:00
return result;
}
2023-10-06 11:23:31 +02:00
case (startracker::REQ_BLOB): {
result = prepareRequestBlobTm();
return result;
}
case (startracker::REQ_BLOBS): {
result = prepareRequestBlobsTm();
return result;
}
2023-10-27 12:17:54 +02:00
case (startracker::REQ_AUTO_BLOB): {
2023-10-26 20:45:36 +02:00
result = prepareRequestAutoBlobTm();
return returnvalue::OK;
}
2022-02-25 14:24:51 +01:00
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);
2023-11-21 14:34:15 +01:00
this->insertInCommandMap(startracker::RELOAD_JSON_CFG_FILE);
2022-02-25 14:24:51 +01:00
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);
2023-07-13 17:35:12 +02:00
this->insertInCommandAndReplyMap(startracker::SET_TIME_FROM_SYS_TIME, 2, nullptr,
2023-04-16 11:25:10 +02:00
startracker::MAX_FRAME_SIZE * 2 + 2);
2022-02-25 14:24:51 +01:00
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);
2023-07-13 20:49:42 +02:00
this->insertInCommandAndReplyMap(startracker::AUTO_THRESHOLD, 2, nullptr,
startracker::MAX_FRAME_SIZE * 2 + 2);
2022-02-25 14:24:51 +01:00
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);
2023-07-13 16:38:20 +02:00
this->insertInCommandAndReplyMap(startracker::CENTROIDING, 2, nullptr,
2022-02-25 14:24:51 +01:00
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);
2023-10-19 14:54:12 +02:00
this->insertInCommandAndReplyMap(startracker::REQ_AUTO_BLOB, 3, &autoBlobSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
2023-10-19 09:26:28 +02:00
this->insertInCommandAndReplyMap(startracker::REQ_MATCHED_CENTROIDS, 3, &matchedCentroidsSet,
2023-10-02 16:11:17 +02:00
startracker::MAX_FRAME_SIZE * 2 + 2);
2023-10-09 15:16:48 +02:00
this->insertInCommandAndReplyMap(startracker::REQ_BLOB, 3, &blobSet,
2023-10-06 11:23:31 +02:00
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_BLOBS, 3, &blobsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
2023-10-09 15:16:48 +02:00
this->insertInCommandAndReplyMap(startracker::REQ_CENTROID, 3, &centroidSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
this->insertInCommandAndReplyMap(startracker::REQ_CENTROIDS, 3, &centroidsSet,
startracker::MAX_FRAME_SIZE * 2 + 2);
2023-10-27 11:24:51 +02:00
this->insertInCommandAndReplyMap(startracker::REQ_CONTRAST, 3, &contrastSet,
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;
2023-07-13 17:03:56 +02:00
solutionSet.setReportingEnabled(true);
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-11-16 16:57:36 +01:00
void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, std::string paramJsonFile) {
2023-03-08 01:21:18 +01:00
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);
2023-07-13 20:49:42 +02:00
cfgs.autoThreshold.init(paramJsonFile);
2023-03-08 01:21:18 +01:00
JCFG_DONE = true;
}
2023-10-02 16:11:17 +02:00
ReturnValue_t StarTrackerHandler::statusFieldCheck(const uint8_t* rawFrame) {
uint8_t status = startracker::getStatusField(rawFrame);
if (status != startracker::STATUS_OK) {
sif::warning << "StarTrackerHandler::handleTm: Reply error: "
<< static_cast<unsigned int>(status) << std::endl;
return REPLY_ERROR;
}
return returnvalue::OK;
}
2023-10-09 15:56:48 +02:00
void StarTrackerHandler::addSecondaryTmForNormalMode(DeviceCommandId_t cmd) {
additionalRequestedTm.emplace(cmd);
}
void StarTrackerHandler::resetSecondaryTmSet() {
additionalRequestedTm.clear();
additionalRequestedTm.emplace(startracker::REQ_TEMPERATURE);
2023-10-27 09:59:15 +02:00
currentSecondaryTmIter = additionalRequestedTm.begin();
2023-10-26 09:52:25 +02:00
{
PoolReadGuard pg(&autoBlobSet);
if (pg.getReadResult() == returnvalue::OK) {
autoBlobSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&matchedCentroidsSet);
if (pg.getReadResult() == returnvalue::OK) {
matchedCentroidsSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&blobSet);
if (pg.getReadResult() == returnvalue::OK) {
blobSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&blobsSet);
if (pg.getReadResult() == returnvalue::OK) {
blobsSet.setValidity(false, true);
}
}
{
PoolReadGuard pg(&centroidSet);
if (pg.getReadResult() == returnvalue::OK) {
centroidSet.setValidity(false, true);
}
}
2023-10-27 12:17:54 +02:00
{
PoolReadGuard pg(&contrastSet);
if (pg.getReadResult() == returnvalue::OK) {
contrastSet.setValidity(false, true);
}
}
2023-10-26 09:52:25 +02:00
{
PoolReadGuard pg(&centroidsSet);
if (pg.getReadResult() == returnvalue::OK) {
centroidsSet.setValidity(false, true);
}
}
2023-10-27 11:24:51 +02:00
{
PoolReadGuard pg(&histogramSet);
if (pg.getReadResult() == returnvalue::OK) {
histogramSet.setValidity(false, true);
}
}
2023-10-09 15:56:48 +02:00
}
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;
}
2023-07-13 21:09:27 +02:00
if (remainingSize < 2) {
sif::error << "StarTrackerHandler: Reply packet with length " << remainingSize
<< " less than "
"2 is invalid"
2023-03-21 20:35:28 +01:00
<< std::endl;
return returnvalue::FAILED;
2022-02-25 14:24:51 +01:00
}
switch (startracker::getReplyFrameType(start)) {
2023-07-13 21:09:27 +02:00
case TMTC_COMM_ERROR: {
*foundLen = remainingSize;
triggerEvent(COM_ERROR_REPLY_RECEIVED, start[1]);
break;
}
2022-02-25 14:24:51 +01:00
case TMTC_ACTIONREPLY: {
*foundLen = remainingSize;
2023-10-02 16:11:17 +02:00
fullPacketLen = remainingSize;
return scanForActionReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
}
case TMTC_SETPARAMREPLY: {
*foundLen = remainingSize;
2023-10-02 16:11:17 +02:00
fullPacketLen = remainingSize;
return scanForSetParameterReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
}
case TMTC_PARAMREPLY: {
*foundLen = remainingSize;
2023-10-02 16:11:17 +02:00
fullPacketLen = remainingSize;
return scanForGetParameterReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
}
case TMTC_TELEMETRYREPLYA:
case TMTC_TELEMETRYREPLY: {
*foundLen = remainingSize;
2023-10-02 16:11:17 +02:00
fullPacketLen = remainingSize;
return scanForTmReply(startracker::getId(start), foundId);
2022-02-25 14:24:51 +01:00
}
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) {
2023-07-13 10:53:58 +02:00
case (startracker::SET_TIME_FROM_SYS_TIME): {
2023-07-12 17:59:07 +02:00
result = handleActionReply(packet);
break;
}
2022-02-25 14:24:51 +01:00
case (startracker::REQ_TIME): {
2023-10-27 12:17:54 +02:00
result = handleTm(packet, timeSet, "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-10-27 12:17:54 +02:00
result = handleTm(packet, versionSet, "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-10-27 12:17:54 +02:00
result = handleTm(packet, interfaceSet, "REQ_INTERFACE");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_POWER): {
2023-10-27 12:17:54 +02:00
result = handleTm(packet, powerSet, "REQ_POWER");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_SOLUTION): {
2023-10-27 12:17:54 +02:00
result = handleTm(packet, solutionSet, "REQ_SOLUTION");
2022-02-25 14:24:51 +01:00
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::REQ_CONTRAST): {
result = handleTm(packet, contrastSet, "REQ_CONTRAST");
2023-10-27 11:24:51 +02:00
break;
}
2023-10-19 09:37:01 +02:00
case (startracker::REQ_AUTO_BLOB): {
result = handleAutoBlobTm(packet);
break;
}
2023-10-02 16:11:17 +02:00
case (startracker::REQ_MATCHED_CENTROIDS): {
result = handleMatchedCentroidTm(packet);
break;
}
2023-10-06 11:23:31 +02:00
case (startracker::REQ_BLOB): {
result = handleBlobTm(packet);
break;
}
case (startracker::REQ_BLOBS): {
result = handleBlobsTm(packet);
break;
}
2023-10-09 15:16:48 +02:00
case (startracker::REQ_CENTROID): {
result = handleCentroidTm(packet);
break;
}
case (startracker::REQ_CENTROIDS): {
result = handleCentroidsTm(packet);
break;
}
2022-02-25 14:24:51 +01:00
case (startracker::REQ_TEMPERATURE): {
2023-10-27 12:17:54 +02:00
result = handleTm(packet, temperatureSet, "REQ_TEMP");
2022-02-25 14:24:51 +01:00
break;
}
case (startracker::REQ_HISTOGRAM): {
2023-10-27 12:17:54 +02:00
result = handleTm(packet, histogramSet, "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):
2023-07-13 20:49:42 +02:00
case (startracker::ALGO):
case (startracker::AUTO_THRESHOLD): {
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-10-19 14:54:12 +02:00
2023-10-26 20:45:36 +02:00
localDataPoolMap.emplace(startracker::TICKS_AUTO_BLOB, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::TIME_AUTO_BLOB, new PoolEntry<uint64_t>());
2023-10-19 14:54:12 +02:00
localDataPoolMap.emplace(startracker::AUTO_BLOB_THRESHOLD, new PoolEntry<float>());
2023-10-02 16:11:17 +02:00
localDataPoolMap.emplace(startracker::PoolIds::NUM_MATCHED_CENTROIDS, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_STAR_IDS,
new PoolEntry<uint32_t>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_COORDS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_COORDS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_X_ERRORS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::MATCHED_CENTROIDS_Y_ERRORS,
new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::TICKS_MATCHED_CENTROIDS,
new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::TIME_MATCHED_CENTROIDS, new PoolEntry<uint64_t>());
2023-01-24 12:24:29 +01:00
2023-10-06 11:35:57 +02:00
localDataPoolMap.emplace(startracker::PoolIds::BLOB_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOB_TIME, new PoolEntry<uint64_t>());
2023-10-06 11:23:31 +02:00
localDataPoolMap.emplace(startracker::PoolIds::BLOB_COUNT, new PoolEntry<uint32_t>());
2023-10-06 11:35:57 +02:00
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_TIME, new PoolEntry<uint64_t>());
2023-10-06 11:23:31 +02:00
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_COUNT_USED, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_NR_4LINES_SKIPPED,
new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_X_COORDS, new PoolEntry<uint16_t>(8));
localDataPoolMap.emplace(startracker::PoolIds::BLOBS_Y_COORDS, new PoolEntry<uint16_t>(8));
2023-10-09 15:16:48 +02:00
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROID_COUNT, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_COUNT, new PoolEntry<uint16_t>());
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_X_COORDS, new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_Y_COORDS, new PoolEntry<float>(16));
localDataPoolMap.emplace(startracker::PoolIds::CENTROIDS_MAGNITUDES, new PoolEntry<uint8_t>(16));
2023-10-27 11:24:51 +02:00
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TICKS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_TIME, new PoolEntry<uint64_t>());
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_A, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_B, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_C, new PoolEntry<uint32_t>(9));
localDataPoolMap.emplace(startracker::PoolIds::CONTRAST_D, new PoolEntry<uint32_t>(9));
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));
2023-10-19 14:54:12 +02:00
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(autoBlobSet.getSid(), false, 10.0));
2023-10-09 15:16:48 +02:00
poolManager.subscribeForRegularPeriodicPacket(
2023-10-19 09:26:28 +02:00
subdp::RegularHkPeriodicParams(matchedCentroidsSet.getSid(), false, 10.0));
2023-10-09 15:16:48 +02:00
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(blobSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(blobsSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(centroidSet.getSid(), false, 10.0));
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(centroidsSet.getSid(), false, 10.0));
2023-10-27 11:24:51 +02:00
poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(contrastSet.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;
}
2023-04-16 11:35:30 +02:00
case (ARC_ACTION_REQ_SETTIME_ID): {
2023-07-13 10:53:58 +02:00
*foundId = startracker::SET_TIME_FROM_SYS_TIME;
2023-04-16 11:25:10 +02:00
break;
}
2022-02-25 14:24:51 +01:00
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;
}
2023-07-13 20:49:42 +02:00
case (startracker::ID::AUTO_THRESHOLD): {
*foundId = startracker::AUTO_THRESHOLD;
break;
}
2022-02-25 14:24:51 +01:00
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;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::BLOB): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_BLOB;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::BLOBS): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_BLOBS;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::CENTROID): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_CENTROID;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::CENTROIDS): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_CENTROIDS;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::AUTO_BLOB): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_AUTO_BLOB;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::MATCHED_CENTROIDS): {
2023-10-26 19:59:16 +02:00
*foundId = startracker::REQ_MATCHED_CENTROIDS;
break;
}
2023-10-27 12:17:54 +02:00
case (startracker::ID::CONTRAST): {
2023-10-27 11:24:51 +02:00
*foundId = startracker::REQ_CONTRAST;
break;
}
2022-02-25 14:24:51 +01:00
default: {
2023-10-26 19:59:16 +02:00
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
}
2023-10-19 14:54:12 +02:00
ReturnValue_t StarTrackerHandler::prepareRequestAutoBlobTm() {
uint32_t length = 0;
arc_tm_pack_autoblob_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestMatchedCentroidsTm() {
2023-10-02 16:11:17 +02:00
uint32_t length = 0;
arc_tm_pack_matchedcentroids_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
2023-10-06 11:23:31 +02:00
ReturnValue_t StarTrackerHandler::prepareRequestBlobTm() {
uint32_t length = 0;
arc_tm_pack_blob_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestBlobsTm() {
uint32_t length = 0;
arc_tm_pack_blobs_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
2023-10-09 15:16:48 +02:00
ReturnValue_t StarTrackerHandler::prepareRequestCentroidTm() {
uint32_t length = 0;
arc_tm_pack_centroid_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::prepareRequestCentroidsTm() {
uint32_t length = 0;
arc_tm_pack_centroids_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
2023-10-27 11:24:51 +02:00
ReturnValue_t StarTrackerHandler::prepareRequestContrastTm() {
uint32_t length = 0;
arc_tm_pack_contrast_req(commandBuffer, &length);
rawPacket = commandBuffer;
rawPacketLen = length;
return returnvalue::OK;
}
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 "
2023-07-12 17:59:07 +02:00
"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-04-16 11:25:10 +02:00
handleStartup(*rawFrame, *(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);
2023-07-12 17:59:07 +02:00
ReturnValue_t result = returnvalue::OK;
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;
2023-07-12 17:59:07 +02:00
result = ACTION_FAILED;
2022-02-25 14:24:51 +01:00
}
2023-07-12 17:59:07 +02:00
if (internalState != InternalState::IDLE) {
handleStartup(*rawFrame, *(rawFrame + PARAMETER_ID_OFFSET));
}
return result;
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::SET_TIME;
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-10-27 12:17:54 +02:00
const char* context) {
2023-10-02 16:11:17 +02:00
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
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 + TICKS_OFFSET;
2022-02-25 14:24:51 +01:00
dataset.setValidityBufferGeneration(false);
2023-10-27 12:17:54 +02:00
size_t sizeLeft = fullPacketLen;
result = dataset.deSerialize(&reply, &sizeLeft, SerializeIF::Endianness::LITTLE);
2022-08-24 17:27:47 +02:00
if (result != returnvalue::OK) {
2023-10-27 12:17:54 +02:00
sif::warning << "StarTrackerHandler::handleTm: Deserialization failed for " << context << ": 0x"
<< std::hex << std::setw(4) << result << std::dec << 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-10-19 09:26:28 +02:00
ReturnValue_t StarTrackerHandler::handleAutoBlobTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-19 09:26:28 +02:00
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&autoBlobSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&autoBlobSet.threshold, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
autoBlobSet.setValidity(true, true);
return returnvalue::OK;
}
2023-10-02 16:11:17 +02:00
ReturnValue_t StarTrackerHandler::handleMatchedCentroidTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-02 16:11:17 +02:00
size_t remainingLen = fullPacketLen;
2023-10-19 09:26:28 +02:00
PoolReadGuard pg(&matchedCentroidsSet);
2023-10-02 16:11:17 +02:00
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.ticks, &rawFrame, &remainingLen,
2023-10-02 16:11:17 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.timeUs, &rawFrame, &remainingLen,
2023-10-02 16:11:17 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.numberOfMatchedCentroids, &rawFrame,
2023-10-02 16:11:17 +02:00
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
// Yeah, we serialize it like that because I can't model anything with that local datapool crap.
for (unsigned idx = 0; idx < 16; idx++) {
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.starIds[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
2023-10-02 16:11:17 +02:00
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
2023-10-02 16:11:17 +02:00
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
2023-10-02 16:11:17 +02:00
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.xErrors[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
2023-10-02 16:11:17 +02:00
if (result != returnvalue::OK) {
return result;
}
2023-10-19 09:26:28 +02:00
result = SerializeAdapter::deSerialize(&matchedCentroidsSet.yErrors[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
2023-10-02 16:11:17 +02:00
if (result != returnvalue::OK) {
return result;
}
}
2023-10-19 09:26:28 +02:00
matchedCentroidsSet.setValidity(true, true);
2023-10-02 16:11:17 +02:00
return returnvalue::OK;
}
2023-10-06 11:23:31 +02:00
ReturnValue_t StarTrackerHandler::handleBlobTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-06 11:23:31 +02:00
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&blobsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
result = SerializeAdapter::deSerialize(&blobSet.ticks, &rawFrame, &remainingLen,
2023-10-06 11:23:31 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
result = SerializeAdapter::deSerialize(&blobSet.timeUs, &rawFrame, &remainingLen,
2023-10-06 11:23:31 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
result = SerializeAdapter::deSerialize(&blobSet.blobCount, &rawFrame, &remainingLen,
2023-10-06 11:23:31 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
blobSet.setValidity(true, true);
2023-10-06 11:23:31 +02:00
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleBlobsTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-06 11:23:31 +02:00
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&blobsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
result = SerializeAdapter::deSerialize(&blobsSet.ticks, &rawFrame, &remainingLen,
2023-10-06 11:23:31 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
2023-10-09 15:16:48 +02:00
result = SerializeAdapter::deSerialize(&blobsSet.timeUs, &rawFrame, &remainingLen,
2023-10-06 11:23:31 +02:00
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.blobsCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.blobsCountUsed, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.nr4LinesSkipped, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
for (unsigned idx = 0; idx < 8; idx++) {
result = SerializeAdapter::deSerialize(&blobsSet.xCoords[idx], &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&blobsSet.yCoords[idx], &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
}
2023-10-09 15:16:48 +02:00
blobsSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleCentroidTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-09 15:16:48 +02:00
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&centroidsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.ticks, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.timeUs, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidSet.centroidCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
centroidSet.setValidity(true, true);
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::handleCentroidsTm(const uint8_t* rawFrame) {
ReturnValue_t result = statusFieldCheck(rawFrame);
if (result != returnvalue::OK) {
return result;
}
2023-10-26 20:45:36 +02:00
rawFrame += TICKS_OFFSET;
2023-10-09 15:16:48 +02:00
size_t remainingLen = fullPacketLen;
PoolReadGuard pg(&centroidsSet);
result = pg.getReadResult();
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.ticksCentroidsTm, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.timeUsCentroidsTm, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsCount, &rawFrame, &remainingLen,
SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
for (unsigned idx = 0; idx < 16; idx++) {
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsXCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsYCoords[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&centroidsSet.centroidsMagnitudes[idx], &rawFrame,
&remainingLen, SerializeIF::Endianness::LITTLE);
if (result != returnvalue::OK) {
return result;
}
}
centroidsSet.setValidity(true, true);
2023-10-06 11:23:31 +02:00
return returnvalue::OK;
}
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-04-16 11:25:10 +02:00
void StarTrackerHandler::handleStartup(uint8_t tmType, uint8_t parameterId) {
2023-04-16 11:35:30 +02:00
switch (tmType) {
case (TMTC_ACTIONREPLY): {
case (ARC_ACTION_REQ_SETTIME_ID): {
bootState = FwBootState::LOGLEVEL;
return;
}
default: {
break;
}
2023-04-16 11:25:10 +02:00
}
}
2023-03-22 02:20:14 +01:00
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;
}
2023-04-16 11:25:10 +02:00
case (ARC_PARAM_TRACKING_ID): {
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-07-13 20:49:42 +02:00
bootState = FwBootState::AUTO_THRESHOLD;
break;
}
case (startracker::ID::AUTO_THRESHOLD): {
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-10-02 16:11:17 +02:00
case startracker::REQ_MATCHED_CENTROIDS:
2023-10-06 11:23:31 +02:00
case startracker::REQ_BLOB:
case startracker::REQ_BLOBS:
2023-10-09 15:16:48 +02:00
case startracker::REQ_CENTROID:
case startracker::REQ_CENTROIDS:
2023-10-27 12:17:54 +02:00
case startracker::REQ_CONTRAST: {
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;
2023-10-27 12:17:54 +02:00
}
2022-02-25 14:24:51 +01:00
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
}
2023-11-21 14:54:21 +01:00
ReturnValue_t StarTrackerHandler::acceptExternalDeviceCommands() { return returnvalue::OK; }