Skip to main content

SbfHeader

Struct SbfHeader 

Source
pub struct SbfHeader {
    pub crc: u16,
    pub block_id: u16,
    pub block_rev: u8,
    pub length: u16,
    pub tow_ms: u32,
    pub wnc: u16,
}
Expand description

SBF block header

Fields§

§crc: u16

CRC-16 checksum

§block_id: u16

Block ID (13 bits)

§block_rev: u8

Block revision (3 bits)

§length: u16

Total block length (including header)

§tow_ms: u32

Time of week in milliseconds (0xFFFFFFFF if not available)

§wnc: u16

GPS week number (0xFFFF if not available)

Implementations§

Source§

impl SbfHeader

Source

pub fn parse(data: &[u8]) -> SbfResult<Self>

Parse header from bytes (starting after sync bytes)

§Arguments
  • data - Data starting from CRC field (after 0x24 0x40 sync)
§Returns

Parsed header or error

Source

pub fn parse_from_block(block_data: &[u8]) -> SbfResult<Self>

Parse header from complete block data (including sync bytes)

§Arguments
  • block_data - Complete block data starting with sync bytes
§Returns

Parsed header or error

Source

pub fn validate_crc(&self, block_data: &[u8]) -> SbfResult<()>

Validate CRC against block data

§Arguments
  • block_data - Complete block data starting with sync bytes
§Returns

Ok(()) if CRC is valid, Err(SbfError::CrcMismatch) otherwise

Source

pub fn tow_seconds(&self) -> Option<f64>

Get TOW in seconds (scaled from milliseconds)

Returns None if TOW is not available (0xFFFFFFFF)

Source

pub fn tow_ms_raw(&self) -> Option<u32>

Get raw TOW in milliseconds

Returns None if TOW is not available (0xFFFFFFFF)

Source

pub fn week_number(&self) -> Option<u16>

Get week number

Returns None if WNc is not available (0xFFFF)

Source

pub fn has_valid_time(&self) -> bool

Check if time fields are valid

Source

pub const fn body_offset() -> usize

Get body offset (where block-specific data starts)

Most blocks have TOW (4 bytes) + WNc (2 bytes) after the 8-byte header, so body starts at offset 14 from block start, or offset 12 from CRC.

Trait Implementations§

Source§

impl Clone for SbfHeader

Source§

fn clone(&self) -> SbfHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SbfHeader

Source§

impl Debug for SbfHeader

Source§

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

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

impl Display for SbfHeader

Source§

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

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

impl Eq for SbfHeader

Source§

impl PartialEq for SbfHeader

Source§

fn eq(&self, other: &SbfHeader) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SbfHeader

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.