Star Tracker : Tweaks and fixes #443

Merged
muellerr merged 7 commits from startracker_try_cfg_time_reduction into develop 2023-03-08 01:26:04 +01:00
3 changed files with 83 additions and 47 deletions
Showing only changes of commit 01e97c8381 - Show all commits

2
fsfw

@ -1 +1 @@
Subproject commit 7f6ba5f40b47bc32802efdc4ed41b4bad4b8071b Subproject commit 1b7493f945302b3785ceba6e7a34a727e3898a13

View File

@ -3,7 +3,9 @@
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include <fsfw/timemanager/Stopwatch.h> #include <fsfw/timemanager/Stopwatch.h>
#include <atomic>
#include <fstream> #include <fstream>
#include <thread>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "StarTrackerJsonCommands.h" #include "StarTrackerJsonCommands.h"
@ -15,6 +17,8 @@ extern "C" {
#include "common/misc.h" #include "common/misc.h"
} }
std::atomic_bool JCFG_DONE(false);
StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie,
const char* jsonFileStr, StrHelper* strHelper, const char* jsonFileStr, StrHelper* strHelper,
power::Switch_t powerSwitch) power::Switch_t powerSwitch)
@ -62,23 +66,10 @@ ReturnValue_t StarTrackerHandler::initialize() {
return result; return result;
} }
// TODO: This takes 200-250ms. Move it into a separate thread, use a mutexed boolean // Spin up a thread to do the JSON initialization, takes 200-250 ms which would
// to check whether init was done. Or move it into the helper class.. // delay whole satellite boot process.
// Also move update of these classes into the helper class. jcfgCountdown.resetTimer();
tracking.init(paramJsonFile); jsonCfgTask = std::thread{setUpJsonCfgs, std::ref(jcfgs), paramJsonFile.c_str()};
logLevel.init(paramJsonFile);
logSubscription.init(paramJsonFile);
debugCamera.init(paramJsonFile);
algo.init(paramJsonFile);
validation.init(paramJsonFile);
matching.init(paramJsonFile);
lisa.init(paramJsonFile);
centroiding.init(paramJsonFile);
camera.init(paramJsonFile);
imageProcessor.init(paramJsonFile);
mounting.init(paramJsonFile);
limits.init(paramJsonFile);
subscription.init(paramJsonFile);
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER); EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) { if (manager == nullptr) {
@ -261,8 +252,19 @@ void StarTrackerHandler::doStartUp() {
// the device handler's submode to the star tracker's mode // the device handler's submode to the star tracker's mode
return; return;
case StartupState::DONE: case StartupState::DONE:
if (jcfgCountdown.isBusy()) {
startupState = StartupState::WAIT_JCFG;
return;
}
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
break; break;
case StartupState::WAIT_JCFG: {
if (jcfgCountdown.hasTimedOut()) {
startupState = StartupState::IDLE;
break;
}
return;
}
default: default:
return; return;
} }
@ -440,7 +442,7 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
return returnvalue::OK; return returnvalue::OK;
} }
case (startracker::SUBSCRIPTION): { case (startracker::SUBSCRIPTION): {
result = prepareParamCommand(commandData, commandDataLen, subscription); result = prepareParamCommand(commandData, commandDataLen, jcfgs.subscription);
return returnvalue::OK; return returnvalue::OK;
} }
case (startracker::REQ_SOLUTION): { case (startracker::REQ_SOLUTION): {
@ -456,55 +458,55 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
return returnvalue::OK; return returnvalue::OK;
} }
case (startracker::LIMITS): { case (startracker::LIMITS): {
result = prepareParamCommand(commandData, commandDataLen, limits); result = prepareParamCommand(commandData, commandDataLen, jcfgs.limits);
return result; return result;
} }
case (startracker::MOUNTING): { case (startracker::MOUNTING): {
result = prepareParamCommand(commandData, commandDataLen, mounting); result = prepareParamCommand(commandData, commandDataLen, jcfgs.mounting);
return result; return result;
} }
case (startracker::IMAGE_PROCESSOR): { case (startracker::IMAGE_PROCESSOR): {
result = prepareParamCommand(commandData, commandDataLen, imageProcessor); result = prepareParamCommand(commandData, commandDataLen, jcfgs.imageProcessor);
return result; return result;
} }
case (startracker::CAMERA): { case (startracker::CAMERA): {
result = prepareParamCommand(commandData, commandDataLen, camera); result = prepareParamCommand(commandData, commandDataLen, jcfgs.camera);
return result; return result;
} }
case (startracker::CENTROIDING): { case (startracker::CENTROIDING): {
result = prepareParamCommand(commandData, commandDataLen, centroiding); result = prepareParamCommand(commandData, commandDataLen, jcfgs.centroiding);
return result; return result;
} }
case (startracker::LISA): { case (startracker::LISA): {
result = prepareParamCommand(commandData, commandDataLen, lisa); result = prepareParamCommand(commandData, commandDataLen, jcfgs.lisa);
return result; return result;
} }
case (startracker::MATCHING): { case (startracker::MATCHING): {
result = prepareParamCommand(commandData, commandDataLen, matching); result = prepareParamCommand(commandData, commandDataLen, jcfgs.matching);
return result; return result;
} }
case (startracker::VALIDATION): { case (startracker::VALIDATION): {
result = prepareParamCommand(commandData, commandDataLen, validation); result = prepareParamCommand(commandData, commandDataLen, jcfgs.validation);
return result; return result;
} }
case (startracker::ALGO): { case (startracker::ALGO): {
result = prepareParamCommand(commandData, commandDataLen, algo); result = prepareParamCommand(commandData, commandDataLen, jcfgs.algo);
return result; return result;
} }
case (startracker::TRACKING): { case (startracker::TRACKING): {
result = prepareParamCommand(commandData, commandDataLen, tracking); result = prepareParamCommand(commandData, commandDataLen, jcfgs.tracking);
return result; return result;
} }
case (startracker::LOGLEVEL): { case (startracker::LOGLEVEL): {
result = prepareParamCommand(commandData, commandDataLen, logLevel); result = prepareParamCommand(commandData, commandDataLen, jcfgs.logLevel);
return result; return result;
} }
case (startracker::LOGSUBSCRIPTION): { case (startracker::LOGSUBSCRIPTION): {
result = prepareParamCommand(commandData, commandDataLen, logSubscription); result = prepareParamCommand(commandData, commandDataLen, jcfgs.logSubscription);
return result; return result;
} }
case (startracker::DEBUG_CAMERA): { case (startracker::DEBUG_CAMERA): {
result = prepareParamCommand(commandData, commandDataLen, debugCamera); result = prepareParamCommand(commandData, commandDataLen, jcfgs.debugCamera);
return result; return result;
} }
case (startracker::CHECKSUM): { case (startracker::CHECKSUM): {
@ -753,6 +755,24 @@ void StarTrackerHandler::bootFirmware(Mode_t toMode) {
} }
} }
void StarTrackerHandler::setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonFile) {
cfgs.tracking.init(paramJsonFile);
cfgs.logLevel.init(paramJsonFile);
cfgs.logSubscription.init(paramJsonFile);
cfgs.debugCamera.init(paramJsonFile);
cfgs.algo.init(paramJsonFile);
cfgs.validation.init(paramJsonFile);
cfgs.matching.init(paramJsonFile);
cfgs.lisa.init(paramJsonFile);
cfgs.centroiding.init(paramJsonFile);
cfgs.camera.init(paramJsonFile);
cfgs.imageProcessor.init(paramJsonFile);
cfgs.mounting.init(paramJsonFile);
cfgs.limits.init(paramJsonFile);
cfgs.subscription.init(paramJsonFile);
JCFG_DONE = true;
}
void StarTrackerHandler::bootBootloader() { void StarTrackerHandler::bootBootloader() {
if (internalState == InternalState::IDLE) { if (internalState == InternalState::IDLE) {
internalState = InternalState::BOOT_BOOTLOADER; internalState = InternalState::BOOT_BOOTLOADER;

View File

@ -4,6 +4,8 @@
#include <fsfw/datapool/PoolReadGuard.h> #include <fsfw/datapool/PoolReadGuard.h>
#include <linux/devices/startracker/StarTrackerJsonCommands.h> #include <linux/devices/startracker/StarTrackerJsonCommands.h>
#include <thread>
#include "ArcsecDatalinkLayer.h" #include "ArcsecDatalinkLayer.h"
#include "ArcsecJsonParamBase.h" #include "ArcsecJsonParamBase.h"
#include "OBSWConfig.h" #include "OBSWConfig.h"
@ -217,6 +219,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
// Loading firmware requires some time and the command will not trigger a reply when executed // Loading firmware requires some time and the command will not trigger a reply when executed
Countdown bootCountdown; Countdown bootCountdown;
struct JsonConfigs {
Tracking tracking; Tracking tracking;
LogLevel logLevel; LogLevel logLevel;
LogSubscription logSubscription; LogSubscription logSubscription;
@ -231,6 +234,12 @@ class StarTrackerHandler : public DeviceHandlerBase {
Mounting mounting; Mounting mounting;
Limits limits; Limits limits;
Subscription subscription; Subscription subscription;
};
JsonConfigs jcfgs;
Countdown jcfgCountdown = Countdown(250);
bool commandExecuted = false;
std::thread jsonCfgTask;
static void setUpJsonCfgs(JsonConfigs& cfgs, const char* paramJsonFile);
std::string paramJsonFile; std::string paramJsonFile;
@ -270,7 +279,14 @@ class StarTrackerHandler : public DeviceHandlerBase {
InternalState internalState = InternalState::IDLE; InternalState internalState = InternalState::IDLE;
enum class StartupState { IDLE, CHECK_PROGRAM, WAIT_CHECK_PROGRAM, BOOT_BOOTLOADER, DONE }; enum class StartupState {
IDLE,
CHECK_PROGRAM,
WAIT_CHECK_PROGRAM,
BOOT_BOOTLOADER,
WAIT_JCFG,
DONE
};
StartupState startupState = StartupState::IDLE; StartupState startupState = StartupState::IDLE;