diff --git a/linux/devices/startracker/StarTrackerHandler.cpp b/linux/devices/startracker/StarTrackerHandler.cpp index 7cf857d7..caf9ebdc 100644 --- a/linux/devices/startracker/StarTrackerHandler.cpp +++ b/linux/devices/startracker/StarTrackerHandler.cpp @@ -713,6 +713,30 @@ void StarTrackerHandler::fillCommandAndReplyMap() { startracker::MAX_FRAME_SIZE * 2 + 2); } +ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { + if (this->mode == MODE_NORMAL && mode == MODE_ON) { + return TRANS_NOT_ALLOWED; + } + switch (mode) { + case MODE_OFF: + case MODE_NORMAL: + case MODE_RAW: + if (submode == SUBMODE_NONE) { + return RETURN_OK; + } else { + return INVALID_SUBMODE; + } + case MODE_ON: + if (submode == SUBMODE_BOOTLOADER || submode == SUBMODE_FIRMWARE || submode == SUBMODE_NONE) { + return RETURN_OK; + } else { + return INVALID_SUBMODE; + } + default: + return HasModesIF::INVALID_MODE; + } +} + ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = RETURN_OK; diff --git a/linux/devices/startracker/StarTrackerHandler.h b/linux/devices/startracker/StarTrackerHandler.h index 3a078b51..691237a4 100644 --- a/linux/devices/startracker/StarTrackerHandler.h +++ b/linux/devices/startracker/StarTrackerHandler.h @@ -48,8 +48,8 @@ class StarTrackerHandler : public DeviceHandlerBase { void performOperationHook() override; - static const Submode_t SUBMODE_BOOTLOADER = 0; - static const Submode_t SUBMODE_FIRMWARE = 1; + static const Submode_t SUBMODE_BOOTLOADER = 1; + static const Submode_t SUBMODE_FIRMWARE = 2; protected: void doStartUp() override; @@ -60,6 +60,7 @@ class StarTrackerHandler : public DeviceHandlerBase { 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; 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;