Struct spacepackets::SpHeader
source · pub struct SpHeader {
pub version: u8,
pub packet_id: PacketId,
pub psc: PacketSequenceCtrl,
pub data_len: u16,
}Expand description
Space Packet Primary Header according to CCSDS 133.0-B-2.
§Arguments
version- CCSDS version field, occupies the first 3 bits of the raw header. Will generally be set to 0b000 in all constructors provided by this crate.packet_id- Packet Identifier, which can also be used as a start marker. Occupies the last 13 bits of the first two bytes of the raw headerpsc- Packet Sequence Control, occupies the third and fourth byte of the raw headerdata_len- Data length field occupies the fifth and the sixth byte of the raw header
Fields§
§version: u8§packet_id: PacketId§psc: PacketSequenceCtrl§data_len: u16Implementations§
source§impl SpHeader
impl SpHeader
pub const fn new( packet_id: PacketId, psc: PacketSequenceCtrl, data_len: u16 ) -> Self
sourcepub fn new_from_single_fields(
ptype: PacketType,
sec_header: bool,
apid: u16,
seq_flags: SequenceFlags,
seq_count: u16,
data_len: u16
) -> Option<Self>
pub fn new_from_single_fields( ptype: PacketType, sec_header: bool, apid: u16, seq_flags: SequenceFlags, seq_count: u16, data_len: u16 ) -> Option<Self>
Create a new Space Packet Header instance which can be used to create generic Space Packets. This will return None if the APID or sequence count argument exceed MAX_APID or MAX_SEQ_COUNT respectively. The version field is set to 0b000.
sourcepub fn tm(
apid: u16,
seq_flags: SequenceFlags,
seq_count: u16,
data_len: u16
) -> Option<Self>
pub fn tm( apid: u16, seq_flags: SequenceFlags, seq_count: u16, data_len: u16 ) -> Option<Self>
Helper function for telemetry space packet headers. The packet type field will be set accordingly. The secondary header flag field is set to false.
sourcepub fn tc(
apid: u16,
seq_flags: SequenceFlags,
seq_count: u16,
data_len: u16
) -> Option<Self>
pub fn tc( apid: u16, seq_flags: SequenceFlags, seq_count: u16, data_len: u16 ) -> Option<Self>
Helper function for telemetry space packet headers. The packet type field will be set accordingly. The secondary header flag field is set to false.
sourcepub fn tm_unseg(apid: u16, seq_count: u16, data_len: u16) -> Option<Self>
pub fn tm_unseg(apid: u16, seq_count: u16, data_len: u16) -> Option<Self>
Variant of SpHeader::tm which sets the sequence flag field to SequenceFlags::Unsegmented
sourcepub fn tc_unseg(apid: u16, seq_count: u16, data_len: u16) -> Option<Self>
pub fn tc_unseg(apid: u16, seq_count: u16, data_len: u16) -> Option<Self>
Variant of SpHeader::tc which sets the sequence flag field to SequenceFlags::Unsegmented
sourcepub fn set_seq_count(&mut self, seq_count: u16) -> bool
pub fn set_seq_count(&mut self, seq_count: u16) -> bool
Returns false and fails if the sequence count exceeds MAX_SEQ_COUNT
pub fn set_seq_flags(&mut self, seq_flags: SequenceFlags)
pub fn set_sec_header_flag(&mut self)
pub fn clear_sec_header_flag(&mut self)
pub fn set_packet_type(&mut self, packet_type: PacketType)
sourcepub fn from_be_bytes(buf: &[u8]) -> Result<(Self, &[u8]), ByteConversionError>
pub fn from_be_bytes(buf: &[u8]) -> Result<(Self, &[u8]), ByteConversionError>
Create a struct from a raw slice where the fields have network endianness (big). This function also returns the remaining part of the passed slice starting past the read CCSDS header.
sourcepub fn write_to_be_bytes<'a>(
&self,
buf: &'a mut [u8]
) -> Result<&'a mut [u8], ByteConversionError>
pub fn write_to_be_bytes<'a>( &self, buf: &'a mut [u8] ) -> Result<&'a mut [u8], ByteConversionError>
Write the header to a raw buffer using big endian format. This function returns the remaining part of the passed slice starting past the written CCSDS header.
Trait Implementations§
source§impl CcsdsPacket for SpHeader
impl CcsdsPacket for SpHeader
fn ccsds_version(&self) -> u8
fn packet_id(&self) -> PacketId
fn psc(&self) -> PacketSequenceCtrl
source§fn packet_id_raw(&self) -> u16
fn packet_id_raw(&self) -> u16
source§fn ptype(&self) -> PacketType
fn ptype(&self) -> PacketType
fn is_tm(&self) -> bool
fn is_tc(&self) -> bool
source§fn sec_header_flag(&self) -> bool
fn sec_header_flag(&self) -> bool
fn seq_count(&self) -> u16
fn sequence_flags(&self) -> SequenceFlags
source§impl CcsdsPrimaryHeader for SpHeader
impl CcsdsPrimaryHeader for SpHeader
fn from_composite_fields( packet_id: PacketId, psc: PacketSequenceCtrl, data_len: u16, version: Option<u8> ) -> Self
source§impl Default for SpHeader
impl Default for SpHeader
source§fn default() -> Self
fn default() -> Self
The default function sets the sequence flag field to SequenceFlags::Unsegmented. The data length field is set to 1, which denotes an empty space packets.