27 m_lastSequenceIndex(0),
28 m_lastPacketWriteStatus(
Os::File::MAX_STATUS),
29 m_filesReceived(this),
30 m_filesReceivedFailed(this),
31 m_packetsReceived(this),
37 this->m_file.osFile.configure(directory);
58 if (packetType != Fw::ComPacketType::FW_PACKET_FILE) {
73 switch (header_type) {
75 this->handleStartPacket(filePacket.asStartPacket());
78 this->handleDataPacket(filePacket.asDataPacket());
81 this->handleEndPacket(filePacket.asEndPacket());
84 this->handleCancelPacket();
94 void FileUplink::pingIn_handler(
const FwIndexType portNum, U32 key) {
109 this->m_packetsReceived.packetReceived();
110 if (this->m_receiveMode != START) {
111 this->m_file.osFile.close();
116 this->goToDataMode();
118 this->m_warnings.fileOpen(this->m_file.name);
119 this->goToStartMode();
124 this->m_packetsReceived.packetReceived();
125 if (this->m_receiveMode != DATA) {
133 if (this->m_lastPacketWriteStatus ==
Os::File::OP_OK && this->checkDuplicatedPacket(sequenceIndex)) {
137 this->checkSequenceIndex(sequenceIndex);
140 if ((std::numeric_limits<U32>::max() - byteOffset < dataSize) || (byteOffset + dataSize > this->m_file.size)) {
141 this->m_warnings.packetOutOfBounds(sequenceIndex, this->m_file.name);
147 this->m_warnings.fileWrite(this->m_file.name);
150 this->m_lastPacketWriteStatus = status;
154 this->m_packetsReceived.packetReceived();
155 if (this->m_receiveMode == DATA) {
157 if (this->compareChecksums(endPacket)) {
158 this->m_filesReceived.fileReceived();
167 this->m_filesReceivedFailed.fileReceivedFailed();
172 this->goToStartMode();
175 void FileUplink::handleCancelPacket() {
176 this->m_packetsReceived.packetReceived();
178 this->goToStartMode();
181 void FileUplink::checkSequenceIndex(
const U32 sequenceIndex) {
182 if (sequenceIndex != this->m_lastSequenceIndex + 1) {
183 this->m_warnings.packetOutOfOrder(sequenceIndex, this->m_lastSequenceIndex);
185 this->m_lastSequenceIndex = sequenceIndex;
188 bool FileUplink::checkDuplicatedPacket(
const U32 sequenceIndex) {
190 if (sequenceIndex == this->m_lastSequenceIndex) {
191 this->m_warnings.packetDuplicate(sequenceIndex);
201 this->m_file.getChecksum(computed);
203 const bool match = (computed == stored);
210 void FileUplink::goToStartMode() {
211 this->m_file.osFile.close();
212 this->m_receiveMode = START;
213 this->m_lastSequenceIndex = 0;
217 void FileUplink::goToDataMode() {
218 this->m_receiveMode = DATA;
219 this->m_lastSequenceIndex = 0;
const U8 * getData() const
Get the data.
Serialization/Deserialization operation was successful.
U16 FwPacketDescriptorType
The width of packet descriptors when they are serialized by the framework.
void log_ACTIVITY_HI_UplinkCanceled() const
const FilePacket::Header & asHeader() const
Get this as a Header.
void bufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port bufferSendOut.
void log_WARNING_HI_InvalidReceiveMode_ThrottleClear()
Reset throttle value for InvalidReceiveMode.
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
U32 getByteOffset() const
Get the byte offset.
const FilePacket::Header & asHeader() const
Get this as a Header.
The type of a data packet.
void getChecksum(CFDP::Checksum &checksum) const
Get the checksum.
U32 getDataSize() const
Get the data size.
void pingOut_out(FwIndexType portNum, U32 key) const
Invoke output port pingOut.
void log_WARNING_HI_DecodeError(I32 status) const
SerializeStatus
forward declaration for string
ExternalSerializeBufferWithMemberCopy getDeserializer()
void log_ACTIVITY_HI_FileReceived(const Fw::StringBase &fileName) const
Class representing a 32-bit checksum as mandated by the CCSDS File Delivery Protocol.
void log_WARNING_HI_PacketOutOfOrder_ThrottleClear()
Reset throttle value for PacketOutOfOrder.
bool isConnected_fileAnnounce_OutputPort(FwIndexType portNum) const
The type of a start packet.
void log_WARNING_HI_FileWriteError_ThrottleClear()
Reset throttle value for FileWriteError.
U32 getValue() const
Get the checksum value.
FileUplink(const char *const name)
FwSizeType getSize() const
SerializeStatus fromBuffer(const Buffer &buffer)
Auto-generated base for FileUplink component.
void log_WARNING_HI_InvalidPacketReceived(FwPacketDescriptorType packetType) const
Operation was successful.
PlatformIndexType FwIndexType
FwSizeType SizeType
The size type for a buffer - for backwards compatibility.
void fileAnnounce_out(FwIndexType portNum, Fw::StringBase &file_name) const
Invoke output port fileAnnounce.
void configure(const char *directory)
RateGroupDivider component implementation.
void log_WARNING_HI_PacketOutOfBounds_ThrottleClear()
Reset throttle value for PacketOutOfBounds.
The type of an end packet.