that was hopefully the last set of fixes
This commit is contained in:
parent
5a15d39a1d
commit
80160e8291
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user