that was hopefully the last set of fixes
Some checks failed
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2023-06-25 13:07:31 +02:00
parent 5a15d39a1d
commit 80160e8291
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -68,18 +68,33 @@ ReturnValue_t PusTmFunnel::handleTmPacket(TmTcMessage &message) {
return result; return result;
} }
packet.setSequenceCount(sourceSequenceCount++); packet.setSequenceCount(sourceSequenceCount++);
// NOTE: This only works because the limit value bit width is below 16 bits!
sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT; sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT;
uint8_t service = packet.getMessageTypeCounter();
// Message type counter handling.
uint8_t service = packet.getService();
bool insertionFailed = false;
auto mapIter = msgCounterMap.find(service); auto mapIter = msgCounterMap.find(service);
if (mapIter == msgCounterMap.end()) { if (mapIter == msgCounterMap.end()) {
msgCounterMap.emplace(service, 0); auto iterPair = msgCounterMap.emplace(service, 0);
if (iterPair.second) {
mapIter = iterPair.first;
} else {
// Should really never never happen but you never know..
insertionFailed = true;
}
} }
if (mapIter->second == std::numeric_limits<uint16_t>::max()) { if (not insertionFailed) {
mapIter->second = 0; packet.setMessageCount(mapIter->second);
} else { // Sane overflow handling.
mapIter->second++; if (mapIter->second == std::numeric_limits<uint16_t>::max()) {
mapIter->second = 0;
} else {
mapIter->second++;
}
} }
packet.setMessageCount(mapIter->second);
// Re-calculate CRC after changing the fields. This operation HAS to come last!
packet.updateErrorControl(); packet.updateErrorControl();
// Send to persistent TM store if the packet matches some filter. // Send to persistent TM store if the packet matches some filter.