completed ring buffer parser
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2022-11-04 12:38:30 +01:00
parent af0853a42b
commit b5cd873f6d
6 changed files with 28 additions and 41 deletions

View File

@ -941,41 +941,15 @@ ReturnValue_t PlocSupvHelper::parseRecRingBufForHdlc(size_t& readSize) {
if (encodedBuf[idx] == HDLC_END_MARKER) {
if (startMarkerFound) {
// Probably a packet, so decode it
size_t decodedLen = 0;
hdlc_remove_framing(encodedBuf.data() + startIdx, idx + 1, decodedBuf.data(), &decodedLen);
readSize = decodedLen;
return returnvalue::OK;
} else {
readSize = ++idx;
return POSSIBLE_PACKET_LOSS_CONSECUTIVE_END;
}
}
}
// // handle ETX char
// if (encodedBuf.first[vectorIdx] == DleEncoder::ETX_CHAR) {
// if (stxFound) {
// // This is propably a packet, so we decode it.
// size_t decodedLen = 0;
// size_t dummy = 0;
//
// ReturnValue_t result =
// decoder.decode(&encodedBuf.first[stxIdx], availableData - stxIdx, &dummy,
// decodedBuf.first, decodedBuf.second,
//&decodedLen); if (result == returnvalue::OK) {
//ctx.setType(ContextType::PACKET_FOUND); ctx.decodedPacket.first = decodedBuf.first;
// ctx.decodedPacket.second = decodedLen;
// readSize = ++vectorIdx;
// return returnvalue::OK;
// } else {
// // invalid packet, skip.
// readSize = ++vectorIdx;
// ErrorInfo info;
// info.res = result;
// setErrorContext(ErrorTypes::DECODE_ERROR, info);
// return POSSIBLE_PACKET_LOSS;
// }
// } else {
// // might be lost packet, so we should advance the read pointer
// readSize = ++vectorIdx;
// ErrorInfo info;
// info.len = 0;
// setErrorContext(ErrorTypes::CONSECUTIVE_ETX_CHARS, info);
// return POSSIBLE_PACKET_LOSS;
// }
// }
// }
// return NO_PACKET_FOUND;
return NO_PACKET_FOUND;
}

View File

@ -226,6 +226,7 @@ class PlocSupvHelper : public DeviceCommunicationIF,
#endif
std::array<uint8_t, 2048> recBuf = {};
std::array<uint8_t, 2048> encodedBuf = {};
std::array<uint8_t, 1200> decodedBuf = {};
SimpleRingBuffer recRingBuf;
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]{};
SpacePacketCreator creator;