Svc/FileUplink/docs/sdd.md
FileUplink is an active F Prime component.
It manages uplink of files to the software deployment.
| Requirement | Description | Rationale | Verification Method |
|---|---|---|---|
| FPRIME-FU-001 | FileUplink shall receive file packets, assemble them into files, and store the files in the on-board non-volatile storage. | This requirement provides the capability to uplink files to the spacecraft. | Unit Test, System Test |
| FPRIME-FU-002 | FileUplink shall announce the completion of uplinked files. | This requirement provides the capability to inform other components of newly uplinked files | Unit Test, System Test |
The design of FileUplink assumes the following:
File uplink occurs by dividing files into packets
of type Fw::FilePacket.
In the nominal case of file uplink
a. Files are received one at a time. All packets of one file are received before receiving any packets of the next file.
b. Within a file, packets are received in order.
c. When the file is successfully uplinked (including verification of a valid set of packets), the file name is announced via the fileAnnounce port.
| Name | Type | Role |
|---|---|---|
timeCaller | Fw::Time | TimeGet |
tlmOut | Fw::Tlm | Telemetry |
eventOut | Fw::LogEvent | LogEvent |
| Name | Type | Kind | Purpose |
|---|---|---|---|
<a name="bufferSendIn">bufferSendIn</a> | Fw::BufferSend | async input | Receives buffers containing file packets. |
<a name="bufferSendOut">bufferSendOut</a> | Fw::BufferSend | output | Returns buffers for deallocation. |
<a name="pingIn">pingIn</a> | Svc::Ping | async input | Receives ping calls from Svc::Health for aliveness check |
<a name="pingOut">pingOut</a> | Svc::Ping | output | Returns ping request to Svc::Health to respond to liveness check |
<a name="fileAnnounce">fileAnnounce</a> | Svc::FileAnnounce | output | Announces the receipt of an uplinked file |
FileUplink maintains the following state:
<a name="receiveMode">receiveMode</a>:
One of START or DATA, recording the type of the next packet that
FileUplink expects to receive.
The initial value is START.
<a name="lastSequenceIndex">lastSequenceIndex</a>: An integer recording the sequence index of the last packet received. The initial value is zero.
<a name="writeFileDescriptor">writeFileDescriptor</a>: The file descriptor of the file, if any, that is currently open for writing.
FileUplink asynchronously receives buffers on
bufferSendIn.
Each buffer contains a file packet.
When FileUplink receives a buffer, it (a) determines the type
of the file packet in the buffer; (b) takes action as
specified in section below corresponding to the packet type; and (c)
invokes bufferSendOut
to return the buffer for deallocation.
Upon receipt of a START packet, FileUplink does the following:
If receiveMode is not START, then close the file at writeFileDescriptor and issue an InvalidReceiveMode warning.
Open the file for writing and set writeFileDescriptor.
If step 2 succeeded, then set lastSequenceIndex to zero and go to DATA mode; otherwise issue a FileOpenError warning and go to START mode.
Upon receipt of a DATA packet P, FileUplink does the following,
where I is the
sequence index
of P:
If receiveMode is not DATA, then issue an InvalidReceiveMode warning and go to START mode.
Otherwise
a. If I is not equal to lastSequenceIndex + 1, then issue a PacketOutOfOrder warning reporting lastSequenceIndex and I.
b. If the packet offset and size are in bounds for the current file, then
Using writeFileDescriptor, write the file data in the packet at offset specified in the packet.
If there was an error writing the file, then issue a FileWriteError warning.
c. Otherwise issue a PacketOutOfBounds warning.
Upon receipt of an END packet P, FileUplink does the following:
If receiveMode is DATA, then do the following, where I is the sequence index of P:
a. If I is not equal to lastSequenceIndex + 1, then issue a PacketOutOfOrder warning reporting lastSequenceIndex and I.
b. Use writeFileDescriptor to do the following:
Use the method described in § 4.1.2 of the CCSDS File Delivery Protocol (CFDP) Recommended Standard to compute the checksum value for the file.
Compare the value computed in the previous step against the checksum value in the packet. If the two values are different, then issue a BadChecksum warning.
c. Close the file.
Otherwise issue an InvalidReceiveMode warning.
Set lastSequenceIndex to zero and go to START mode.
Upon receipt of a cancel packet P, FileUplink does the following:
Set lastSequenceIndex to zero.
If receiveMode is not START, then close the file at writeFileDescriptor.
Issue an UplinkCanceled event.
Go to START mode.
See FileUplink.fpp for a list of events and telemetry.
| Checklist |
|---|
| Design |
| Code |
| Unit Test |