Skip to main content

Bus

Struct Bus 

Source
pub struct Bus<P> { /* private fields */ }
Available on crate feature std only.
Expand description

A wired M-Bus behind a port.

Implementations§

Source§

impl<P: Read + Write> Bus<P>

Source

pub fn new(port: P, baud: Baud) -> Self

A bus at baud (the baud rate the port is opened with), with 50 ms of slack on every response timeout for USB and network latency.

Source

pub const fn slack(self, slack: Duration) -> Self

Extra time added to every response timeout: more for a gateway on the network, zero for a UART on the same board.

Source

pub fn port_mut(&mut self) -> &mut P

The port, e.g. to change its baud rate after master::set_baud.

Source

pub fn into_inner(self) -> P

The port back.

Source

pub fn readout(&mut self, target: Target) -> Result<Vec<Telegram>, Error>

Read every telegram of one meter. Anything but a complete readout is an error (Error::Incomplete).

Source

pub fn run_readout(&mut self, readout: Readout) -> Result<Vec<Telegram>, Error>

Read every telegram with a configured Readout (retries, telegram limit, expected meter). Ok only when the readout is complete.

Source

pub fn search(&mut self) -> Result<Found, Error>

Find every meter on the bus by secondary address (wildcard search). Each selection waits for the whole response window, so colliding replies are seen.

Search with a configured Search (selection limit).

Source

pub fn command(&mut self, request: &Request) -> Result<bool, Error>

Send a command and wait for its acknowledgement: Ok(true) on E5, Ok(false) when nothing (or something else) came back. A broadcast is Ok(true) unread.

Trait Implementations§

Source§

impl<P: Debug> Debug for Bus<P>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P> Forget for Bus<P>

§

impl<P> Freeze for Bus<P>
where P: Freeze,

§

impl<P> Move for Bus<P>

§

impl<P> RefUnwindSafe for Bus<P>
where P: RefUnwindSafe,

§

impl<P> Send for Bus<P>
where P: Send,

§

impl<P> Sync for Bus<P>
where P: Sync,

§

impl<P> Unpin for Bus<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Bus<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for Bus<P>
where P: UnwindSafe,

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.