PacketAssembly

Trait PacketAssembly 

Source
pub trait PacketAssembly {
    // Required method
    fn packet_sequence_count(
        &mut self,
        packet_type: PacketType,
        apid: Apid,
    ) -> PacketSequenceCount;

    // Provided method
    fn assemble<'a>(
        &mut self,
        packet_type: PacketType,
        apid: Apid,
        secondary_header_flag: SecondaryHeaderFlag,
        buffer: &'a mut [u8],
    ) -> Result<&'a mut SpacePacket, PacketAssemblyError> { ... }
}
Expand description

The PacketAssembly trait describes the “Packet Assembly” function from the CCSDS 133.0-B-2 Space Packet Protocol recommended standard. This function concerns the ability of some protocol entity to build Space Packets from octet strings (packet data fields). It is the sending counterpart of the PacketExtraction trait.

We deviate slightly from the strict “Packet Assembly” function definition in permitting population of the octet string only after assembly of a packet with given packet data field length. This is useful, because it means that no copy is needed to prepend the Space Packet header to the data field, which saves a memcpy.

Required Methods§

Source

fn packet_sequence_count( &mut self, packet_type: PacketType, apid: Apid, ) -> PacketSequenceCount

In practice, the primary reason that the PacketAssembly function exists is that it is a centralized manner to determine the packet sequence count of any newly-created packet. To make life easier, we require this as separate method based on which we provide a default implementation of assemble().

Implementations of this function shall also result in an appropriate update of the packet sequence count.

Provided Methods§

Source

fn assemble<'a>( &mut self, packet_type: PacketType, apid: Apid, secondary_header_flag: SecondaryHeaderFlag, buffer: &'a mut [u8], ) -> Result<&'a mut SpacePacket, PacketAssemblyError>

Generates Space Packets from octet strings. See CCSDS 133.0-B-2 Section 4.2.2 “Packet Assembly Function”. The Packet Assembly function shall itself keep track of the source sequence count of packets for a given packet identification (version, packet type, and APID), but all other elements must be provided by the service user. On top, since the Packet Assembly function is used in tandem with the Octet String service (which does not permit segmentation), the packet sequence flags shall be 0b11 (“Unsegmented”).

An error shall be returned if an empty packet data field is requested, since that indicates an error on the user input side. In all other cases, no error may be returned - though there may be cases where the packet is lost.

Implementors§