meier/startracker #155

Merged
muellerr merged 51 commits from meier/startracker into develop 2022-02-28 13:25:39 +01:00
11 changed files with 294 additions and 232 deletions
Showing only changes of commit b822ee77bc - Show all commits

View File

@ -6,9 +6,9 @@
<envs> <envs>
<env name="PYTHONUNBUFFERED" value="1" /> <env name="PYTHONUNBUFFERED" value="1" />
</envs> </envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="C:\Users\jakob\AppData\Local\Programs\Python\Python39\python.exe" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" /> <EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />

View File

@ -100,6 +100,7 @@
11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h 11207;SELF_TEST_COIL_CURRENT_FAILURE;LOW;;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h
11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h 11208;INVALID_ERROR_BYTE;LOW;Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC.;C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h
11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\eive-software\eive_obsw/mission/devices/RwHandler.h 11301;ERROR_STATE;HIGH;Reaction wheel signals an error state;C:\Users\jakob\eive-software\eive_obsw/mission/devices/RwHandler.h
11401;BOOTING_FIRMWARE_FAILED;LOW;Failed to boot firmware;C:\Users\jakob\eive-software\eive_obsw/linux/devices/startracker/StarTrackerHandler.h
11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h 11501;SUPV_MEMORY_READ_RPT_CRC_FAILURE;LOW;PLOC supervisor crc failure in telemetry packet;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h
11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h 11502;SUPV_ACK_FAILURE;LOW;PLOC supervisor received acknowledgment failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h
11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h 11503;SUPV_EXE_FAILURE;LOW;PLOC received execution failure report;C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h

1 2200 STORE_SEND_WRITE_FAILED LOW /home/rmueller/EIVE/eive-obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h C:\Users\jakob\eive-software\eive_obsw/fsfw/src/fsfw/tmstorage/TmStoreBackendIF.h
100 11207 SELF_TEST_COIL_CURRENT_FAILURE LOW Get self test result returns failure indicating that the coil current was outside of the expected range P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA /home/rmueller/EIVE/eive-obsw/mission/devices/IMTQHandler.h C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h
101 11208 INVALID_ERROR_BYTE LOW Received invalid error byte. This indicates an error of the communication link between IMTQ and OBC. /home/rmueller/EIVE/eive-obsw/mission/devices/IMTQHandler.h C:\Users\jakob\eive-software\eive_obsw/mission/devices/IMTQHandler.h
102 11301 ERROR_STATE HIGH Reaction wheel signals an error state /home/rmueller/EIVE/eive-obsw/mission/devices/RwHandler.h C:\Users\jakob\eive-software\eive_obsw/mission/devices/RwHandler.h
103 11401 BOOTING_FIRMWARE_FAILED LOW Failed to boot firmware C:\Users\jakob\eive-software\eive_obsw/linux/devices/startracker/StarTrackerHandler.h
104 11501 SUPV_MEMORY_READ_RPT_CRC_FAILURE LOW PLOC supervisor crc failure in telemetry packet /home/rmueller/EIVE/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h
105 11502 SUPV_ACK_FAILURE LOW PLOC supervisor received acknowledgment failure report /home/rmueller/EIVE/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h
106 11503 SUPV_EXE_FAILURE LOW PLOC received execution failure report /home/rmueller/EIVE/eive-obsw/bsp_q7s/devices/PlocSupervisorHandler.h C:\Users\jakob\eive-software\eive_obsw/bsp_q7s/devices/PlocSupervisorHandler.h

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 137 translations. * @brief Auto-generated event translation file. Contains 138 translations.
* @details * @details
* Generated on: 2022-02-13 15:31:27 * Generated on: 2022-02-22 09:46:40
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -107,6 +107,7 @@ const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE";
const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE";
const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE";
const char *ERROR_STATE_STRING = "ERROR_STATE"; const char *ERROR_STATE_STRING = "ERROR_STATE";
const char *BOOTING_FIRMWARE_FAILED_STRING = "BOOTING_FIRMWARE_FAILED";
const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE";
const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE";
const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE";
@ -349,6 +350,8 @@ const char * translateEvents(Event event) {
return INVALID_ERROR_BYTE_STRING; return INVALID_ERROR_BYTE_STRING;
case(11301): case(11301):
return ERROR_STATE_STRING; return ERROR_STATE_STRING;
case(11401):
return BOOTING_FIRMWARE_FAILED_STRING;
case(11501): case(11501):
return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING;
case(11502): case(11502):

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 111 translations. * Contains 111 translations.
* Generated on: 2022-02-13 15:31:32 * Generated on: 2022-02-23 11:11:47
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -233,20 +233,14 @@ void StarTrackerHandler::performOperationHook() {
void StarTrackerHandler::doStartUp() { void StarTrackerHandler::doStartUp() {
switch (startupState) { switch (startupState) {
case StartupState::IDLE: case StartupState::IDLE:
startupState = StartupState::CHECK_BOOT_STATE; startupState = StartupState::CHECK_PROGRAM;
return; return;
case StartupState::BOOT_DELAY: case StartupState::BOOT_BOOTLOADER:
if (bootCountdown.hasTimedOut()) { // This step is required in case the star tracker is already in firmware mode to harmonize
startupState = StartupState::VERIFY_BOOT; // the device handler's submode to the star tracker's mode
} return;
return;
case StartupState::FAILED_FIRMWARE_BOOT:
startupState = StartupState::IDLE;
// Though the star tracker failed to boot the firmware the device handler will go to
// mode on. In bootloader mode the star tracker is still on and can e.g. perform firmware
// updates.
break;
case StartupState::DONE: case StartupState::DONE:
submode = SUBMODE_BOOTLOADER;
startupState = StartupState::IDLE; startupState = StartupState::IDLE;
break; break;
default: default:
@ -258,26 +252,18 @@ void StarTrackerHandler::doStartUp() {
void StarTrackerHandler::doShutDown() { void StarTrackerHandler::doShutDown() {
// If the star tracker is shutdown also stop all running processes in the image loader task // If the star tracker is shutdown also stop all running processes in the image loader task
strHelper->stopProcess(); strHelper->stopProcess();
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
setMode(_MODE_POWER_DOWN); setMode(_MODE_POWER_DOWN);
} }
void StarTrackerHandler::doOffActivity() { startupState = StartupState::IDLE; } void StarTrackerHandler::doOffActivity() { internalState = InternalState::IDLE; }
ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (!bootCountdown.hasTimedOut()) { switch (normalState) {
return NOTHING_TO_SEND; case NormalState::TEMPERATURE_REQUEST:
}
switch (internalState) {
case InternalState::CHECK_PROGRAM:
*id = startracker::REQ_VERSION;
break;
case InternalState::TEMPERATURE_REQUEST:
*id = startracker::REQ_TEMPERATURE; *id = startracker::REQ_TEMPERATURE;
break; break;
default: default:
sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid internal step" sif::debug << "StarTrackerHandler::buildNormalDeviceCommand: Invalid normal step"
<< std::endl; << std::endl;
break; break;
} }
@ -285,94 +271,103 @@ ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id
} }
ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t StarTrackerHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
if (mode == _MODE_TO_NORMAL && currentProgram != startracker::Program::FIRMWARE) { switch (internalState) {
internalState = InternalState::CHECK_PROGRAM; case InternalState::BOOT:
*id = startracker::BOOT;
bootCountdown.setTimeout(BOOT_TIMEOUT);
return buildCommandFromCommand(*id, nullptr, 0);
} else if (mode != _MODE_START_UP) {
return NOTHING_TO_SEND;
}
switch (startupState) {
case StartupState::CHECK_BOOT_STATE:
*id = startracker::REQ_VERSION;
startupState = StartupState::STARTUP_CHECK;
return buildCommandFromCommand(*id, nullptr, 0);
case StartupState::BOOT:
*id = startracker::BOOT; *id = startracker::BOOT;
bootCountdown.setTimeout(BOOT_TIMEOUT); bootCountdown.setTimeout(BOOT_TIMEOUT);
startupState = StartupState::BOOT_DELAY; internalState = InternalState::BOOT_DELAY;
return buildCommandFromCommand(*id, nullptr, 0); return buildCommandFromCommand(*id, nullptr, 0);
case StartupState::VERIFY_BOOT: case InternalState::REQ_VERSION:
internalState = InternalState::VERIFY_BOOT;
// Again read program to check if firmware boot was successful // Again read program to check if firmware boot was successful
*id = startracker::REQ_VERSION; *id = startracker::REQ_VERSION;
startupState = StartupState::FIRMWARE_CHECK;
return buildCommandFromCommand(*id, nullptr, 0); return buildCommandFromCommand(*id, nullptr, 0);
case StartupState::LOGLEVEL: case InternalState::LOGLEVEL:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::LOGLEVEL; *id = startracker::LOGLEVEL;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::LIMITS: case InternalState::LIMITS:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::LIMITS; *id = startracker::LIMITS;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::TRACKING: case InternalState::TRACKING:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::TRACKING; *id = startracker::TRACKING;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::MOUNTING: case InternalState::MOUNTING:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::MOUNTING; *id = startracker::MOUNTING;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::IMAGE_PROCESSOR: case InternalState::IMAGE_PROCESSOR:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::IMAGE_PROCESSOR; *id = startracker::IMAGE_PROCESSOR;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::CAMERA: case InternalState::CAMERA:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::CAMERA; *id = startracker::CAMERA;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::CENTROIDING: case InternalState::CENTROIDING:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::CENTROIDING; *id = startracker::CENTROIDING;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::LISA: case InternalState::LISA:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::LISA; *id = startracker::LISA;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::MATCHING: case InternalState::MATCHING:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::MATCHING; *id = startracker::MATCHING;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::VALIDATION: case InternalState::VALIDATION:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::VALIDATION; *id = startracker::VALIDATION;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::ALGO: case InternalState::ALGO:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::ALGO; *id = startracker::ALGO;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::LOG_SUBSCRIPTION: case InternalState::LOG_SUBSCRIPTION:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::LOGSUBSCRIPTION; *id = startracker::LOGSUBSCRIPTION;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case StartupState::DEBUG_CAMERA: case InternalState::DEBUG_CAMERA:
startupState = StartupState::WAIT_FOR_EXECUTION; internalState = InternalState::WAIT_FOR_EXECUTION;
*id = startracker::DEBUG_CAMERA; *id = startracker::DEBUG_CAMERA;
return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()), return buildCommandFromCommand(*id, reinterpret_cast<const uint8_t*>(paramJsonFile.c_str()),
paramJsonFile.size()); paramJsonFile.size());
case InternalState::BOOT_BOOTLOADER:
internalState = InternalState::BOOTLOADER_CHECK;
*id = startracker::SWITCH_TO_BOOTLOADER_PROGRAM;
return buildCommandFromCommand(*id, nullptr, 0);
case InternalState::BOOTLOADER_CHECK:
*id = startracker::REQ_VERSION;
return buildCommandFromCommand(*id, nullptr, 0);
default:
break;
}
switch (startupState) {
case StartupState::CHECK_PROGRAM:
startupState = StartupState::WAIT_CHECK_PROGRAM;
*id = startracker::REQ_VERSION;
return buildCommandFromCommand(*id, nullptr, 0);
break;
case StartupState::BOOT_BOOTLOADER:
startupState = StartupState::CHECK_PROGRAM;
*id = startracker::SWITCH_TO_BOOTLOADER_PROGRAM;
return buildCommandFromCommand(*id, nullptr, 0);
break;
default: default:
break; break;
} }
@ -409,7 +404,6 @@ ReturnValue_t StarTrackerHandler::buildCommandFromCommand(DeviceCommandId_t devi
return RETURN_OK; return RETURN_OK;
} }
case (startracker::SWITCH_TO_BOOTLOADER_PROGRAM): { case (startracker::SWITCH_TO_BOOTLOADER_PROGRAM): {
currentProgram = startracker::Program::BOOTLOADER;
prepareRebootCommand(); prepareRebootCommand();
return RETURN_OK; return RETURN_OK;
} }
@ -727,7 +721,7 @@ ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t
return INVALID_SUBMODE; return INVALID_SUBMODE;
} }
case MODE_ON: case MODE_ON:
if (submode == SUBMODE_BOOTLOADER || submode == SUBMODE_FIRMWARE || submode == SUBMODE_NONE) { if (submode == SUBMODE_BOOTLOADER || submode == SUBMODE_FIRMWARE) {
return RETURN_OK; return RETURN_OK;
} else { } else {
return INVALID_SUBMODE; return INVALID_SUBMODE;
@ -737,6 +731,86 @@ ReturnValue_t StarTrackerHandler::isModeCombinationValid(Mode_t mode, Submode_t
} }
} }
void StarTrackerHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
switch (mode) {
case _MODE_TO_ON:
doOnTransition(subModeFrom);
break;
case _MODE_TO_RAW:
setMode(MODE_RAW);
break;
case _MODE_TO_NORMAL:
doNormalTransition(modeFrom, subModeFrom);
break;
case _MODE_POWER_DOWN:
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
break;
default:
break;
}
}
void StarTrackerHandler::doOnTransition(Submode_t subModeFrom) {
if (submode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_FIRMWARE) {
bootBootloader();
} else if (submode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_FIRMWARE) {
setMode(MODE_ON);
} else if (submode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_BOOTLOADER) {
bootFirmware(MODE_ON);
} else if (submode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_BOOTLOADER) {
setMode(MODE_ON);
} else if (submode == SUBMODE_BOOTLOADER && subModeFrom == SUBMODE_NONE) {
setMode(MODE_ON);
} else if (submode == SUBMODE_FIRMWARE && subModeFrom == SUBMODE_NONE) {
setMode(MODE_ON);
}
}
void StarTrackerHandler::doNormalTransition(Mode_t modeFrom, Submode_t subModeFrom) {
if (subModeFrom == SUBMODE_FIRMWARE) {
setMode(MODE_NORMAL);
} else if (subModeFrom == SUBMODE_BOOTLOADER) {
bootFirmware(MODE_NORMAL);
} else if (modeFrom == MODE_NORMAL && subModeFrom == SUBMODE_NONE){
// Device handler already in mode normal
setMode(MODE_NORMAL);
}
}
void StarTrackerHandler::bootFirmware(Mode_t toMode) {
switch (internalState) {
case InternalState::IDLE:
internalState = InternalState::BOOT;
break;
case InternalState::BOOT_DELAY:
if (bootCountdown.hasTimedOut()) {
internalState = InternalState::REQ_VERSION;
}
break;
case InternalState::FAILED_FIRMWARE_BOOT:
internalState = InternalState::IDLE;
break;
case InternalState::DONE:
setMode(toMode);
internalState = InternalState::IDLE;
break;
default:
return;
}
}
void StarTrackerHandler::bootBootloader() {
if (internalState == InternalState::IDLE) {
internalState = InternalState::BOOT_BOOTLOADER;
} else if (internalState == InternalState::BOOTING_BOOTLOADER_FAILED) {
internalState = InternalState::IDLE;
} else if (internalState == InternalState::DONE) {
internalState = InternalState::IDLE;
setMode(MODE_ON);
}
}
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize, ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) { DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
@ -955,7 +1029,14 @@ ReturnValue_t StarTrackerHandler::interpretDeviceReply(DeviceCommandId_t id,
void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {} void StarTrackerHandler::setNormalDatapoolEntriesInvalid() {}
uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 20000; } uint32_t StarTrackerHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
// if (modeTo == MODE_ON && (submode == SUBMODE_NONE || submode == SUBMODE_BOOTLOADER)) {
// return BOOTLOADER_TRANSITION_DELAY;
// } else if (modeTo == MODE_ON && submode == SUBMODE_FIRMWARE && modeFrom == MODE_) {
// return FIRMWARE_TRANSITION_DELAY;
// }
return DEFAULT_TRANSITION_DELAY;
}
ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, ReturnValue_t StarTrackerHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) { LocalDataPoolManager& poolManager) {
@ -2161,12 +2242,12 @@ ReturnValue_t StarTrackerHandler::handleSetParamReply() {
sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set " sif::warning << "StarTrackerHandler::handleSetParamReply: Failed to execute parameter set "
" command with parameter ID" " command with parameter ID"
<< static_cast<unsigned int>(*(reply + PARAMETER_ID_OFFSET)) << std::endl; << static_cast<unsigned int>(*(reply + PARAMETER_ID_OFFSET)) << std::endl;
if (startupState != StartupState::IDLE) { if (internalState != InternalState::IDLE) {
startupState = StartupState::IDLE; internalState = InternalState::IDLE;
} }
return SET_PARAM_FAILED; return SET_PARAM_FAILED;
} }
if (startupState != StartupState::IDLE) { if (internalState != InternalState::IDLE) {
handleStartup(reply + PARAMETER_ID_OFFSET); handleStartup(reply + PARAMETER_ID_OFFSET);
} }
return RETURN_OK; return RETURN_OK;
@ -2293,30 +2374,27 @@ ReturnValue_t StarTrackerHandler::checkProgram() {
PoolReadGuard pg(&versionSet); PoolReadGuard pg(&versionSet);
switch (versionSet.program.value) { switch (versionSet.program.value) {
case startracker::Program::BOOTLOADER: case startracker::Program::BOOTLOADER:
// Star tracker currently in bootloader program. Need to send boot command to switch to if (startupState == StartupState::WAIT_CHECK_PROGRAM) {
// firmware program startupState = StartupState::DONE;
currentProgram = startracker::Program::BOOTLOADER;
if (startupState == StartupState::STARTUP_CHECK) {
startupState = StartupState::BOOT;
} else if (startupState == StartupState::FIRMWARE_CHECK) {
startupState = StartupState::FAILED_FIRMWARE_BOOT;
} }
if (internalState == InternalState::CHECK_PROGRAM) { if (internalState == InternalState::VERIFY_BOOT) {
// Firmware boot failed when trying to switch to normal mode sif::warning << "StarTrackerHandler::checkProgram: Failed to boot firmware" << std::endl;
internalState = InternalState::IDLE; // Device handler will run into timeout and fall back to transition source mode
sif::warning << "StarTrackerHandler::checkProgram: Failed to boot firmware when " triggerEvent(BOOTING_FIRMWARE_FAILED);
<< "trying to switch to normal mode" << std::endl; internalState = InternalState::FAILED_FIRMWARE_BOOT;
setMode(_MODE_TO_ON); } else if (internalState == InternalState::BOOTLOADER_CHECK) {
internalState = InternalState::DONE;
} }
break; break;
case startracker::Program::FIRMWARE: case startracker::Program::FIRMWARE:
// Firmware already booted if (startupState == StartupState::WAIT_CHECK_PROGRAM) {
currentProgram = startracker::Program::FIRMWARE; startupState = StartupState::BOOT_BOOTLOADER;
if (startupState == StartupState::FIRMWARE_CHECK) {
startupState = StartupState::LOGLEVEL;
} }
if (internalState == InternalState::CHECK_PROGRAM) { if (internalState == InternalState::VERIFY_BOOT) {
internalState = InternalState::TEMPERATURE_REQUEST; internalState = InternalState::LOGLEVEL;
} else if (internalState == InternalState::BOOTLOADER_CHECK) {
triggerEvent(BOOTING_BOOTLOADER_FAILED);
internalState = InternalState::BOOTING_BOOTLOADER_FAILED;
} }
break; break;
default: default:
@ -2390,55 +2468,55 @@ ReturnValue_t StarTrackerHandler::handleActionReplySet(LocalPoolDataSetBase& dat
void StarTrackerHandler::handleStartup(const uint8_t* parameterId) { void StarTrackerHandler::handleStartup(const uint8_t* parameterId) {
switch (*parameterId) { switch (*parameterId) {
case (startracker::ID::LOG_LEVEL): { case (startracker::ID::LOG_LEVEL): {
startupState = StartupState::LIMITS; internalState = InternalState::LIMITS;
break; break;
} }
case (startracker::ID::LIMITS): { case (startracker::ID::LIMITS): {
startupState = StartupState::TRACKING; internalState = InternalState::TRACKING;
break; break;
} }
case (startracker::ID::TRACKING): { case (startracker::ID::TRACKING): {
startupState = StartupState::MOUNTING; internalState = InternalState::MOUNTING;
break; break;
} }
case (startracker::ID::MOUNTING): { case (startracker::ID::MOUNTING): {
startupState = StartupState::IMAGE_PROCESSOR; internalState = InternalState::IMAGE_PROCESSOR;
break; break;
} }
case (startracker::ID::IMAGE_PROCESSOR): { case (startracker::ID::IMAGE_PROCESSOR): {
startupState = StartupState::CAMERA; internalState = InternalState::CAMERA;
break; break;
} }
case (startracker::ID::CAMERA): { case (startracker::ID::CAMERA): {
startupState = StartupState::CENTROIDING; internalState = InternalState::CENTROIDING;
break; break;
} }
case (startracker::ID::CENTROIDING): { case (startracker::ID::CENTROIDING): {
startupState = StartupState::LISA; internalState = InternalState::LISA;
break; break;
} }
case (startracker::ID::LISA): { case (startracker::ID::LISA): {
startupState = StartupState::MATCHING; internalState = InternalState::MATCHING;
break; break;
} }
case (startracker::ID::MATCHING): { case (startracker::ID::MATCHING): {
startupState = StartupState::VALIDATION; internalState = InternalState::VALIDATION;
break; break;
} }
case (startracker::ID::VALIDATION): { case (startracker::ID::VALIDATION): {
startupState = StartupState::ALGO; internalState = InternalState::ALGO;
break; break;
} }
case (startracker::ID::ALGO): { case (startracker::ID::ALGO): {
startupState = StartupState::LOG_SUBSCRIPTION; internalState = InternalState::LOG_SUBSCRIPTION;
break; break;
} }
case (startracker::ID::LOG_SUBSCRIPTION): { case (startracker::ID::LOG_SUBSCRIPTION): {
startupState = StartupState::DEBUG_CAMERA; internalState = InternalState::DEBUG_CAMERA;
break; break;
} }
case (startracker::ID::DEBUG_CAMERA): { case (startracker::ID::DEBUG_CAMERA): {
startupState = StartupState::DONE; internalState = InternalState::DONE;
break; break;
} }
default: { default: {
@ -2451,11 +2529,6 @@ void StarTrackerHandler::handleStartup(const uint8_t* parameterId) {
ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) { ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) {
switch (actionId) { switch (actionId) {
case startracker::BOOT:
if (currentProgram != startracker::Program::BOOTLOADER) {
return STARTRACKER_ALREADY_BOOTED;
}
break;
case startracker::REQ_INTERFACE: case startracker::REQ_INTERFACE:
case startracker::REQ_TIME: case startracker::REQ_TIME:
case startracker::SWITCH_TO_BOOTLOADER_PROGRAM: case startracker::SWITCH_TO_BOOTLOADER_PROGRAM:
@ -2472,12 +2545,12 @@ ReturnValue_t StarTrackerHandler::checkCommand(ActionId_t actionId) {
case startracker::DOWNLOAD_MATCHED_STAR: case startracker::DOWNLOAD_MATCHED_STAR:
case startracker::DOWNLOAD_DBIMAGE: case startracker::DOWNLOAD_DBIMAGE:
case startracker::DOWNLOAD_BLOBPIXEL: case startracker::DOWNLOAD_BLOBPIXEL:
if (currentProgram != startracker::Program::FIRMWARE) { if (!(mode == MODE_ON && submode == startracker::Program::FIRMWARE)) {
return STARTRACKER_RUNNING_BOOTLOADER; return STARTRACKER_RUNNING_BOOTLOADER;
} }
break; break;
case startracker::FIRMWARE_UPDATE: case startracker::FIRMWARE_UPDATE:
if (currentProgram != startracker::Program::BOOTLOADER) { if (!(mode == MODE_ON && submode == startracker::Program::BOOTLOADER)) {
return STARTRACKER_RUNNING_FIRMWARE; return STARTRACKER_RUNNING_FIRMWARE;
} }
break; break;

View File

@ -73,6 +73,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
*/ */
virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; virtual size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override;
virtual ReturnValue_t doSendReadHook() override; virtual ReturnValue_t doSendReadHook() override;
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override;
private: private:
static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER; static const uint8_t INTERFACE_ID = CLASS_ID::STR_HANDLER;
@ -142,6 +143,13 @@ class StarTrackerHandler : public DeviceHandlerBase {
//! [EXPORT] : [COMMENT] Star tracker is in bootloader mode but must be in firmware mode to execute this command //! [EXPORT] : [COMMENT] Star tracker is in bootloader mode but must be in firmware mode to execute this command
static const ReturnValue_t STARTRACKER_RUNNING_BOOTLOADER = MAKE_RETURN_CODE(0xBD); static const ReturnValue_t STARTRACKER_RUNNING_BOOTLOADER = MAKE_RETURN_CODE(0xBD);
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::STR_HANDLER;
//! [EXPORT] : [COMMENT] Failed to boot firmware
static const Event BOOTING_FIRMWARE_FAILED = MAKE_EVENT(1, severity::LOW);
//! [EXPORT] : [COMMENT] Failed to boot star tracker into bootloader mode
static const Event BOOTING_BOOTLOADER_FAILED = MAKE_EVENT(2, severity::LOW);
static const size_t MAX_PATH_SIZE = 50; static const size_t MAX_PATH_SIZE = 50;
static const size_t MAX_FILE_NAME = 30; static const size_t MAX_FILE_NAME = 30;
@ -163,6 +171,7 @@ class StarTrackerHandler : public DeviceHandlerBase {
static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING; static const MutexIF::TimeoutType TIMEOUT_TYPE = MutexIF::TimeoutType::WAITING;
static const uint32_t MUTEX_TIMEOUT = 20; static const uint32_t MUTEX_TIMEOUT = 20;
static const uint32_t BOOT_TIMEOUT = 1000; static const uint32_t BOOT_TIMEOUT = 1000;
static const uint32_t DEFAULT_TRANSITION_DELAY = 15000;
class WriteCmd { class WriteCmd {
public: public:
@ -303,18 +312,16 @@ class StarTrackerHandler : public DeviceHandlerBase {
#endif #endif
#endif #endif
enum class InternalState { enum class NormalState {
IDLE, TEMPERATURE_REQUEST
CHECK_PROGRAM,
TEMPERATURE_REQUEST,
}; };
InternalState internalState = InternalState::IDLE; NormalState normalState = NormalState::TEMPERATURE_REQUEST;
enum class StartupState { enum class InternalState {
IDLE, IDLE,
CHECK_BOOT_STATE,
BOOT, BOOT,
REQ_VERSION,
VERIFY_BOOT, VERIFY_BOOT,
STARTUP_CHECK, STARTUP_CHECK,
BOOT_DELAY, BOOT_DELAY,
@ -335,15 +342,26 @@ class StarTrackerHandler : public DeviceHandlerBase {
DEBUG_CAMERA, DEBUG_CAMERA,
WAIT_FOR_EXECUTION, WAIT_FOR_EXECUTION,
DONE, DONE,
FAILED_FIRMWARE_BOOT FAILED_FIRMWARE_BOOT,
BOOT_BOOTLOADER,
BOOTLOADER_CHECK,
BOOTING_BOOTLOADER_FAILED
};
InternalState internalState = InternalState::IDLE;
enum class StartupState {
IDLE,
CHECK_PROGRAM,
WAIT_CHECK_PROGRAM,
BOOT_BOOTLOADER,
DONE
}; };
StartupState startupState = StartupState::IDLE; StartupState startupState = StartupState::IDLE;
bool strHelperExecuting = false; bool strHelperExecuting = false;
uint8_t currentProgram = startracker::Program::BOOTLOADER;
/** /**
* @brief Handles internal state * @brief Handles internal state
*/ */
@ -598,6 +616,11 @@ class StarTrackerHandler : public DeviceHandlerBase {
* @return RETURN_OK if star tracker is in valid mode, otherwise error return value * @return RETURN_OK if star tracker is in valid mode, otherwise error return value
*/ */
ReturnValue_t checkCommand(ActionId_t actionId); ReturnValue_t checkCommand(ActionId_t actionId);
void doOnTransition(Submode_t subModeFrom);
void doNormalTransition(Mode_t modeFrom, Submode_t subModeFrom);
void bootFirmware(Mode_t toMode);
void bootBootloader();
}; };
#endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */ #endif /* MISSION_DEVICES_STARTRACKERHANDLER_H_ */

View File

@ -1,10 +1,11 @@
#include "StrHelper.h" #include "StrHelper.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "fsfw/timemanager/Countdown.h"
#include "linux/devices/devicedefinitions/StarTrackerDefinitions.h"
#include "mission/utility/Timestamp.h" #include "mission/utility/Timestamp.h"
StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {} StrHelper::StrHelper(object_id_t objectId) : SystemObject(objectId) {}
@ -184,7 +185,7 @@ ReturnValue_t StrHelper::performImageDownload() {
downloadReq.position = 0; downloadReq.position = 0;
while (downloadReq.position < ImageDownload::LAST_POSITION) { while (downloadReq.position < ImageDownload::LAST_POSITION) {
if (terminate) { if (terminate) {
file.close(); file.close();
return RETURN_OK; return RETURN_OK;
} }
arc_pack_download_action_req(&downloadReq, commandBuffer, &size); arc_pack_download_action_req(&downloadReq, commandBuffer, &size);
@ -249,7 +250,7 @@ ReturnValue_t StrHelper::performImageUpload() {
imageSize = file.tellg(); imageSize = file.tellg();
while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) { while ((uploadReq.position + 1) * SIZE_IMAGE_PART < imageSize) {
if (terminate) { if (terminate) {
file.close(); file.close();
return RETURN_OK; return RETURN_OK;
} }
file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg); file.seekg(uploadReq.position * SIZE_IMAGE_PART, file.beg);
@ -257,12 +258,12 @@ ReturnValue_t StrHelper::performImageUpload() {
arc_pack_upload_action_req(&uploadReq, commandBuffer, &size); arc_pack_upload_action_req(&uploadReq, commandBuffer, &size);
result = sendAndRead(size, uploadReq.position); result = sendAndRead(size, uploadReq.position);
if (result != RETURN_OK) { if (result != RETURN_OK) {
file.close(); file.close();
return RETURN_FAILED; return RETURN_FAILED;
} }
result = checkActionReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
file.close(); file.close();
return result; return result;
} }
#if OBSW_DEBUG_STARTRACKER == 1 #if OBSW_DEBUG_STARTRACKER == 1
@ -292,15 +293,15 @@ ReturnValue_t StrHelper::performImageUpload() {
} }
ReturnValue_t StrHelper::performFirmwareUpdate() { ReturnValue_t StrHelper::performFirmwareUpdate() {
using namespace startracker; using namespace startracker;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = unlockAndEraseRegions(static_cast<uint32_t>(startracker::FirmwareRegions::FIRST), result = unlockAndEraseRegions(static_cast<uint32_t>(startracker::FirmwareRegions::FIRST),
static_cast<uint32_t>(startracker::FirmwareRegions::LAST)); static_cast<uint32_t>(startracker::FirmwareRegions::LAST));
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result;
}
result = performFlashWrite();
return result; return result;
}
result = performFlashWrite();
return result;
} }
ReturnValue_t StrHelper::performFlashWrite() { ReturnValue_t StrHelper::performFlashWrite() {
@ -318,8 +319,8 @@ ReturnValue_t StrHelper::performFlashWrite() {
file.seekg(0, file.end); file.seekg(0, file.end);
fileSize = file.tellg(); fileSize = file.tellg();
if (fileSize > FLASH_REGION_SIZE * (flashWrite.lastRegion - flashWrite.firstRegion)) { if (fileSize > FLASH_REGION_SIZE * (flashWrite.lastRegion - flashWrite.firstRegion)) {
sif::warning << "StrHelper::performFlashWrite: Invalid file" << std::endl; sif::warning << "StrHelper::performFlashWrite: Invalid file" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
uint32_t fileChunks = fileSize / CHUNK_SIZE; uint32_t fileChunks = fileSize / CHUNK_SIZE;
bytesWritten = 0; bytesWritten = 0;
@ -327,36 +328,36 @@ ReturnValue_t StrHelper::performFlashWrite() {
req.length = CHUNK_SIZE; req.length = CHUNK_SIZE;
for (uint32_t idx = 0; idx < fileChunks; idx++) { for (uint32_t idx = 0; idx < fileChunks; idx++) {
if (terminate) { if (terminate) {
file.close(); file.close();
return RETURN_OK; return RETURN_OK;
} }
file.seekg(idx * CHUNK_SIZE, file.beg); file.seekg(idx * CHUNK_SIZE, file.beg);
file.read(reinterpret_cast<char*>(req.data), CHUNK_SIZE); file.read(reinterpret_cast<char*>(req.data), CHUNK_SIZE);
if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) { if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) {
req.region++; req.region++;
bytesWritten = 0; bytesWritten = 0;
} }
req.address = bytesWritten; req.address = bytesWritten;
arc_pack_write_action_req(&req, commandBuffer, &size); arc_pack_write_action_req(&req, commandBuffer, &size);
result = sendAndRead(size, req.address); result = sendAndRead(size, req.address);
if (result != RETURN_OK) { if (result != RETURN_OK) {
file.close(); file.close();
return result; return result;
} }
result = checkFlashActionReply(req.region, req.address, req.length); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
file.close(); file.close();
return result; return result;
} }
bytesWritten += CHUNK_SIZE; bytesWritten += CHUNK_SIZE;
} }
uint32_t remainingBytes = fileSize - fileChunks * CHUNK_SIZE; uint32_t remainingBytes = fileSize - fileChunks * CHUNK_SIZE;
file.seekg((fileChunks - 1) * CHUNK_SIZE , file.beg); file.seekg((fileChunks - 1) * CHUNK_SIZE, file.beg);
file.read(reinterpret_cast<char*>(req.data), remainingBytes); file.read(reinterpret_cast<char*>(req.data), remainingBytes);
file.close(); file.close();
if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) { if (bytesWritten + CHUNK_SIZE > FLASH_REGION_SIZE) {
req.region++; req.region++;
bytesWritten = 0; bytesWritten = 0;
} }
req.address = bytesWritten; req.address = bytesWritten;
req.length = remainingBytes; req.length = remainingBytes;
@ -365,7 +366,7 @@ ReturnValue_t StrHelper::performFlashWrite() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
result = checkFlashActionReply(req.region, req.address, req.length); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -416,7 +417,7 @@ ReturnValue_t StrHelper::performFlashRead() {
file.close(); file.close();
return result; return result;
} }
result = checkFlashActionReply(req.region, req.address, req.length); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) { if (retries < CONFIG_MAX_DOWNLOAD_RETRIES) {
uartComIF->flushUartRxBuffer(comCookie); uartComIF->flushUartRxBuffer(comCookie);
@ -435,7 +436,7 @@ ReturnValue_t StrHelper::performFlashRead() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) { ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter, uint32_t delayMs) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
ReturnValue_t decResult = RETURN_OK; ReturnValue_t decResult = RETURN_OK;
size_t receivedDataLen = 0; size_t receivedDataLen = 0;
@ -452,6 +453,10 @@ ReturnValue_t StrHelper::sendAndRead(size_t size, uint32_t parameter) {
} }
decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS; decResult = ArcsecDatalinkLayer::DEC_IN_PROGRESS;
while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) { while (decResult == ArcsecDatalinkLayer::DEC_IN_PROGRESS) {
Countdown delay(delayMs);
delay.resetTimer();
while (delay.isBusy()) {
}
result = uartComIF->requestReceiveMessage(comCookie, startracker::MAX_FRAME_SIZE * 2 + 2); result = uartComIF->requestReceiveMessage(comCookie, startracker::MAX_FRAME_SIZE * 2 + 2);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl; sif::warning << "StrHelper::sendAndRead: Failed to request reply" << std::endl;
@ -513,46 +518,6 @@ ReturnValue_t StrHelper::checkReplyPosition(uint32_t expectedPosition) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t StrHelper::checkFlashActionReply(uint8_t region_, uint32_t address_,
uint16_t length_) {
ReturnValue_t result = RETURN_OK;
result = checkActionReply();
if (result != RETURN_OK) {
return result;
}
const uint8_t* data = datalinkLayer.getReply();
uint8_t region = *(data + REGION_OFFSET);
uint32_t address;
const uint8_t* addressData = data + ADDRESS_OFFSET;
size_t size = sizeof(address);
result =
SerializeAdapter::deSerialize(&address, &addressData, &size, SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of address failed"
<< std::endl;
return result;
}
uint16_t length = 0;
size = sizeof(length);
const uint8_t* lengthData = data + LENGTH_OFFSET;
result =
SerializeAdapter::deSerialize(&length, lengthData, &size, SerializeIF::Endianness::LITTLE);
if (result != RETURN_OK) {
sif::warning << "StrHelper::checkFlashActionReply: Deserialization of length failed"
<< std::endl;
}
if (region != region_) {
return REGION_MISMATCH;
}
if (address != address_) {
return ADDRESS_MISMATCH;
}
if (length != length_) {
return LENGTH_MISMATCH;
}
return RETURN_OK;
}
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
ReturnValue_t StrHelper::checkPath(std::string name) { ReturnValue_t StrHelper::checkPath(std::string name) {
if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) == if (name.substr(0, sizeof(SdCardManager::SD_0_MOUNT_POINT)) ==
@ -585,29 +550,29 @@ void StrHelper::printProgress(uint32_t itemsTransferred, uint32_t fullNumItems)
} }
ReturnValue_t StrHelper::unlockAndEraseRegions(uint32_t from, uint32_t to) { ReturnValue_t StrHelper::unlockAndEraseRegions(uint32_t from, uint32_t to) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
struct UnlockActionRequest unlockReq; struct UnlockActionRequest unlockReq;
struct EraseActionRequest eraseReq; struct EraseActionRequest eraseReq;
uint32_t size = 0; uint32_t size = 0;
for (uint8_t idx = from; idx <= to; idx++) { for (uint8_t idx = from; idx <= to; idx++) {
unlockReq.region = idx; unlockReq.region = idx;
unlockReq.code = startracker::region_secrets::secret[idx]; unlockReq.code = startracker::region_secrets::secret[idx];
arc_pack_unlock_action_req(&unlockReq, commandBuffer, &size); arc_pack_unlock_action_req(&unlockReq, commandBuffer, &size);
sendAndRead(size, unlockReq.region); sendAndRead(size, unlockReq.region);
result = checkActionReply(); result = checkActionReply();
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "StrHelper::unlockAndEraseRegions: Failed to unlock region with id " sif::warning << "StrHelper::unlockAndEraseRegions: Failed to unlock region with id "
<< static_cast<unsigned int>(unlockReq.region) << std::endl; << static_cast<unsigned int>(unlockReq.region) << std::endl;
return result; return result;
}
eraseReq.region = idx;
arc_pack_erase_action_req(&eraseReq, commandBuffer, &size);
result = sendAndRead(size, eraseReq.region);
if (result != RETURN_OK) {
sif::warning << "StrHelper::unlockAndEraseRegions: Failed to erase region with id "
<< static_cast<unsigned int>(eraseReq.region) << std::endl;
return result;
}
} }
return result; eraseReq.region = idx;
arc_pack_erase_action_req(&eraseReq, commandBuffer, &size);
result = sendAndRead(size, eraseReq.region, FLASH_ERASE_DELAY);
if (result != RETURN_OK) {
sif::warning << "StrHelper::unlockAndEraseRegions: Failed to erase region with id "
<< static_cast<unsigned int>(eraseReq.region) << std::endl;
return result;
}
}
return result;
} }

View File

@ -181,7 +181,8 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
static const uint8_t ADDRESS_OFFSET = 3; static const uint8_t ADDRESS_OFFSET = 3;
static const uint8_t LENGTH_OFFSET = 7; static const uint8_t LENGTH_OFFSET = 7;
static const size_t CHUNK_SIZE = 1024; static const size_t CHUNK_SIZE = 1024;
static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 3; static const size_t CONFIG_MAX_DOWNLOAD_RETRIES = 2000;
static const uint32_t FLASH_ERASE_DELAY = 500;
enum class InternalState { enum class InternalState {
IDLE, IDLE,
@ -307,10 +308,11 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
* *
* @param size Size of data beforehand written to the commandBuffer * @param size Size of data beforehand written to the commandBuffer
* @param parameter Parameter 2 of trigger event function * @param parameter Parameter 2 of trigger event function
* @param delayMs Delay in milliseconds between send and receive call
* *
* @return RETURN_OK if successful, otherwise RETURN_FAILED * @return RETURN_OK if successful, otherwise RETURN_FAILED
*/ */
ReturnValue_t sendAndRead(size_t size, uint32_t parameter); ReturnValue_t sendAndRead(size_t size, uint32_t parameter, uint32_t delayMs = 0);
/** /**
* @brief Checks the header (type id and status fields) of the action reply * @brief Checks the header (type id and status fields) of the action reply
@ -328,14 +330,6 @@ class StrHelper : public SystemObject, public ExecutableObjectIF, public HasRetu
*/ */
ReturnValue_t checkReplyPosition(uint32_t expectedPosition); ReturnValue_t checkReplyPosition(uint32_t expectedPosition);
/**
* @brief Checks the region, address and length value of a flash write or read reply.
*
* @return RETURN_OK if values match expected values, otherwise appropriate error return
* value.
*/
ReturnValue_t checkFlashActionReply(uint8_t region_, uint32_t address_, uint16_t length_);
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
/** /**
* @brief Checks if a path points to an sd card and whether the SD card is monuted. * @brief Checks if a path points to an sd card and whether the SD card is monuted.

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 137 translations. * @brief Auto-generated event translation file. Contains 138 translations.
* @details * @details
* Generated on: 2022-02-13 15:31:27 * Generated on: 2022-02-22 09:46:40
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -107,6 +107,7 @@ const char *SELF_TEST_MTM_RANGE_FAILURE_STRING = "SELF_TEST_MTM_RANGE_FAILURE";
const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE"; const char *SELF_TEST_COIL_CURRENT_FAILURE_STRING = "SELF_TEST_COIL_CURRENT_FAILURE";
const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE"; const char *INVALID_ERROR_BYTE_STRING = "INVALID_ERROR_BYTE";
const char *ERROR_STATE_STRING = "ERROR_STATE"; const char *ERROR_STATE_STRING = "ERROR_STATE";
const char *BOOTING_FIRMWARE_FAILED_STRING = "BOOTING_FIRMWARE_FAILED";
const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE"; const char *SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING = "SUPV_MEMORY_READ_RPT_CRC_FAILURE";
const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE"; const char *SUPV_ACK_FAILURE_STRING = "SUPV_ACK_FAILURE";
const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE"; const char *SUPV_EXE_FAILURE_STRING = "SUPV_EXE_FAILURE";
@ -349,6 +350,8 @@ const char * translateEvents(Event event) {
return INVALID_ERROR_BYTE_STRING; return INVALID_ERROR_BYTE_STRING;
case(11301): case(11301):
return ERROR_STATE_STRING; return ERROR_STATE_STRING;
case(11401):
return BOOTING_FIRMWARE_FAILED_STRING;
case(11501): case(11501):
return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING; return SUPV_MEMORY_READ_RPT_CRC_FAILURE_STRING;
case(11502): case(11502):

View File

@ -3,6 +3,6 @@
#include "fsfw/events/Event.h" #include "fsfw/events/Event.h"
const char* translateEvents(Event event); const char * translateEvents(Event event);
#endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */ #endif /* FSFWCONFIG_EVENTS_TRANSLATEEVENTS_H_ */

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 111 translations. * Contains 111 translations.
* Generated on: 2022-02-13 15:31:32 * Generated on: 2022-02-23 11:11:47
*/ */
#include "translateObjects.h" #include "translateObjects.h"