str image helper, step failure handling
This commit is contained in:
parent
077913400f
commit
1affc1e1d3
@ -195,10 +195,30 @@ void StarTrackerImageHelper::stepSuccessfulReceived(ActionId_t actionId,
|
||||
|
||||
void StarTrackerImageHelper::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
||||
ReturnValue_t returnCode) {
|
||||
switch (pendingCommand) {
|
||||
case (StarTracker::UPLOAD_IMAGE):
|
||||
if (retries < MAX_RETRIES) {
|
||||
// Repeat sending last command
|
||||
commandsSent--;
|
||||
remainingCommands++;
|
||||
commandImageUpload();
|
||||
retries++;
|
||||
state = State::COMMAND_EXECUTING;
|
||||
}
|
||||
else {
|
||||
triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent);
|
||||
retries = 0;
|
||||
state = State::IDLE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sif::debug << "StarTrackerImageHelper::completionSuccessfulReceived: Invalid pending command"
|
||||
<< std::endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerImageHelper::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
||||
|
||||
}
|
||||
|
||||
void StarTrackerImageHelper::completionSuccessfulReceived(ActionId_t actionId) {
|
||||
@ -225,7 +245,7 @@ void StarTrackerImageHelper::completionFailedReceived(ActionId_t actionId,
|
||||
ReturnValue_t returnCode) {
|
||||
switch(pendingCommand) {
|
||||
case(StarTracker::UPLOAD_IMAGE): {
|
||||
triggerEvent(IMAGE_UPLOAD_FAILED);
|
||||
triggerEvent(IMAGE_UPLOAD_FAILED, returnCode, commandsSent);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -240,7 +260,7 @@ void StarTrackerImageHelper::commandImageUpload() {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
uint16_t dataLen = 0;
|
||||
uint8_t tmpCommandBuffer[UPLOAD_COMMAND_SIZE] = {0};
|
||||
uint32_t position = commandsSent * SIZE_IMAGE_PART;
|
||||
uint32_t position = commandsSent;
|
||||
|
||||
if (not std::filesystem::exists(imageFile)) {
|
||||
triggerEvent(IMAGE_FILE_NOT_EXISTS, commandsSent);
|
||||
|
@ -72,13 +72,14 @@ private:
|
||||
//! P1: Return value of CommandActionHelper::commandAction
|
||||
//! P2: Action ID of command to send
|
||||
static const Event ACTION_COMMANDING_FAILED = MAKE_EVENT(1, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Star tracker handler replies with completion failure message to upload image command
|
||||
//! P1: Upload step of the failed command execution
|
||||
//! [EXPORT] : [COMMENT] Star tracker handler replies with completion or step failure message to upload image command
|
||||
//!P1: Return code of execution/step failure message
|
||||
//!P2: Failed upload step (equal to number of commands already sent)
|
||||
static const Event IMAGE_UPLOAD_FAILED = MAKE_EVENT(2, severity::LOW);
|
||||
//! [EXPORT] : [COMMENT] Image upload was successful
|
||||
static const Event IMAGE_UPLOAD_FINISHED = MAKE_EVENT(3, severity::LOW);
|
||||
|
||||
|
||||
static const uint8_t MAX_RETRIES = 3;
|
||||
static const uint32_t QUEUE_SIZE = config::STR_IMG_HELPER_QUEUE_SIZE;
|
||||
static const size_t MAX_STR_IMAGE_PATH = 50;
|
||||
static const size_t SD_PREFIX_LENGTH = 8;
|
||||
@ -108,6 +109,8 @@ private:
|
||||
|
||||
uint32_t commandsSent = 0;
|
||||
uint32_t remainingCommands = 0;
|
||||
// Counts retries when command was rejected by star tracker
|
||||
uint8_t retries = 0;
|
||||
|
||||
// Path and name of active image (either upload or download image)
|
||||
std::string imageFile;
|
||||
|
@ -604,12 +604,13 @@ ReturnValue_t StarTrackerHandler::handleUploadImageReply() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET);
|
||||
if (position != rememberUploadPosition) {
|
||||
sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position"
|
||||
<< std::endl;
|
||||
return UPLOAD_IMAGE_FAILED;
|
||||
}
|
||||
// Position seems to be always 0 (independent of sent position)
|
||||
// uint32_t position = deserializeUint32(decodedFrame + ACTION_DATA_OFFSET);
|
||||
// if (position != rememberUploadPosition) {
|
||||
// sif::warning << "StarTrackerHandler::handleUploadImageReply: Invalid position"
|
||||
// << std::endl;
|
||||
// return UPLOAD_IMAGE_FAILED;
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ private:
|
||||
// position (uint32) + 1024 image data
|
||||
static const size_t UPLOAD_COMMAND_LEN = 1028;
|
||||
// Max valid position value in upload image command
|
||||
static const uint16_t MAX_POSITION= 3071;
|
||||
static const uint16_t MAX_POSITION= 4095;
|
||||
static const uint8_t STATUS_OFFSET = 2;
|
||||
static const uint8_t TICKS_OFFSET = 3;
|
||||
static const uint8_t TIME_OFFSET = 7;
|
||||
|
Loading…
Reference in New Issue
Block a user