2020-09-30 22:14:44 +02:00
|
|
|
#ifndef MISSION_DEVICES_MGMRM3100HANDLER_H_
|
|
|
|
#define MISSION_DEVICES_MGMRM3100HANDLER_H_
|
|
|
|
|
2021-06-24 11:16:08 +02:00
|
|
|
#include "OBSWConfig.h"
|
2021-09-13 18:07:07 +02:00
|
|
|
#include "devices/powerSwitcherList.h"
|
2020-10-01 02:06:39 +02:00
|
|
|
#include "devicedefinitions/MGMHandlerRM3100Definitions.h"
|
2021-06-24 11:16:08 +02:00
|
|
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
2020-12-21 23:09:35 +01:00
|
|
|
|
2021-02-14 13:07:05 +01:00
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
2021-06-24 11:16:08 +02:00
|
|
|
#include "fsfw/globalfunctions/PeriodicOperationDivider.h"
|
2020-12-22 00:24:19 +01:00
|
|
|
#endif
|
|
|
|
|
2020-12-22 13:32:40 +01:00
|
|
|
/**
|
|
|
|
* @brief Device Handler for the RM3100 geomagnetic magnetometer sensor
|
|
|
|
* (https://www.pnicorp.com/rm3100/)
|
|
|
|
* @details
|
2021-06-15 13:58:19 +02:00
|
|
|
* Flight manual:
|
2020-12-22 13:32:40 +01:00
|
|
|
* https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/RM3100_MGM
|
|
|
|
*/
|
2020-09-30 22:14:44 +02:00
|
|
|
class MGMHandlerRM3100: public DeviceHandlerBase {
|
|
|
|
public:
|
2020-12-21 23:09:35 +01:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::MGM_RM3100;
|
2020-12-22 00:24:19 +01:00
|
|
|
|
2021-06-24 11:16:08 +02:00
|
|
|
//! [EXPORT] : [COMMENT] P1: TMRC value which was set, P2: 0
|
2020-12-22 00:24:19 +01:00
|
|
|
static constexpr Event tmrcSet = event::makeEvent(SUBSYSTEM_ID::MGM_RM3100,
|
|
|
|
0x00, severity::INFO);
|
|
|
|
|
2021-06-24 11:16:08 +02:00
|
|
|
//! [EXPORT] : [COMMENT] Cycle counter set. P1: First two bytes new Cycle Count X
|
2020-12-22 00:24:19 +01:00
|
|
|
//! P1: Second two bytes new Cycle Count Y
|
|
|
|
//! P2: New cycle count Z
|
|
|
|
static constexpr Event cycleCountersSet = event::makeEvent(
|
|
|
|
SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO);
|
2020-09-30 22:14:44 +02:00
|
|
|
|
|
|
|
MGMHandlerRM3100(object_id_t objectId, object_id_t deviceCommunication,
|
2021-09-13 18:07:07 +02:00
|
|
|
CookieIF* comCookie, uint8_t switchId);
|
2020-09-30 22:14:44 +02:00
|
|
|
virtual ~MGMHandlerRM3100();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/* DeviceHandlerBase overrides */
|
2020-12-22 00:24:19 +01:00
|
|
|
ReturnValue_t buildTransitionDeviceCommand(
|
2020-09-30 22:14:44 +02:00
|
|
|
DeviceCommandId_t *id) override;
|
2020-12-22 00:24:19 +01:00
|
|
|
void doStartUp() override;
|
|
|
|
void doShutDown() override;
|
|
|
|
ReturnValue_t buildNormalDeviceCommand(
|
2020-09-30 22:14:44 +02:00
|
|
|
DeviceCommandId_t *id) override;
|
2020-12-22 00:24:19 +01:00
|
|
|
ReturnValue_t buildCommandFromCommand(
|
2020-09-30 22:14:44 +02:00
|
|
|
DeviceCommandId_t deviceCommand, const uint8_t *commandData,
|
|
|
|
size_t commandDataLen) override;
|
2020-12-22 00:24:19 +01:00
|
|
|
ReturnValue_t scanForReply(const uint8_t *start, size_t len,
|
2020-09-30 22:14:44 +02:00
|
|
|
DeviceCommandId_t *foundId, size_t *foundLen) override;
|
2020-12-22 00:24:19 +01:00
|
|
|
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
|
2020-09-30 22:14:44 +02:00
|
|
|
const uint8_t *packet) override;
|
2021-09-13 18:07:07 +02:00
|
|
|
ReturnValue_t getSwitches(const uint8_t **switches,
|
|
|
|
uint8_t *numberOfSwitches) override;
|
2020-09-30 22:14:44 +02:00
|
|
|
|
2020-12-22 00:24:19 +01:00
|
|
|
void fillCommandAndReplyMap() override;
|
|
|
|
void modeChanged(void) override;
|
|
|
|
uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override;
|
2021-01-14 11:37:32 +01:00
|
|
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
|
2020-12-22 00:24:19 +01:00
|
|
|
LocalDataPoolManager &poolManager) override;
|
|
|
|
|
2020-09-30 22:14:44 +02:00
|
|
|
private:
|
|
|
|
|
2020-12-23 20:17:39 +01:00
|
|
|
enum class InternalState {
|
2021-03-07 14:06:29 +01:00
|
|
|
NONE,
|
|
|
|
CONFIGURE_CMM,
|
|
|
|
READ_CMM,
|
2020-12-21 19:50:01 +01:00
|
|
|
// The cycle count states are propably not going to be used because
|
|
|
|
// the default cycle count will be used.
|
|
|
|
STATE_CONFIGURE_CYCLE_COUNT,
|
|
|
|
STATE_READ_CYCLE_COUNT,
|
|
|
|
STATE_CONFIGURE_TMRC,
|
|
|
|
STATE_READ_TMRC,
|
2021-03-07 14:06:29 +01:00
|
|
|
NORMAL
|
2020-09-30 22:14:44 +02:00
|
|
|
};
|
2021-03-07 14:06:29 +01:00
|
|
|
InternalState internalState = InternalState::NONE;
|
2020-12-21 19:50:01 +01:00
|
|
|
bool commandExecuted = false;
|
2020-12-22 00:24:19 +01:00
|
|
|
RM3100::Rm3100PrimaryDataset primaryDataset;
|
2020-12-21 19:52:00 +01:00
|
|
|
|
2020-12-21 23:09:35 +01:00
|
|
|
uint8_t commandBuffer[10];
|
2020-12-21 19:52:00 +01:00
|
|
|
uint8_t commandBufferLen = 0;
|
|
|
|
|
|
|
|
uint8_t cmmRegValue = RM3100::CMM_VALUE;
|
|
|
|
uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE;
|
2020-12-21 23:09:35 +01:00
|
|
|
uint16_t cycleCountRegValueX = RM3100::CYCLE_COUNT_VALUE;
|
|
|
|
uint16_t cycleCountRegValueY = RM3100::CYCLE_COUNT_VALUE;
|
|
|
|
uint16_t cycleCountRegValueZ = RM3100::CYCLE_COUNT_VALUE;
|
|
|
|
float scaleFactorX = 1 / RM3100::DEFAULT_GAIN;
|
|
|
|
float scaleFactorY = 1 / RM3100::DEFAULT_GAIN;
|
|
|
|
float scaleFactorZ = 1 / RM3100::DEFAULT_GAIN;
|
|
|
|
|
2021-09-13 18:07:07 +02:00
|
|
|
uint8_t switchId;
|
|
|
|
|
2020-12-21 23:09:35 +01:00
|
|
|
ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand,
|
|
|
|
const uint8_t *commandData,size_t commandDataLen);
|
|
|
|
ReturnValue_t handleCycleCommand(bool oneCycleValue,
|
|
|
|
const uint8_t *commandData, size_t commandDataLen);
|
|
|
|
|
|
|
|
ReturnValue_t handleTmrcConfigCommand(DeviceCommandId_t deviceCommand,
|
|
|
|
const uint8_t *commandData,size_t commandDataLen);
|
2020-12-22 00:24:19 +01:00
|
|
|
|
|
|
|
ReturnValue_t handleDataReadout(const uint8_t* packet);
|
2021-02-14 13:07:05 +01:00
|
|
|
#if OBSW_VERBOSE_LEVEL >= 1
|
2020-12-22 00:24:19 +01:00
|
|
|
PeriodicOperationDivider* debugDivider;
|
|
|
|
#endif
|
2020-09-30 22:14:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */
|