start adding re-try logic for SUPV
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2024-06-04 15:10:54 +02:00
parent 467ee0028a
commit e43a86432b
2 changed files with 15 additions and 3 deletions

View File

@ -11,6 +11,7 @@
#include <fstream> #include <fstream>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "tas/hdlc.h" #include "tas/hdlc.h"
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#include "bsp_q7s/fs/FilesystemHelper.h" #include "bsp_q7s/fs/FilesystemHelper.h"
@ -449,10 +450,11 @@ ReturnValue_t PlocSupvUartManager::writeUpdatePackets() {
update.bytesWritten); update.bytesWritten);
return result; return result;
} }
result = handlePacketTransmissionNoReply(packet, 5000); result = handlePacketTransmissionNoReply(packet, COM_TIMEOUT_MS);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount), triggerEvent(WRITE_MEMORY_FAILED, buildProgParams1(progPercent, update.sequenceCount),
update.bytesWritten); update.bytesWritten);
// TODO: Retry logic, re-try up to three times.
return result; return result;
} }
@ -572,7 +574,15 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
bool ackReceived = false; bool ackReceived = false;
bool packetWasHandled = false; bool packetWasHandled = false;
while (true) { while (true) {
handleUartReception(); ReturnValue_t status = handleUartReception();
if (status != returnvalue::OK) {
result = status;
// We probably missed a packet or the communication was temporarily corrupted..
// It probably would be good to bail immediately for re-try logic.
if (result == HDLC_ERROR) {
return result;
}
}
if (not decodedQueue.empty()) { if (not decodedQueue.empty()) {
size_t packetLen = 0; size_t packetLen = 0;
decodedQueue.retrieve(&packetLen); decodedQueue.retrieve(&packetLen);
@ -615,7 +625,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
return result::NO_REPLY_TIMEOUT; return result::NO_REPLY_TIMEOUT;
} }
} }
return returnvalue::OK; return result;
} }
int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, size_t packetLen) { int PlocSupvUartManager::handleAckReception(supv::TcBase& tc, size_t packetLen) {

View File

@ -199,6 +199,8 @@ class PlocSupvUartManager : public DeviceCommunicationIF,
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 4); static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS_CONSECUTIVE_END = returnvalue::makeCode(1, 4);
static constexpr ReturnValue_t HDLC_ERROR = returnvalue::makeCode(1, 5); static constexpr ReturnValue_t HDLC_ERROR = returnvalue::makeCode(1, 5);
static constexpr uint32_t COM_TIMEOUT_MS = 3000;
static const uint16_t CRC16_INIT = 0xFFFF; static const uint16_t CRC16_INIT = 0xFFFF;
// Event buffer reply will carry 24 space packets with 1016 bytes and one space packet with // Event buffer reply will carry 24 space packets with 1016 bytes and one space packet with
// 192 bytes // 192 bytes