[−][src]Struct arinc_429::Message
An ARINC 429 message
The bits of a message are represented exactly as transmitted on the wires, with the least significant bit transmitted first.
The label field is in the 8 least significant bits. Because the most significant digit of the label is transmitted first, the label field is in the reverse of the usual bit order.
The parity bit is the most significant bit.
Conversions
The u32::from(Message)
and Message::from(u32)
From
implementations copy bits with no
changes.
Some ARINC 429 adapters use a different representation, where the bits of the label field are
reversed from their on-wire representation. The methods Message::from_bits_label_swapped()
and
Message::bits_label_swapped()
implement this conversion.
Conversions never panic.
Examples
Create a message
let message = Message::from(0x10000056); assert_eq!(0x10000056, u32::from(message));
Label bit swapping
let message = Message::from_bits_label_swapped(0x10000056); assert_eq!(0x1000006a, u32::from(message));
Methods
impl Message
[src]
pub fn bits(&self) -> u32
[src]
Returns the bits that represent this message
pub fn bits_label_swapped(&self) -> u32
[src]
Returns the bits of this message, but with the order of the 8 label bits reversed.
pub fn from_bits_label_swapped(bits: u32) -> Self
[src]
Creates a message from a message representation with the 8 label bits reversed. The returned Message will be represented as transmitted on the wires.
pub fn check_parity(&self) -> Result<(), ParityError>
[src]
Checks the parity of this message, and returns an error if the parity is not odd
Examples
assert!(Message::from(0x0).check_parity().is_err()); assert!(Message::from(0xf03ccccc).check_parity().is_err()); assert!(Message::from(0x1).check_parity().is_ok()); assert!(Message::from(0xf13ccccc).check_parity().is_ok());
pub fn update_parity(&self) -> Message
[src]
Calculates the parity of this message and returns a new message with the parity bit (31) to the correct value
Examples
// Create a message with incorrect (even) parity let message = Message::from(0x22443300); assert_eq!(message.update_parity().bits(), 0xa2443300);
// Create a message with correct (odd) parity let message = Message::from(0x22443301); // Message should not change assert_eq!(message.update_parity(), message);
pub fn label(&self) -> Label
[src]
Returns the label of this message. This can be used to show the label as an octal number.
Examples
let message = Message::from(0x84000109); let label = message.label(); assert_eq!(format!("{:?}", label), "Label(0o220)");
let message = Message::from(0x84000180); let label = message.label(); assert_eq!(format!("{:?}", label), "Label(0o001)");
Trait Implementations
impl Default for Message
[src]
impl Clone for Message
[src]
fn clone(&self) -> Message
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Ord for Message
[src]
fn cmp(&self, other: &Message) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
impl From<u32> for Message
[src]
impl From<Message> for u32
[src]
impl Eq for Message
[src]
impl Copy for Message
[src]
impl PartialOrd<Message> for Message
[src]
fn partial_cmp(&self, other: &Message) -> Option<Ordering>
[src]
fn lt(&self, other: &Message) -> bool
[src]
fn le(&self, other: &Message) -> bool
[src]
fn gt(&self, other: &Message) -> bool
[src]
fn ge(&self, other: &Message) -> bool
[src]
impl PartialEq<Message> for Message
[src]
impl Hash for Message
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Debug for Message
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,