completed CFDP TM funnel impl
This commit is contained in:
parent
4d49d3c1a4
commit
0d106fe4d6
@ -37,18 +37,38 @@ ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) {
|
|||||||
ReturnValue_t CfdpTmFunnel::initialize() { return returnvalue::OK; }
|
ReturnValue_t CfdpTmFunnel::initialize() { return returnvalue::OK; }
|
||||||
|
|
||||||
ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) {
|
ReturnValue_t CfdpTmFunnel::handlePacket(TmTcMessage& msg) {
|
||||||
uint8_t* packetData = nullptr;
|
const uint8_t* cfdpPacket = nullptr;
|
||||||
size_t size = 0;
|
size_t cfdpPacketLen = 0;
|
||||||
ReturnValue_t result = tmStore.modifyData(msg.getStorageId(), &packetData, &size);
|
ReturnValue_t result = tmStore.getData(msg.getStorageId(), &cfdpPacket, &cfdpPacketLen);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
auto spacePacket =
|
auto spacePacketHeader =
|
||||||
SpacePacketCreator(ccsds::PacketType::TM, false, cfdpInCcsdsApid,
|
SpacePacketCreator(ccsds::PacketType::TM, false, cfdpInCcsdsApid,
|
||||||
ccsds::SequenceFlags::UNSEGMENTED, sourceSequenceCount++, 0);
|
ccsds::SequenceFlags::UNSEGMENTED, sourceSequenceCount++, 0);
|
||||||
sourceSequenceCount = sourceSequenceCount & ccsds::LIMIT_SEQUENCE_COUNT;
|
sourceSequenceCount = sourceSequenceCount & ccsds::LIMIT_SEQUENCE_COUNT;
|
||||||
spacePacket.setCcsdsLenFromTotalDataFieldLen(size);
|
spacePacketHeader.setCcsdsLenFromTotalDataFieldLen(cfdpPacketLen);
|
||||||
// TODO: Get new slot from TM store, serialize space packet header first, and then the CFDP packet
|
uint8_t* newPacketData = nullptr;
|
||||||
|
store_address_t newStoreId{};
|
||||||
|
result =
|
||||||
|
tmStore.getFreeElement(&newStoreId, spacePacketHeader.getFullPacketLen(), &newPacketData);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "CfdpTmFunnel::handlePacket: Error getting TM store element of size "
|
||||||
|
<< spacePacketHeader.getFullPacketLen() << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
size_t serSize = 0;
|
||||||
|
result =
|
||||||
|
spacePacketHeader.serializeBe(&newPacketData, &serSize, spacePacketHeader.getFullPacketLen());
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "CfdpTmFunnel::handlePacket: Error serializing packet" << std::endl;
|
||||||
|
#endif
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
std::memcpy(newPacketData, cfdpPacket, cfdpPacketLen);
|
||||||
result = msgQueue->sendToDefault(&msg);
|
result = msgQueue->sendToDefault(&msg);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
tmStore.deleteData(msg.getStorageId());
|
tmStore.deleteData(msg.getStorageId());
|
||||||
|
@ -46,6 +46,9 @@ ReturnValue_t PusTmFunnel::handlePacket(TmTcMessage &message) {
|
|||||||
PusTmZeroCopyWriter packet(timeReader, packetData, size);
|
PusTmZeroCopyWriter packet(timeReader, packetData, size);
|
||||||
result = packet.parseDataWithoutCrcCheck();
|
result = packet.parseDataWithoutCrcCheck();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "PusTmFunnel::handlePacket: Error parsing received PUS packet" << std::endl;
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
packet.setSequenceCount(sourceSequenceCount++);
|
packet.setSequenceCount(sourceSequenceCount++);
|
||||||
|
Loading…
Reference in New Issue
Block a user