SafeClient

Struct SafeClient 

Source
pub struct SafeClient { /* private fields */ }
Available on crate feature safe-client-sync and (crate features tokio-rtu-sync or tokio-tcp-sync) only.
Expand description

Synchronous client for interacting with the R4DCB08 temperature module over Modbus.

This struct provides methods to read sensor data and configure the module’s operational parameters by wrapping tokio-modbus synchronous operations.

Implementations§

Source§

impl SafeClient

Source

pub fn new(ctx: Context) -> Self

Creates a new SafeClient with a given tokio-modbus synchronous context.

Source

pub fn from_shared(ctx: Arc<Mutex<Context>>) -> Self

Creates a new SafeClient from a shared tokio-modbus synchronous context.

Source

pub fn clone_shared(&self) -> Arc<Mutex<Context>>

Clones the shared tokio-modbus synchronous context.

Source

pub fn read_temperatures(&mut self) -> Result<Temperatures, Error>

Reads the current temperatures from all 8 available channels in degrees Celsius (°C).

Source

pub fn read_temperature_correction( &mut self, ) -> Result<TemperatureCorrection, Error>

Reads the configured temperature correction values (°C) for all 8 channels.

Source

pub fn set_temperature_correction( &mut self, channel: Channel, correction: Temperature, ) -> Result<(), Error>

Sets a temperature correction value for a specific channel.

Source

pub fn read_automatic_report(&mut self) -> Result<AutomaticReport, Error>

Reads the automatic temperature reporting interval.

Source

pub fn set_automatic_report( &mut self, report: AutomaticReport, ) -> Result<(), Error>

Sets the automatic temperature reporting interval.

Source

pub fn read_baud_rate(&mut self) -> Result<BaudRate, Error>

Reads the current Modbus communication baud rate setting from the device.

Source

pub fn set_baud_rate(&mut self, baud_rate: BaudRate) -> Result<(), Error>

Sets the Modbus communication baud rate for the device.

Source

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

Resets the R4DCB08 module to its factory default settings.

Source

pub fn read_address(&mut self) -> Result<Address, Error>

Reads the current Modbus device address (Slave ID) from the module.

Source

pub fn set_address(&mut self, new_address: Address) -> Result<(), Error>

Sets a new Modbus device address.

A successful call makes the existing Context invalid (as it still points to the old address). This function automatically updates the slave ID within its managed Context.

Trait Implementations§

Source§

impl Clone for SafeClient

Source§

fn clone(&self) -> SafeClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

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, 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.