Merge pull request 'Bugfixes ans tweaks for STR' (#559) from bugfixes_tweaks_str into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

Reviewed-on: #559
This commit is contained in:
Robin Müller 2023-04-04 11:22:49 +02:00
commit 2b18ab1504
6 changed files with 76 additions and 59 deletions

View File

@ -22,11 +22,15 @@ will consitute of a breaking change warranting a new major release:
- Version of thermal controller which performs basic control tasks.
- PCDU handler can now command switch of the 3V3 stack (switch ID 19)
- Set STR dev to OFF in assembly when it is faulty.
- STR: Reset data link layer and flush RX for regular commands and before performing special
commands to ensure consistent start state
## Fixed
- PTME was not reset after configuration changes.
- GPS health devices: ACS board assembly not reacts to health changes.
- STR COM helper: Reset reply size after returning a reply
## Changed

View File

@ -42,7 +42,6 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
while (true) {
lock->lockMutex();
state = InternalState::SLEEPING;
datalinkLayer.reset();
lock->unlockMutex();
semaphore.acquire();
switch (state) {
@ -58,6 +57,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
}
case InternalState::UPLOAD_IMAGE: {
replyTimeout.setTimeout(200);
resetReplyHandlingState();
result = performImageUpload();
if (result == returnvalue::OK) {
triggerEvent(IMAGE_UPLOAD_SUCCESSFUL);
@ -68,6 +68,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
}
case InternalState::DOWNLOAD_IMAGE: {
replyTimeout.setTimeout(200);
resetReplyHandlingState();
result = performImageDownload();
if (result == returnvalue::OK) {
triggerEvent(IMAGE_DOWNLOAD_SUCCESSFUL);
@ -78,6 +79,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
}
case InternalState::FLASH_READ: {
replyTimeout.setTimeout(200);
resetReplyHandlingState();
result = performFlashRead();
if (result == returnvalue::OK) {
triggerEvent(FLASH_READ_SUCCESSFUL);
@ -88,6 +90,7 @@ ReturnValue_t StrComHandler::performOperation(uint8_t operationCode) {
}
case InternalState::FIRMWARE_UPDATE: {
replyTimeout.setTimeout(200);
resetReplyHandlingState();
result = performFirmwareUpdate();
if (result == returnvalue::OK) {
triggerEvent(FIRMWARE_UPDATE_SUCCESSFUL);
@ -645,7 +648,8 @@ ReturnValue_t StrComHandler::sendMessage(CookieIF* cookie, const uint8_t* sendDa
return BUSY;
}
}
serial::flushRxBuf(serialPort);
// Ensure consistent state.
resetReplyHandlingState();
const uint8_t* txFrame;
size_t frameLen;
@ -697,6 +701,7 @@ ReturnValue_t StrComHandler::readReceivedMessage(CookieIF* cookie, uint8_t** buf
*buffer = const_cast<uint8_t*>(replyPtr);
*size = replyLen;
}
replyLen = 0;
return replyResult;
}
@ -781,3 +786,8 @@ ReturnValue_t StrComHandler::readOneReply(uint32_t failParameter) {
}
}
}
void StrComHandler::resetReplyHandlingState() {
serial::flushRxBuf(serialPort);
datalinkLayer.reset();
}

View File

@ -374,6 +374,8 @@ class StrComHandler : public SystemObject, public DeviceCommunicationIF, public
* @return
*/
ReturnValue_t readOneReply(uint32_t failParameter);
void resetReplyHandlingState();
};
#endif /* BSP_Q7S_DEVICES_STRHELPER_H_ */

View File

@ -56,6 +56,49 @@ StarTrackerHandler::StarTrackerHandler(object_id_t objectId, object_id_t comIF,
StarTrackerHandler::~StarTrackerHandler() {}
void StarTrackerHandler::doStartUp() {
switch (startupState) {
case StartupState::IDLE:
startupState = StartupState::CHECK_PROGRAM;
return;
case StartupState::BOOT_BOOTLOADER:
// This step is required in case the star tracker is already in firmware mode to harmonize
// the device handler's submode to the star tracker's mode
return;
case StartupState::DONE:
if (jcfgCountdown.isBusy()) {
startupState = StartupState::WAIT_JCFG;
return;
}
startupState = StartupState::IDLE;
break;
case StartupState::WAIT_JCFG: {
if (jcfgCountdown.hasTimedOut()) {
startupState = StartupState::IDLE;
break;
}
return;
}
default:
return;
}
solutionSet.setReportingEnabled(true);
startupState = StartupState::DONE;
internalState = InternalState::IDLE;
setMode(_MODE_TO_ON);
}
void StarTrackerHandler::doShutDown() {
// If the star tracker is shutdown also stop all running processes in the image loader task
strHelper->stopProcess();
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
bootState = FwBootState::NONE;
solutionSet.setReportingEnabled(false);
reinitNextSetParam = false;
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t StarTrackerHandler::initialize() {
ReturnValue_t result = returnvalue::OK;
result = DeviceHandlerBase::initialize();
@ -236,49 +279,6 @@ void StarTrackerHandler::performOperationHook() {
Submode_t StarTrackerHandler::getInitialSubmode() { return SUBMODE_BOOTLOADER; }
void StarTrackerHandler::doStartUp() {
switch (startupState) {
case StartupState::IDLE:
startupState = StartupState::CHECK_PROGRAM;
return;
case StartupState::BOOT_BOOTLOADER:
// This step is required in case the star tracker is already in firmware mode to harmonize
// the device handler's submode to the star tracker's mode
return;
case StartupState::DONE:
if (jcfgCountdown.isBusy()) {
startupState = StartupState::WAIT_JCFG;
return;
}
startupState = StartupState::IDLE;
break;
case StartupState::WAIT_JCFG: {
if (jcfgCountdown.hasTimedOut()) {
startupState = StartupState::IDLE;
break;
}
return;
}
default:
return;
}
solutionSet.setReportingEnabled(true);
startupState = StartupState::DONE;
internalState = InternalState::IDLE;
setMode(_MODE_TO_ON);
}
void StarTrackerHandler::doShutDown() {
// If the star tracker is shutdown also stop all running processes in the image loader task
strHelper->stopProcess();
internalState = InternalState::IDLE;
startupState = StartupState::IDLE;
bootState = FwBootState::NONE;
solutionSet.setReportingEnabled(false);
reinitNextSetParam = false;
setMode(_MODE_POWER_DOWN);
}
ReturnValue_t StarTrackerHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
if (strHelperHandlingSpecialRequest) {
return NOTHING_TO_SEND;
@ -831,7 +831,6 @@ void StarTrackerHandler::bootBootloader() {
ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t remainingSize,
DeviceCommandId_t* foundId, size_t* foundLen) {
ReturnValue_t result = returnvalue::OK;
size_t bytesLeft = 0;
if (remainingSize == 0) {
*foundLen = remainingSize;
@ -845,24 +844,24 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema
switch (startracker::getReplyFrameType(start)) {
case TMTC_ACTIONREPLY: {
*foundLen = remainingSize - bytesLeft;
result = scanForActionReply(startracker::getId(start), foundId);
*foundLen = remainingSize;
return scanForActionReply(startracker::getId(start), foundId);
break;
}
case TMTC_SETPARAMREPLY: {
*foundLen = remainingSize - bytesLeft;
result = scanForSetParameterReply(startracker::getId(start), foundId);
*foundLen = remainingSize;
return scanForSetParameterReply(startracker::getId(start), foundId);
break;
}
case TMTC_PARAMREPLY: {
*foundLen = remainingSize - bytesLeft;
result = scanForGetParameterReply(startracker::getId(start), foundId);
*foundLen = remainingSize;
return scanForGetParameterReply(startracker::getId(start), foundId);
break;
}
case TMTC_TELEMETRYREPLYA:
case TMTC_TELEMETRYREPLY: {
*foundLen = remainingSize - bytesLeft;
result = scanForTmReply(startracker::getId(start), foundId);
*foundLen = remainingSize;
return scanForTmReply(startracker::getId(start), foundId);
break;
}
default: {
@ -870,9 +869,6 @@ ReturnValue_t StarTrackerHandler::scanForReply(const uint8_t* start, size_t rema
result = returnvalue::FAILED;
}
}
remainingSize = bytesLeft;
return result;
}

View File

@ -11,8 +11,13 @@ StrAssembly::StrAssembly(object_id_t objectId) : AssemblyBase(objectId) {
}
ReturnValue_t StrAssembly::commandChildren(Mode_t mode, Submode_t submode) {
commandTable[0].setMode(mode);
// To ensure consistent state.
commandTable[0].setMode(MODE_OFF);
commandTable[0].setSubmode(submode);
if (healthHelper.healthTable->getHealth(objects::STAR_TRACKER) != FAULTY) {
commandTable[0].setMode(mode);
commandTable[0].setSubmode(submode);
}
HybridIterator<ModeListEntry> iter(commandTable.begin(), commandTable.end());
executeTable(iter);
return returnvalue::OK;

2
tmtc

@ -1 +1 @@
Subproject commit de1188c1bbc890d9b1e3a43cb0c3f06d34e07639
Subproject commit 1fb50d84c61fd7ebf393fb0a030a86752f106c53