various fixes and improvements
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
2022-11-28 16:24:18 +01:00
parent 003d37c490
commit 2c223712ff
5 changed files with 41 additions and 12 deletions

View File

@ -116,7 +116,9 @@ ReturnValue_t PlocSupvUartManager::performOperation(uint8_t operationCode) {
break;
}
case InternalState::DEDICATED_REQUEST: {
updateVtime(1);
handleRunningLongerRequest();
updateVtime(2);
MutexGuard mg(lock);
state = InternalState::DEFAULT;
break;
@ -380,9 +382,9 @@ ReturnValue_t PlocSupvUartManager::writeUpdatePackets() {
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
uint8_t tempData[supv::WriteMemory::CHUNK_MAX + 1]{};
if (not std::filesystem::exists(update.file)) {
sif::error << "PlocSupvUartManager::writeUpdatePackets: File "
<< update.file << " does not exist" << std::endl;
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
sif::error << "PlocSupvUartManager::writeUpdatePackets: File " << update.file
<< " does not exist" << std::endl;
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
}
std::ifstream file(update.file, std::ifstream::binary);
uint16_t dataLength = 0;
@ -553,6 +555,7 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
return result;
}
Countdown countdown(timeoutExecutionReport);
dur_millis_t currentDelay = 5;
bool ackReceived = false;
bool packetWasHandled = false;
while (true) {
@ -590,7 +593,10 @@ ReturnValue_t PlocSupvUartManager::handlePacketTransmissionNoReply(
decodedRingBuf.deleteData(packetLen);
}
} else {
TaskFactory::delayTask(20);
TaskFactory::delayTask(currentDelay);
if (currentDelay < 20) {
currentDelay *= 2;
}
}
if (countdown.hasTimedOut()) {
return result::NO_REPLY_TIMEOUT;
@ -1095,9 +1101,11 @@ void PlocSupvUartManager::addHdlcFraming(const uint8_t* src, size_t slen, uint8_
}
size_t dummy = 0;
uint8_t crcRaw[2];
// hdlc crc16 is in little endian format
SerializeAdapter::serialize(&crc16, dst + tlen, &dummy, maxDest, SerializeIF::Endianness::LITTLE);
tlen += dummy;
SerializeAdapter::serialize(&crc16, crcRaw, &dummy, maxDest, SerializeIF::Endianness::LITTLE);
hdlc_add_byte(crcRaw[0], dst, &tlen);
hdlc_add_byte(crcRaw[1], dst, &tlen);
dst[tlen++] = 0x7C;
*dlen = tlen;
@ -1141,3 +1149,9 @@ bool PlocSupvUartManager::longerRequestActive() const {
MutexGuard mg(lock);
return state == InternalState::DEDICATED_REQUEST;
}
void PlocSupvUartManager::updateVtime(uint8_t vtime) {
tcgetattr(serialPort, &tty);
tty.c_cc[VTIME] = vtime;
tcsetattr(serialPort, TCSANOW, &tty);
}