fsfw/src/fsfw/tmtcpacket/SpacePacket.cpp

29 lines
887 B
C++
Raw Normal View History

2021-07-13 20:22:54 +02:00
#include "fsfw/tmtcpacket/SpacePacket.h"
2022-02-02 10:29:30 +01:00
2021-07-13 20:22:54 +02:00
#include <cstring>
2022-02-02 10:29:30 +01:00
#include "fsfw/tmtcpacket/ccsds_header.h"
2021-07-13 20:22:54 +02:00
SpacePacket::SpacePacket(uint16_t packetDataLength, bool isTelecommand, uint16_t apid,
2022-02-02 10:29:30 +01:00
uint16_t sequenceCount)
: SpacePacketBase((uint8_t*)&this->localData) {
initSpacePacketHeader(isTelecommand, false, apid, sequenceCount);
this->setPacketSequenceCount(sequenceCount);
if (packetDataLength <= sizeof(this->localData.fields.buffer)) {
this->setPacketDataLength(packetDataLength);
} else {
this->setPacketDataLength(sizeof(this->localData.fields.buffer));
}
}
2022-02-02 10:29:30 +01:00
SpacePacket::~SpacePacket(void) {}
2022-02-02 10:29:30 +01:00
bool SpacePacket::addWholeData(const uint8_t* p_Data, uint32_t packet_size) {
2022-04-29 07:43:52 +02:00
if (packet_size <= sizeof(this->localData)) {
memcpy(this->localData.byteStream, p_Data, packet_size);
2022-02-02 10:29:30 +01:00
return true;
} else {
return false;
}
}