pub struct Settings {
pub baud: u32,
pub parity: Parity,
pub stop_bits: StopBits,
}Expand description
A port’s speed and character format: eight data bits, with the parity and stop bits given.
§Examples
use pamoja_hal::port::{Parity, Settings};
// A Modbus RTU meter at 9600 baud, with the even parity the protocol defaults to: one
// stop bit, and eleven bits a character.
let meter = Settings::new(9_600).with_parity(Parity::Even);
assert_eq!(meter.to_string(), "9600 8E1");
assert_eq!(meter.bits_per_character(), 11);
assert_eq!(meter.character_nanos(), 1_145_834);Fields§
§baud: u32The speed, in bits a second.
parity: ParityThe parity bit each character carries.
stop_bits: StopBitsHow many stop bits end each character.
Implementations§
Source§impl Settings
impl Settings
Sourcepub const fn with_parity(self, parity: Parity) -> Settings
pub const fn with_parity(self, parity: Parity) -> Settings
Sourcepub const fn with_stop_bits(self, stop_bits: StopBits) -> Settings
pub const fn with_stop_bits(self, stop_bits: StopBits) -> Settings
Sourcepub const fn bits_per_character(&self) -> u32
pub const fn bits_per_character(&self) -> u32
Returns the bits one character takes on the wire: a start bit, eight data bits, the parity bit if there is one, and the stop bits.
Sourcepub const fn character_nanos(&self) -> u64
pub const fn character_nanos(&self) -> u64
Returns how long one character takes on the wire, in nanoseconds, rounded up.
Trait Implementations§
impl Copy for Settings
impl Eq for Settings
impl StructuralPartialEq for Settings
Auto Trait Implementations§
impl Freeze for Settings
impl RefUnwindSafe for Settings
impl Send for Settings
impl Sync for Settings
impl Unpin for Settings
impl UnsafeUnpin for Settings
impl UnwindSafe for Settings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more