PLEASE WORK

This commit is contained in:
Robin Müller 2023-11-21 14:54:21 +01:00
parent f9d2d35f86
commit cdad099f32
2 changed files with 28 additions and 16 deletions

View File

@ -5,6 +5,8 @@
#include <mission/acs/str/strHelpers.h>
#include <mission/acs/str/strJsonCommands.h>
#include "fsfw/ipc/MessageQueueIF.h"
extern "C" {
#include <sagitta/client/actionreq.h>
#include <sagitta/client/client_tm_structs.h>
@ -183,21 +185,6 @@ ReturnValue_t StarTrackerHandler::executeAction(ActionId_t actionId, MessageQueu
ReturnValue_t result = returnvalue::OK;
switch (actionId) {
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.
if(reloadJsonCfgFile()) {
// Could trigger this after the thread has finished, but the base class does not accept
// commands for buildCommandForCommand when it is OFF. I am sure there is way to solve
// this, but I don't care anymore. This is fine.
return HasActionsIF::EXECUTION_FINISHED;
};
return returnvalue::OK;
}
case (startracker::ADD_SECONDARY_TM_TO_NORMAL_MODE): {
if (size < 4) {
return HasActionsIF::INVALID_PARAMETERS;
@ -361,11 +348,21 @@ void StarTrackerHandler::performOperationHook() {
}
if (jcfgPending) {
if (JCFG_DONE) {
sif::debug << "jcfg fucking done" << std::endl;
jsonCfgTask.join();
jcfgPending = false;
JCFG_DONE = false;
auto iter = deviceCommandMap.find(startracker::RELOAD_JSON_CFG_FILE);
if (iter != deviceCommandMap.end() and iter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) {
sif::debug << "jcfg sending finished" << std::endl;
actionHelper.finish(true, iter->second.sendReplyTo, startracker::RELOAD_JSON_CFG_FILE);
}
} else if (jcfgCountdown.hasTimedOut()) {
JCFG_DONE = false;
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);
}
}
}
}
@ -532,6 +529,16 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
preparePingRequest();
return returnvalue::OK;
}
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;
}
case (startracker::SET_TIME_FROM_SYS_TIME): {
SetTimeActionRequest setTimeRequest{};
timeval tv;
@ -2846,3 +2853,5 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) {
}
return returnvalue::OK;
}
ReturnValue_t StarTrackerHandler::acceptExternalDeviceCommands() { return returnvalue::OK; }

View File

@ -27,7 +27,9 @@ extern "C" {
* @details Datasheet: https://eive-cloud.irs.uni-stuttgart.de/index.php/apps/files/?dir=/EIVE_IRS/
* Arbeitsdaten/08_Used%20Components/ArcSec_KULeuven_Startracker/
* Sagitta%201.0%20Datapack&fileid=659181
* @author J. Meier
* @note The STR code is a chaotic inconsistent mess and should be re-written with a simpler base
* class. DO NOT USE THIS AS REFERENCE. Stay away from it.
* @author J. Meier, R. Mueller
*/
class StarTrackerHandler : public DeviceHandlerBase {
public:
@ -546,6 +548,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
void bootFirmware(Mode_t toMode);
void bootBootloader();
bool reloadJsonCfgFile();
ReturnValue_t acceptExternalDeviceCommands() override;
};
#endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */