F´ Flight Software - C/C++ Documentation
devel
A framework for building embedded system applications to NASA flight quality standards.
|
The FramingProtocol
library defines the interfaces to the framing and deframing protocols used by the Svc::Framer
and Svc::Deframer
components. Svc::Framer
uses a framing protocol to wrap data in frames for transmission to the ground. Svc::Deframer
uses a deframing protocol to extract data from frames received from the ground. The FramingProtocol
library allows each of these components to operate with any one of several protocols. Each protocol corresponds to a different implementation of an interface provided by this library.
This library implements default F' protocols that work with the F' Ground Data System (GDS). The F' protocols use the following frame format: frame header, data, hash value. A frame header consists of a four-byte start word 0xDEADBEEF
and a four byte data size. The hash value is defined by the Utils::Hash
library.
Users may provide new protocols by implementing the abstract classes defined in the FramingProtocol
library.
Requirement | Description | Verification Method |
---|---|---|
Svc-FramingProtocol-001 | Svc::FramingProtocol shall provide the interface to a protocol for wrapping data in frames for transmission to the ground | Unit test |
Svc-FramingProtocol-002 | Svc::FramingProtocol shall provide the interface to a protocol for extracting data from frames received from the ground | Unit test |
Svc-FramingProtocol-003 | Svc::FramingProtocol shall implement the framing and deframing protocols used by the F Prime GDS | Unit test |
To use the F' framing protocol, do the following:
FprimeFraming
defined in this library.Svc::Framer
component, passing the instance created in step 1 to its setup
method.For an example, see the definition of the instance downlink
at Ref/Top/instances.fpp
.
To implement and use a new framing protocol, do the following:
FramingProtocolInterface
as discussed in Section 3.1. This class defines helper operations used when framing a packet.FramingProtocol
as discussed in Section 3.1. This class defines the operation of framing a data packet.setup
method.Svc::Framer
component, passing the instance created in step 4 to its setup
method.To use the F' deframing protocol, do the following:
FprimeDeframing
defined in this library.Svc::Deframer
component, passing the instance created in step 1 to its setup
method.For an example, see the definition of the instance uplink
at Ref/Top/instances.fpp
.
To implement and use a new deframing protocol, do the following:
DeframingProtocolInterface
as discussed in Section 3.2. This class defines helper operations used when deframing a framed packet.DeframingProtocol
as discussed in Section 3.2. This class defines the operation of deframing a framed packet.setup
method.Svc::Deframer
component, passing the instance created in step 4 to its setup
method.To implement a framing protocol, do the following:
FramingProtocolInterface
.FramingProtocol
.Implementations of the framing protocol are allowed to produce zero or one frame for each incoming packet. Producing zero packets is useful when aggregating packets into a larger frame. Producing more than one packet is not permitted.
FramingProtocolInterface
defines helper methods for framing data. Typically these methods are implemented by an F Prime component (e.g., Svc::Framer
), because they require port invocations. The component Svc::Framer
provides an implementation of FramingProtocolInterface
that you can use. It does this by inheriting from FramingProtocolInterface
and implementing its abstract methods.
To implement FramingProtocolInterface
, you must implement the following pure virtual methods:
The method allocate
should accept a size in bytes and return an Fw::Buffer
that (1) points to a memory allocation of at least that size if the allocation succeeded; or (2) has size zero if the allocation failed. A typical implementation invokes a port connected to a memory allocation component.
The method send
should send the data stored in the buffer. A typical implementation invokes an Fw::BufferSend
port.
FramingProtocol
defines the operation of framing a packet. To implement FramingProtocol
, you must implement the following pure virtual method:
This method is called with the following arguments:
data
: A pointer to the data to frame.size
: The number of bytes to frame.packet_type
: The type of data to frame.The abstract class FramingProtocol
provides a protected member m_interface
. This member is a pointer, initially null. After the setup
method of FramingProtocol
is called, it points to a concrete instance of FramingProtocolInterface
.
Your implementation of frame
should do the following:
m_interface->allocate
to allocate a buffer to hold the framed data.m_interface->send
to send the buffer. m_interface->send
should be called at most once in any single invocation of frame
. Aggregating protocols may only call m_interface->send
for occasional invocations of frame
.To implement a deframing protocol, do the following:
DeframingProtocolInterface
.DeframingProtocol
.DeframingProtocolInterface
defines helper methods for deframing data. Typically these methods are implemented by an F Prime component (e.g., Svc::Deframer
), because they require port invocations. The component Svc::Deframer
provides an implementation of DeframingProtocolInterface
that you can use. It does this by inheriting from DeframingProtocolInterface
and implementing its abstract methods.
To implement DeframingProtocolInterface
, you must implement the following pure virtual methods:
The method allocate
should allocate memory, as described in Section 3.1.1.
The method route
should send (route) the data stored in the buffer. A typical implementation invokes either an Fw::Com
port (e.g., for sending commands) or a Fw::BufferSend
port (e.g., for sending file packets).
DeframingProtocol
defines the operation of deframing a packet. To implement DeframingProtocol
, you must implement the following pure virtual method:
This method is called with the following arguments:
buffer
: A circular buffer holding the data to deframe.needed
: A reference for returning the number of bytes needed for deframing.deframe
returns a value of type DeframingStatus
indicating what happened.
The abstract class DeframingProtocol
provides a protected member m_interface
. It operates as described in Section 3.1.2.
Your implementation of deframe
should do the following:
m_interface->allocate
to allocate an Fw::Buffer
to hold the deframed data.m_interface->route
to send the buffer.needed
to record the number of bytes needed.The F Prime framing protocol operates as follows:
packet_type
is Fw::ComPacket::FW_PACKET_UNKNOWN
, then the frame data size is the size of the provided data.The F Prime deframing protocol operates as follows:
Diagram view of DeframingProtocol:
Diagrams generated with SourceTrail
Date | Description |
---|---|
2021-01-30 | Initial Draft |
2021-02-15 | Revised |