bugfix in map packet extraction

This commit is contained in:
Robin Müller 2022-11-09 14:06:59 +01:00
parent ce387deee7
commit 31defac17c
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 12 additions and 7 deletions

View File

@ -89,12 +89,17 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame)
if (totalLength > MAX_PACKET_SIZE) return CONTENT_TOO_LARGE; if (totalLength > MAX_PACKET_SIZE) return CONTENT_TOO_LARGE;
uint8_t* position = frame->getDataField(); uint8_t* position = frame->getDataField();
while ((totalLength > ccsds::HEADER_LEN)) { while ((totalLength > ccsds::HEADER_LEN)) {
SpacePacketBase packet(position); SpacePacketReader packet(position, totalLength);
uint32_t packetSize = packet.getFullSize(); status = packet.checkSize();
if(status != returnvalue::OK) {
// TODO: Better error handling
status = DATA_CORRUPTED;
}
uint32_t packetSize = packet.getFullPacketLen();
if (packetSize <= totalLength) { if (packetSize <= totalLength) {
status = sendCompletePacket(packet.getWholeData(), packet.getFullSize()); status = sendCompletePacket(packet.getFullData(), packet.getFullPacketLen());
totalLength -= packet.getFullSize(); totalLength -= packet.getFullPacketLen();
position += packet.getFullSize(); position += packet.getFullPacketLen();
status = returnvalue::OK; status = returnvalue::OK;
} else { } else {
status = DATA_CORRUPTED; status = DATA_CORRUPTED;
@ -107,7 +112,7 @@ ReturnValue_t MapPacketExtraction::unpackBlockingPackets(TcTransferFrame* frame)
return status; return status;
} }
ReturnValue_t MapPacketExtraction::sendCompletePacket(uint8_t* data, uint32_t size) { ReturnValue_t MapPacketExtraction::sendCompletePacket(const uint8_t* data, uint32_t size) {
store_address_t store_id; store_address_t store_id;
ReturnValue_t status = this->packetStore->addData(&store_id, data, size); ReturnValue_t status = this->packetStore->addData(&store_id, data, size);
if (status == returnvalue::OK) { if (status == returnvalue::OK) {

View File

@ -47,7 +47,7 @@ class MapPacketExtraction : public MapPacketExtractionIF {
* @param size Complete total size of the packet. * @param size Complete total size of the packet.
* @return Return Code of the Packet Store or the Message Queue. * @return Return Code of the Packet Store or the Message Queue.
*/ */
ReturnValue_t sendCompletePacket(uint8_t* data, uint32_t size); ReturnValue_t sendCompletePacket(const uint8_t* data, uint32_t size);
/** /**
* Helper method to reset the internal buffer. * Helper method to reset the internal buffer.
*/ */