Skip to main content

Telemetry

Struct Telemetry 

Source
#[repr(C)]
pub struct Telemetry { pub primary: PrimaryHeader, pub secondary: TelemetrySecondaryHeader, pub payload: [u8], }
Expand description

A zero-copy view over a complete CFE telemetry packet (headers + payload). This is the primary struct you will use to represent telemetry.

+------------------------------------+---------+
| Field Name                         | Size    |
+------------------------------------+---------+
+ -- Primary Header (6 bytes) ------ | ------- |
|                                    |         |
| - Packet Type is always Telemetry  |         |
| - Sec. Hdr. Flag is always Present |         |
|                                    |         |
+ -- cFE Secondary Header (2 bytes)  | ------- |
|                                    |         |
| Time                               | 6 bytes |
| Spare                              | 4 bytes |
|                                    |         |
+ -- User Data Field (Variable) ---- | ------- |
|                                    |         |
| Payload                            | 1-65534 |
|                                    | bytes   |
+------------------------------------+---------+

Fields§

§primary: PrimaryHeader

CCSDS SPP primary header.

§secondary: TelemetrySecondaryHeader

CFE telemetry secondary header containing timestamp.

§payload: [u8]

Variable-length telemetry payload.

Implementations§

Source§

impl Telemetry

Source

pub fn time(&self) -> u64

6-byte CCSDS Day Segmented (CDS) time value.

Source

pub fn set_time(&mut self, time: u64) -> Result<(), TelemetryError>

Sets the 6-byte time value, returning an error if out of range.

Source

pub fn payload(&self) -> &[u8]

Returns the telemetry payload bytes.

Source

pub fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the telemetry payload bytes.

Source

pub fn parse<'a>(bytes: &'a [u8]) -> Result<&'a Telemetry, TelemetryError>

Parses a byte slice as a CFE telemetry packet.

Source

pub fn builder<'a>() -> TelemetryBuilder<'a>

Creates a new telemetry packet view over the provided buffer.

Methods from Deref<Target = SpacePacket>§

Source

pub fn set_data_field<T: SpacePacketData>( &mut self, data: &T, ) -> Result<(), DataFieldError>

Copies a user-defined data structure into the packet’s data field.

The size of T must exactly match the length of the data field.

Source

pub fn data_as<T: SpacePacketData>(&self) -> Result<&T, DataFieldError>

Returns a zero-copy, typed view of the packet’s data field.

This is the primary method for interpreting the packet’s payload as a specific data structure. It will fail if the size of T does not match the data field’s length.

Source

pub fn data_field(&self) -> &[u8]

Returns an immutable slice of the packet’s data field.

Source

pub fn data_field_mut(&mut self) -> &mut [u8]

Returns a mutable slice of the packet’s data field.

Warning: Modifying the data field directly will invalidate any CRC checksum. If using a CrcSpacePacket, prefer the safe set_data() method instead.

Methods from Deref<Target = PrimaryHeader>§

Source

pub fn version(&self) -> PacketVersion

Returns the 3-bit packet version number.

Source

pub fn set_version(&mut self, version: PacketVersion)

Sets the 3-bit packet version number.

Source

pub fn packet_type(&self) -> PacketType

Returns the PacketType (Telemetry or Telecommand).

Source

pub fn set_packet_type(&mut self, packet_type: PacketType)

Sets the PacketType (Telemetry or Telecommand).

Source

pub fn secondary_header_flag(&self) -> SecondaryHeaderFlag

Returns the SecondaryHeader flag (Present or Absent).

Source

pub fn set_secondary_header_flag(&mut self, flag: SecondaryHeaderFlag)

Sets the SecondaryHeader flag (Present or Absent).

Source

pub fn apid(&self) -> Apid

Returns the 11-bit Application Process Identifier (Apid).

Source

pub fn set_apid(&mut self, apid: Apid)

Sets the 11-bit Application Process Identifier (Apid).

Source

pub fn sequence_flag(&self) -> SequenceFlag

Returns the 2-bit SequenceFlag.

Source

pub fn set_sequence_flag(&mut self, flag: SequenceFlag)

Sets the 2-bit SequenceFlag.

Source

pub fn sequence_count(&self) -> SequenceCount

Returns the 14-bit packet sequence count.

Source

pub fn set_sequence_count(&mut self, count: SequenceCount)

Sets the 14-bit SequenceCount.

Source

pub fn data_field_len(&self) -> usize

Returns the length of the data field in bytes as specified by the header.

Source

pub fn set_data_field_len(&mut self, len: u16)

Sets the length of the data field in bytes. The value written to the header will be len - 1 as per the CCSDS standard.

Source

pub fn packet_len(&self) -> usize

Returns the total length of the packet (header + data field) in bytes.

Source

pub fn cfe_msg_id(&self) -> u16

Reconstructs the CFE-style Message ID (MsgId) from the primary header fields.

This is a crucial convenience function for systems that interact with the cFE Software Bus (SB). The SB uses a single integer MsgId for routing, which is a composite value created from several fields in the CCSDS header.

A cFE MsgId is 16-bit integer with the following structure:

+-----------------+------+-----------------------------------------+
| Field           | Size | Description                             |
+-----------------+------+-----------------------------------------+
| APID            | 11   | The 11-bit Application Process ID.      |
| SB Flag         | 1    | 1 indicates a Software Bus message.     |
| Type            | 1    | 0 for Telemetry, 1 for Telecommand.     |
| Reserved        | 3    | Unused, should be zero.                 |
+-----------------+------+-----------------------------------------+

Trait Implementations§

Source§

impl Debug for Telemetry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for Telemetry

Source§

type Target = SpacePacket

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Telemetry

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl FromBytes for Telemetry
where PrimaryHeader: FromBytes, TelemetrySecondaryHeader: FromBytes, [u8]: FromBytes,

§

fn ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the given source as a &Self. Read more
§

fn ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout + Immutable,

Interprets the prefix of the given source as a &Self without copying. Read more
§

fn ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: Immutable + KnownLayout,

Interprets the suffix of the given bytes as a &Self. Read more
§

fn mut_from_bytes( source: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the given source as a &mut Self. Read more
§

fn mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the prefix of the given source as a &mut Self without copying. Read more
§

fn mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout,

Interprets the suffix of the given source as a &mut Self without copying. Read more
§

fn ref_from_bytes_with_elems( source: &[u8], count: usize, ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the given source as a &Self with a DST length equal to count. Read more
§

fn ref_from_prefix_with_elems( source: &[u8], count: usize, ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the prefix of the given source as a DST &Self with length equal to count. Read more
§

fn ref_from_suffix_with_elems( source: &[u8], count: usize, ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the suffix of the given source as a DST &Self with length equal to count. Read more
§

fn mut_from_bytes_with_elems( source: &mut [u8], count: usize, ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize> + Immutable,

Interprets the given source as a &mut Self with a DST length equal to count. Read more
§

fn mut_from_prefix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize>,

Interprets the prefix of the given source as a &mut Self with DST length equal to count. Read more
§

fn mut_from_suffix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>
where Self: IntoBytes + KnownLayout<PointerMetadata = usize>,

Interprets the suffix of the given source as a &mut Self with DST length equal to count. Read more
Source§

impl FromZeros for Telemetry
where PrimaryHeader: FromZeros, TelemetrySecondaryHeader: FromZeros, [u8]: FromZeros,

§

fn zero(&mut self)

Overwrites self with zeros. Read more
Source§

impl IntoBytes for Telemetry
where PrimaryHeader: IntoBytes, TelemetrySecondaryHeader: IntoBytes, [u8]: IntoBytes, (): DynamicPaddingFree<Self, { _ }>,

§

fn as_bytes(&self) -> &[u8]
where Self: Immutable,

Gets the bytes of this value. Read more
§

fn as_mut_bytes(&mut self) -> &mut [u8]
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
§

fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to dst. Read more
§

fn write_to_prefix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the prefix of dst. Read more
§

fn write_to_suffix( &self, dst: &mut [u8], ) -> Result<(), SizeError<&Self, &mut [u8]>>
where Self: Immutable,

Writes a copy of self to the suffix of dst. Read more
Source§

impl KnownLayout for Telemetry
where [u8]: KnownLayout,

Source§

type PointerMetadata = <[u8] as KnownLayout>::PointerMetadata

The type of metadata stored in a pointer to Self. Read more
§

fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>

Computes the size of an object of type Self with the given pointer metadata. Read more
Source§

impl<'a> TryFrom<&'a SpacePacket> for &'a Telemetry

Source§

type Error = TelemetryError

The type returned in the event of a conversion error.
Source§

fn try_from(sp: &'a SpacePacket) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFromBytes for Telemetry
where PrimaryHeader: TryFromBytes, TelemetrySecondaryHeader: TryFromBytes, [u8]: TryFromBytes,

§

fn try_ref_from_bytes( source: &[u8], ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the given source as a &Self. Read more
§

fn try_ref_from_prefix( source: &[u8], ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the prefix of the given source as a &Self. Read more
§

fn try_ref_from_suffix( source: &[u8], ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout + Immutable,

Attempts to interpret the suffix of the given source as a &Self. Read more
§

fn try_mut_from_bytes( bytes: &mut [u8], ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the given source as a &mut Self without copying. Read more
§

fn try_mut_from_prefix( source: &mut [u8], ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the prefix of the given source as a &mut Self. Read more
§

fn try_mut_from_suffix( source: &mut [u8], ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout + IntoBytes,

Attempts to interpret the suffix of the given source as a &mut Self. Read more
§

fn try_ref_from_bytes_with_elems( source: &[u8], count: usize, ) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Attempts to interpret the given source as a &Self with a DST length equal to count. Read more
§

fn try_ref_from_prefix_with_elems( source: &[u8], count: usize, ) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Attempts to interpret the prefix of the given source as a &Self with a DST length equal to count. Read more
§

fn try_ref_from_suffix_with_elems( source: &[u8], count: usize, ) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + Immutable,

Attempts to interpret the suffix of the given source as a &Self with a DST length equal to count. Read more
§

fn try_mut_from_bytes_with_elems( source: &mut [u8], count: usize, ) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + IntoBytes,

Attempts to interpret the given source as a &mut Self with a DST length equal to count. Read more
§

fn try_mut_from_prefix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + IntoBytes,

Attempts to interpret the prefix of the given source as a &mut Self with a DST length equal to count. Read more
§

fn try_mut_from_suffix_with_elems( source: &mut [u8], count: usize, ) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>
where Self: KnownLayout<PointerMetadata = usize> + IntoBytes,

Attempts to interpret the suffix of the given source as a &mut Self with a DST length equal to count. Read more
Source§

impl Immutable for Telemetry
where PrimaryHeader: Immutable, TelemetrySecondaryHeader: Immutable, [u8]: Immutable,

Source§

impl Unaligned for Telemetry
where PrimaryHeader: Unaligned, TelemetrySecondaryHeader: Unaligned, [u8]: Unaligned,

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.