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

564 lines
21 KiB
C
Raw Permalink Normal View History

2021-07-07 12:12:01 +02:00
#ifndef MISSION_DEVICES_STARTRACKERHANDLER_H_
#define MISSION_DEVICES_STARTRACKERHANDLER_H_
2021-11-27 19:40:52 +01:00
#include <fsfw/datapool/PoolReadGuard.h>
#include <linux/acs/StrComHandler.h>
#include <mission/acs/str/ArcsecJsonParamBase.h>
#include <mission/acs/str/strHelpers.h>
#include <mission/acs/str/strJsonCommands.h>
2023-04-16 11:25:10 +02:00
#include <thirdparty/sagittactl/wire/common/genericstructs.h>
2022-01-17 15:58:27 +01:00
2023-10-09 15:29:04 +02:00
#include <set>
2023-03-08 01:21:18 +01:00
#include <thread>
2022-01-17 15:58:27 +01:00
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
#include "fsfw/timemanager/Countdown.h"
2021-07-07 12:12:01 +02:00
2023-04-13 18:09:02 +02:00
extern "C" {
2023-04-16 11:25:10 +02:00
#include <wire/common/genericstructs.h>
2023-04-13 18:09:02 +02:00
}
2021-07-07 12:12:01 +02:00
/**
* @brief This is the device handler for the star tracker from arcsec.
*
* @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
2023-11-21 14:54:21 +01:00
* @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
2021-07-07 12:12:01 +02:00
*/
2022-01-17 15:58:27 +01:00
class StarTrackerHandler : public DeviceHandlerBase {
public:
/**
* @brief Constructor
*
* @param objectId
* @param comIF
* @param comCookie
* @param gpioComIF Pointer to gpio communication interface
* @param enablePin GPIO connected to the enable pin of the reaction wheels. Must be pulled
* to high to enable the device.
*/
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,
2024-02-19 17:16:08 +01:00
startracker::SdCardConfigPathGetter& cfgPathGetter, SdCardMountedIF& sdCardIF);
2022-01-17 15:58:27 +01:00
virtual ~StarTrackerHandler();
ReturnValue_t initialize() override;
/**
* @brief Overwrite this function from DHB to handle commands executed by the str image
* loader task.
*/
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
void performOperationHook() override;
2022-02-25 14:24:51 +01:00
Submode_t getInitialSubmode() override;
2024-02-19 17:16:08 +01:00
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper,
const ParameterWrapper* newValues, uint16_t startAtIndex) override;
2022-01-17 15:58:27 +01:00
protected:
void doStartUp() override;
void doShutDown() override;
ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override;
ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override;
void fillCommandAndReplyMap() override;
ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, const uint8_t* commandData,
size_t commandDataLen) override;
ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override;
2022-01-17 15:58:27 +01:00
ReturnValue_t scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId,
size_t* foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) override;
void setNormalDatapoolEntriesInvalid() override;
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
/**
2022-11-10 18:07:59 +01:00
* @brief Overwritten here to always read all available data from theSerialComIF.
2022-01-17 15:58:27 +01:00
*/
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
virtual ReturnValue_t doSendReadHook() override;
2022-03-29 07:58:22 +02:00
ReturnValue_t getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) override;
2022-02-23 18:15:34 +01:00
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
2022-01-17 15:58:27 +01:00
private:
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER;
//! [EXPORT] : [COMMENT] Status in temperature reply signals error
static const ReturnValue_t TEMPERATURE_REQ_FAILED = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Ping command failed
static const ReturnValue_t PING_FAILED = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Status in version reply signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t VERSION_REQ_FAILED = MAKE_RETURN_CODE(0xA2);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Status in interface reply signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t INTERFACE_REQ_FAILED = MAKE_RETURN_CODE(0xA3);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Status in power reply signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t POWER_REQ_FAILED = MAKE_RETURN_CODE(0xA4);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Status of reply to parameter set command signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t SET_PARAM_FAILED = MAKE_RETURN_CODE(0xA5);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Status of reply to action command signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t ACTION_FAILED = MAKE_RETURN_CODE(0xA6);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Received invalid path string. Exceeds allowed length
2022-02-27 15:46:06 +01:00
static const ReturnValue_t FILE_PATH_TOO_LONG = MAKE_RETURN_CODE(0xA7);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Name of file received with command is too long
2022-02-27 15:46:06 +01:00
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA8);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Received version reply with invalid program ID
2022-02-27 15:46:06 +01:00
static const ReturnValue_t INVALID_PROGRAM = MAKE_RETURN_CODE(0xA9);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Status field reply signals error
2022-02-27 15:46:06 +01:00
static const ReturnValue_t REPLY_ERROR = MAKE_RETURN_CODE(0xAA);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Received command which is too short (some data is missing for proper
//! execution)
2022-02-27 15:46:06 +01:00
static const ReturnValue_t COMMAND_TOO_SHORT = MAKE_RETURN_CODE(0xAB);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Received command with invalid length (too few or too many parameters)
2022-02-27 15:46:06 +01:00
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xAC);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Region mismatch between send and received data
2022-02-27 15:46:06 +01:00
static const ReturnValue_t REGION_MISMATCH = MAKE_RETURN_CODE(0xAD);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Address mismatch between send and received data
2022-02-27 15:46:06 +01:00
static const ReturnValue_t ADDRESS_MISMATCH = MAKE_RETURN_CODE(0xAE);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Length field mismatch between send and received data
2022-02-27 15:46:06 +01:00
static const ReturnValue_t lENGTH_MISMATCH = MAKE_RETURN_CODE(0xAF);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Specified file does not exist
2022-02-27 15:46:06 +01:00
static const ReturnValue_t FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xB0);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Download blob pixel command has invalid type field
2022-02-27 15:46:06 +01:00
static const ReturnValue_t INVALID_TYPE = MAKE_RETURN_CODE(0xB1);
2022-01-17 15:58:27 +01:00
//! [EXPORT] : [COMMENT] Received FPGA action command with invalid ID
2022-02-27 15:46:06 +01:00
static const ReturnValue_t INVALID_ID = MAKE_RETURN_CODE(0xB2);
2022-01-29 12:27:26 +01:00
//! [EXPORT] : [COMMENT] Received reply is too short
2022-02-27 15:46:06 +01:00
static const ReturnValue_t REPLY_TOO_SHORT = MAKE_RETURN_CODE(0xB3);
2022-01-29 12:27:26 +01:00
//! [EXPORT] : [COMMENT] Received reply with invalid CRC
2022-02-27 15:46:06 +01:00
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xB4);
2022-01-29 12:27:26 +01:00
//! [EXPORT] : [COMMENT] Star tracker handler currently executing a command and using the
//! communication interface
2022-02-27 15:46:06 +01:00
static const ReturnValue_t STR_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB5);
2022-02-14 11:28:15 +01:00
//! [EXPORT] : [COMMENT] Star tracker is already in firmware mode
2022-02-27 15:46:06 +01:00
static const ReturnValue_t STARTRACKER_ALREADY_BOOTED = MAKE_RETURN_CODE(0xB6);
2023-03-21 23:59:28 +01:00
//! [EXPORT] : [COMMENT] Star tracker must be in firmware mode to run this command
2023-03-21 17:35:36 +01:00
static const ReturnValue_t STARTRACKER_NOT_RUNNING_FIRMWARE = MAKE_RETURN_CODE(0xB7);
2023-03-21 23:59:28 +01:00
//! [EXPORT] : [COMMENT] Star tracker must be in bootloader mode to run this command
2023-03-21 17:35:36 +01:00
static const ReturnValue_t STARTRACKER_NOT_RUNNING_BOOTLOADER = MAKE_RETURN_CODE(0xB8);
2022-01-17 15:58:27 +01:00
2022-02-23 18:15:34 +01:00
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER;
//! [EXPORT] : [COMMENT] Failed to boot firmware
2023-02-17 12:19:53 +01:00
static const Event BOOTING_FIRMWARE_FAILED_EVENT = MAKE_EVENT(1, severity::LOW);
2022-02-23 18:15:34 +01:00
//! [EXPORT] : [COMMENT] Failed to boot star tracker into bootloader mode
2023-02-17 12:19:53 +01:00
static const Event BOOTING_BOOTLOADER_FAILED_EVENT = MAKE_EVENT(2, severity::LOW);
2023-07-13 21:09:27 +02:00
//! [EXPORT] : [COMMENT] Received COM error. P1: Communication Error ID (datasheet p32)
static constexpr Event COM_ERROR_REPLY_RECEIVED = MAKE_EVENT(3, severity::LOW);
2022-02-23 18:15:34 +01:00
2023-03-21 20:35:28 +01:00
static const uint8_t STATUS_OFFSET = 2;
static const uint8_t PARAMS_OFFSET = 2;
static const uint8_t TICKS_OFFSET = 3;
static const uint8_t TIME_OFFSET = 7;
2023-10-06 11:23:31 +02:00
static const uint8_t TM_PARAM_OFFSET = 15;
2023-03-21 20:35:28 +01:00
static const uint8_t PARAMETER_ID_OFFSET = 1;
static const uint8_t ACTION_ID_OFFSET = 1;
static const uint8_t ACTION_DATA_OFFSET = 3;
2022-01-17 15:58:27 +01:00
// Ping request will reply ping with this ID (data field)
static const uint32_t PING_ID = 0x55;
2024-02-19 17:16:08 +01:00
uint8_t firmwareTargetRaw = static_cast<uint8_t>(startracker::FirmwareTarget::MAIN);
2022-01-17 15:58:27 +01:00
static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING;
static const uint32_t MUTEX_TIMEOUT = 20;
static const uint32_t BOOT_TIMEOUT = 1000;
2022-02-23 18:15:34 +01:00
static const uint32_t DEFAULT_TRANSITION_DELAY = 15000;
2022-01-17 15:58:27 +01:00
2022-03-30 09:19:30 +02:00
struct FlashReadCmd {
2022-02-25 14:24:51 +01:00
// Minimum length of a read command (region, length and filename)
static const size_t MIN_LENGTH = 7;
2022-01-17 15:58:27 +01:00
};
2022-03-30 09:19:30 +02:00
struct ChecksumCmd {
2022-01-17 15:58:27 +01:00
static const uint8_t ADDRESS_OFFSET = 1;
static const uint8_t LENGTH_OFFSET = 5;
// Length of checksum command
static const size_t LENGTH = 9;
uint8_t rememberRegion = 0;
uint32_t rememberAddress = 0;
uint32_t rememberLength = 0;
};
ChecksumCmd checksumCmd;
MessageQueueIF* eventQueue = nullptr;
2022-02-14 11:28:15 +01:00
startracker::TemperatureSet temperatureSet;
startracker::VersionSet versionSet;
startracker::PowerSet powerSet;
startracker::InterfaceSet interfaceSet;
startracker::TimeSet timeSet;
startracker::SolutionSet solutionSet;
startracker::HistogramSet histogramSet;
startracker::ChecksumSet checksumSet;
startracker::CameraSet cameraSet;
startracker::LimitsSet limitsSet;
startracker::LogLevelSet loglevelSet;
startracker::MountingSet mountingSet;
startracker::ImageProcessorSet imageProcessorSet;
startracker::CentroidingSet centroidingSet;
startracker::LisaSet lisaSet;
startracker::MatchingSet matchingSet;
startracker::TrackingSet trackingSet;
startracker::ValidationSet validationSet;
startracker::AlgoSet algoSet;
startracker::SubscriptionSet subscriptionSet;
startracker::LogSubscriptionSet logSubscriptionSet;
startracker::DebugCameraSet debugCameraSet;
2023-10-19 09:26:28 +02:00
startracker::AutoBlobSet autoBlobSet;
startracker::MatchedCentroidsSet matchedCentroidsSet;
2023-10-09 15:16:48 +02:00
startracker::BlobSet blobSet;
2023-10-06 11:23:31 +02:00
startracker::BlobsSet blobsSet;
2023-10-09 15:16:48 +02:00
startracker::CentroidSet centroidSet;
startracker::CentroidsSet centroidsSet;
2023-10-27 12:17:54 +02:00
startracker::ContrastSet contrastSet;
2024-02-27 13:05:13 +01:00
startracker::BlobStatsSet blobStatsSet;
2022-01-17 15:58:27 +01:00
// Pointer to object responsible for uploading and downloading images to/from the star tracker
2023-03-21 20:35:28 +01:00
StrComHandler* strHelper = nullptr;
2022-01-17 15:58:27 +01:00
2022-02-04 13:06:56 +01:00
uint8_t commandBuffer[startracker::MAX_FRAME_SIZE];
2022-01-17 15:58:27 +01:00
// Countdown to insert delay for star tracker to switch from bootloader to firmware program
2022-02-14 11:28:15 +01:00
// Loading firmware requires some time and the command will not trigger a reply when executed
2022-01-17 15:58:27 +01:00
Countdown bootCountdown;
2023-03-08 01:21:18 +01:00
struct JsonConfigs {
Tracking tracking;
LogLevel logLevel;
LogSubscription logSubscription;
DebugCamera debugCamera;
Algo algo;
Validation validation;
Matching matching;
Lisa lisa;
Centroiding centroiding;
Camera camera;
ImageProcessor imageProcessor;
Mounting mounting;
Limits limits;
Subscription subscription;
2023-07-13 20:49:42 +02:00
AutoThreshold autoThreshold;
2023-03-08 01:21:18 +01:00
};
2023-11-21 14:17:19 +01:00
bool jcfgPending = false;
2023-03-08 01:21:18 +01:00
JsonConfigs jcfgs;
2023-11-21 14:17:19 +01:00
Countdown jcfgCountdown = Countdown(1000);
2023-03-08 01:21:18 +01:00
bool commandExecuted = false;
std::thread jsonCfgTask;
2023-11-16 16:57:36 +01:00
static void setUpJsonCfgs(JsonConfigs& cfgs, std::string paramJsonFile);
2023-03-07 18:47:16 +01:00
std::string paramJsonFile;
2022-01-17 15:58:27 +01:00
2023-10-09 15:29:04 +02:00
enum class NormalState { SECONDARY_REQUEST, SOLUTION_REQUEST };
2022-01-17 15:58:27 +01:00
2023-10-09 15:29:04 +02:00
NormalState normalState = NormalState::SECONDARY_REQUEST;
2022-01-17 15:58:27 +01:00
2023-03-20 17:51:10 +01:00
enum class StartupState {
IDLE,
CHECK_PROGRAM,
WAIT_CHECK_PROGRAM,
BOOT_BOOTLOADER,
WAIT_JCFG,
DONE
};
StartupState startupState = StartupState::IDLE;
2022-02-23 18:15:34 +01:00
enum class InternalState {
2022-01-17 15:58:27 +01:00
IDLE,
2023-03-20 17:51:10 +01:00
BOOT_FIRMWARE,
DONE,
FAILED_FIRMWARE_BOOT,
BOOT_BOOTLOADER,
BOOTLOADER_CHECK,
FAILED_BOOTLOADER_BOOT
};
enum class FwBootState {
NONE,
BOOT_DELAY,
2022-02-23 18:15:34 +01:00
REQ_VERSION,
2022-02-14 11:28:15 +01:00
VERIFY_BOOT,
2023-04-16 11:25:10 +02:00
SET_TIME,
LOGLEVEL,
2022-01-17 15:58:27 +01:00
LIMITS,
TRACKING,
MOUNTING,
2022-01-29 12:27:26 +01:00
IMAGE_PROCESSOR,
2022-01-17 15:58:27 +01:00
CAMERA,
BLOB,
CENTROIDING,
LISA,
MATCHING,
VALIDATION,
ALGO,
LOG_SUBSCRIPTION,
DEBUG_CAMERA,
2023-07-13 20:49:42 +02:00
AUTO_THRESHOLD,
2022-01-17 15:58:27 +01:00
WAIT_FOR_EXECUTION,
2023-07-13 16:38:20 +02:00
RETRY_CFG_CMD
2023-03-20 17:05:57 +01:00
};
2023-03-20 17:51:10 +01:00
FwBootState bootState = FwBootState::NONE;
2023-03-20 17:05:57 +01:00
2022-02-23 18:15:34 +01:00
InternalState internalState = InternalState::IDLE;
2023-03-31 18:51:16 +02:00
bool reinitNextSetParam = false;
bool strHelperHandlingSpecialRequest = false;
2022-01-17 15:58:27 +01:00
2022-03-30 09:19:30 +02:00
const power::Switch_t powerSwitch = power::NO_SWITCH;
2022-03-29 07:58:22 +02:00
2023-10-02 16:11:17 +02:00
size_t fullPacketLen = 0;
2023-10-09 15:29:04 +02:00
std::set<DeviceCommandId_t> additionalRequestedTm{};
std::set<DeviceCommandId_t>::iterator currentSecondaryTmIter;
2024-02-19 17:16:08 +01:00
SdCardMountedIF& sdCardIF;
2023-11-16 16:57:36 +01:00
startracker::SdCardConfigPathGetter& cfgPathGetter;
2022-01-17 15:58:27 +01:00
/**
* @brief Handles internal state
*/
void handleInternalState();
2024-02-19 17:16:08 +01:00
void loadTargetFirmwareFromPersistentCfg();
2022-01-17 15:58:27 +01:00
/**
* @brief Checks mode for commands requiring MODE_ON of MODE_NORMAL for execution.
*
* @param actionId Action id of command to execute
*/
ReturnValue_t checkMode(ActionId_t actionId);
/**
* @brief This function initializes the serial link ip protocol struct slipInfo.
*/
void slipInit();
2023-03-21 20:35:28 +01:00
ReturnValue_t scanForActionReply(uint8_t replyId, DeviceCommandId_t* foundId);
ReturnValue_t scanForSetParameterReply(uint8_t replyId, DeviceCommandId_t* foundId);
ReturnValue_t scanForGetParameterReply(uint8_t replyId, DeviceCommandId_t* foundId);
ReturnValue_t scanForTmReply(uint8_t replyId, DeviceCommandId_t* foundId);
2022-01-17 15:58:27 +01:00
/**
* @brief Fills command buffer with data to ping the star tracker
*/
void preparePingRequest();
/**
* @brief Fills command buffer with data to request the time telemetry.
*/
void prepareTimeRequest();
/**
* @brief Handles all received event messages
*/
void handleEvent(EventMessage* eventMessage);
/**
* @brief Extracts information for flash-read-command from TC data and starts execution of
* flash-read-procedure
*
* @param commandData Pointer to received command data
* @param commandDataLen Size of received command data
*
2022-08-24 17:27:47 +02:00
* @return returnvalue::OK if start of execution was successful, otherwise error return value
2022-01-17 15:58:27 +01:00
*/
2022-02-25 14:24:51 +01:00
ReturnValue_t executeFlashReadCommand(const uint8_t* commandData, size_t commandDataLen);
2022-01-17 15:58:27 +01:00
2023-10-09 15:56:48 +02:00
/**
* Add a TM request to the list of telemetry which will be polled in the secondary step of
* the device communication.
* @param cmd
*/
void addSecondaryTmForNormalMode(DeviceCommandId_t cmd);
/**
* Reset the secondary set, which will only contain a TEMPERATURE set request after the reset.
*/
void resetSecondaryTmSet();
2022-01-17 15:58:27 +01:00
/**
* @brief Fills command buffer with data to boot image (works only when star tracker is
* in bootloader mode).
*/
2024-02-19 17:16:08 +01:00
void prepareBootCommand(startracker::FirmwareTarget target);
2022-01-17 15:58:27 +01:00
/**
* @brief Fills command buffer with command to get the checksum of a flash part
*/
ReturnValue_t prepareChecksumCommand(const uint8_t* commandData, size_t commandDataLen);
/**
* @brief Fills the command buffer with the command to take an image.
*/
void prepareTakeImageCommand(const uint8_t* commandData);
/**
* @brief Fills command buffer with data to request the version telemetry packet
*/
void prepareVersionRequest();
/**
* @brief Fills the command buffer with data to request the interface telemetry packet.
*/
void prepareInterfaceRequest();
/**
* @brief Fills the command buffer with data to request the power telemetry packet.
*/
void preparePowerRequest();
/**
* @brief Fills command buffer with data to reboot star tracker.
*/
2022-02-27 15:46:06 +01:00
void prepareSwitchToBootloaderCmd();
2022-01-17 15:58:27 +01:00
/**
* @brief Fills command buffer with data to subscribe to a telemetry packet.
*
* @param tmId The ID of the telemetry packet to subscribe to
*/
void prepareSubscriptionCommand(const uint8_t* tmId);
/**
* @brief Fills command buffer with data to request solution telemtry packet (contains
* attitude information)
*/
void prepareSolutionRequest();
/**
* @brief Fills command buffer with data to request temperature from star tracker
*/
void prepareTemperatureRequest();
/**
* @brief Fills command buffer with data to request histogram
*/
void prepareHistogramRequest();
/**
* @brief Reads parameters from json file specified by string in commandData and
* prepares the command to apply the parameter set to the star tracker
*
* @param commandData Contains string with file name
* @param commandDataLen Length of command
* @param paramSet The object defining the command generation
*
2022-08-24 17:27:47 +02:00
* @return returnvalue::OK if successful, otherwise error return Value
2022-01-17 15:58:27 +01:00
*/
ReturnValue_t prepareParamCommand(const uint8_t* commandData, size_t commandDataLen,
2023-03-31 18:51:16 +02:00
ArcsecJsonParamBase& paramSet, bool reinitSet);
2022-01-17 15:58:27 +01:00
/**
2022-02-09 19:20:19 +01:00
* @brief The following function will fill the command buffer with the command to request
* a parameter set.
*/
ReturnValue_t prepareRequestCameraParams();
ReturnValue_t prepareRequestLimitsParams();
2022-02-09 19:20:19 +01:00
ReturnValue_t prepareRequestLogLevelParams();
ReturnValue_t prepareRequestMountingParams();
ReturnValue_t prepareRequestImageProcessorParams();
ReturnValue_t prepareRequestCentroidingParams();
ReturnValue_t prepareRequestLisaParams();
ReturnValue_t prepareRequestMatchingParams();
2023-10-19 14:54:12 +02:00
ReturnValue_t prepareRequestAutoBlobTm();
ReturnValue_t prepareRequestMatchedCentroidsTm();
2023-10-06 11:23:31 +02:00
ReturnValue_t prepareRequestBlobTm();
ReturnValue_t prepareRequestBlobsTm();
2023-10-09 15:16:48 +02:00
ReturnValue_t prepareRequestCentroidTm();
ReturnValue_t prepareRequestCentroidsTm();
2023-10-27 11:24:51 +02:00
ReturnValue_t prepareRequestContrastTm();
2024-02-27 13:34:55 +01:00
ReturnValue_t prepareRequestBlobStatsTm();
2022-02-09 19:20:19 +01:00
ReturnValue_t prepareRequestTrackingParams();
ReturnValue_t prepareRequestValidationParams();
ReturnValue_t prepareRequestAlgoParams();
ReturnValue_t prepareRequestSubscriptionParams();
ReturnValue_t prepareRequestLogSubscriptionParams();
ReturnValue_t prepareRequestDebugCameraParams();
2022-01-17 15:58:27 +01:00
/**
* @brief Handles action replies with datasets.
*/
2023-03-21 20:35:28 +01:00
ReturnValue_t handleActionReplySet(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
size_t size);
2022-01-17 15:58:27 +01:00
/**
* @brief Default function to handle action replies
*/
2023-03-21 20:35:28 +01:00
ReturnValue_t handleActionReply(const uint8_t* rawFrame);
2022-01-17 15:58:27 +01:00
/**
* @brief Handles reply to upload centroid command
*/
ReturnValue_t handleUploadCentroidReply();
/**
* @brief Handles reply to checksum command
*/
2023-03-21 20:35:28 +01:00
ReturnValue_t handleChecksumReply(const uint8_t* rawFrame);
2022-01-17 15:58:27 +01:00
/**
* @brief Handles all set parameter replies
*/
2023-03-21 20:35:28 +01:00
ReturnValue_t handleSetParamReply(const uint8_t* rawFrame);
2022-01-17 15:58:27 +01:00
2023-03-21 20:35:28 +01:00
ReturnValue_t handlePingReply(const uint8_t* rawFrame);
2022-01-17 15:58:27 +01:00
2023-03-21 20:35:28 +01:00
ReturnValue_t handleParamRequest(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
size_t size);
2022-01-17 15:58:27 +01:00
/**
* @brief Checks the loaded program by means of the version set
*/
ReturnValue_t checkProgram();
/**
* @brief Handles the startup state machine
*/
2023-04-16 11:25:10 +02:00
void handleStartup(uint8_t tmType, uint8_t parameterId);
2022-01-17 15:58:27 +01:00
2023-10-02 16:11:17 +02:00
ReturnValue_t statusFieldCheck(const uint8_t* rawFrame);
2022-01-17 15:58:27 +01:00
/**
* @brief Handles telemtry replies and fills the appropriate dataset
*
* @param dataset Dataset where reply data will be written to
* @param size Size of the dataset
*
2022-08-24 17:27:47 +02:00
* @return returnvalue::OK if successful, otherwise error return value
2022-01-17 15:58:27 +01:00
*/
2023-10-27 12:17:54 +02:00
ReturnValue_t handleTm(const uint8_t* rawFrame, LocalPoolDataSetBase& dataset,
2023-04-16 04:04:57 +02:00
const char* context);
2022-02-14 11:28:15 +01:00
2023-12-19 11:07:45 +01:00
ReturnValue_t handleSolution(const uint8_t* rawFrame);
2023-10-19 09:26:28 +02:00
ReturnValue_t handleAutoBlobTm(const uint8_t* rawFrame);
2023-10-02 16:11:17 +02:00
ReturnValue_t handleMatchedCentroidTm(const uint8_t* rawFrame);
2023-10-06 11:23:31 +02:00
ReturnValue_t handleBlobTm(const uint8_t* rawFrame);
ReturnValue_t handleBlobsTm(const uint8_t* rawFrame);
2023-10-09 15:16:48 +02:00
ReturnValue_t handleCentroidTm(const uint8_t* rawFrame);
ReturnValue_t handleCentroidsTm(const uint8_t* rawFrame);
2023-10-02 16:11:17 +02:00
2022-02-14 11:28:15 +01:00
/**
* @brief Checks if star tracker is in valid mode for executing the received command.
*
* @param actioId Id of received command
*
2022-08-24 17:27:47 +02:00
* @return returnvalue::OK if star tracker is in valid mode, otherwise error return value
2022-02-14 11:28:15 +01:00
*/
ReturnValue_t checkCommand(ActionId_t actionId);
2022-02-23 18:15:34 +01:00
void doOnTransition(Submode_t subModeFrom);
void doNormalTransition(Mode_t modeFrom, Submode_t subModeFrom);
void bootFirmware(Mode_t toMode);
void bootBootloader();
bool reloadJsonCfgFile();
2023-11-21 14:54:21 +01:00
ReturnValue_t acceptExternalDeviceCommands() override;
2024-02-19 17:16:08 +01:00
ReturnValue_t handleFirmwareUpdateCommand(const uint8_t* data, size_t size,
startracker::FirmwareTarget target);
2021-07-07 12:12:01 +02:00
};
#endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */