ModbusTcpClient

Struct ModbusTcpClient 

Source
pub struct ModbusTcpClient { /* private fields */ }
Expand description

Modbus TCP client implementation using the generic client

Implementations§

Source§

impl ModbusTcpClient

Source

pub async fn new(addr: SocketAddr, timeout: Duration) -> ModbusResult<Self>

Create a new TCP client

Source

pub async fn with_logging( addr: &str, timeout: Duration, logger: Option<CallbackLogger>, ) -> ModbusResult<Self>

Create a new TCP client with logging

Source

pub async fn from_address(addr: &str, timeout: Duration) -> ModbusResult<Self>

Create a new TCP client from address string

Source

pub fn from_transport(transport: TcpTransport) -> Self

Create a new TCP client from transport

Source

pub fn server_address(&self) -> SocketAddr

Get the server address

Source

pub fn set_packet_logging(&mut self, enabled: bool)

Enable or disable packet logging on existing client

Source

pub async fn execute_request( &mut self, request: ModbusRequest, ) -> ModbusResult<ModbusResponse>

Execute a raw request

Trait Implementations§

Source§

impl ModbusClient for ModbusTcpClient

Source§

async fn read_01( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> ModbusResult<Vec<bool>>

Read coils (function code 0x01). Read more
Source§

async fn read_02( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> ModbusResult<Vec<bool>>

Read discrete inputs (function code 0x02). Read more
Source§

async fn read_03( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> ModbusResult<Vec<u16>>

Read holding registers (function code 0x03). Read more
Source§

async fn read_04( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> ModbusResult<Vec<u16>>

Read input registers (function code 0x04). Read more
Source§

async fn write_05( &mut self, slave_id: SlaveId, address: u16, value: bool, ) -> ModbusResult<()>

Write single coil (function code 0x05). Read more
Source§

async fn write_06( &mut self, slave_id: SlaveId, address: u16, value: u16, ) -> ModbusResult<()>

Write single register (function code 0x06). Read more
Source§

async fn write_0f( &mut self, slave_id: SlaveId, address: u16, values: &[bool], ) -> ModbusResult<()>

Write multiple coils (function code 0x0F). Read more
Source§

async fn write_10( &mut self, slave_id: SlaveId, address: u16, values: &[u16], ) -> ModbusResult<()>

Write multiple registers (function code 0x10). Read more
Source§

fn is_connected(&self) -> bool

Check if the client is connected. Read more
Source§

async fn close(&mut self) -> ModbusResult<()>

Close the client connection. Read more
Source§

fn get_stats(&self) -> TransportStats

Get transport statistics. Read more
Source§

fn read_coils( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> impl Future<Output = ModbusResult<Vec<bool>>> + Send

Alias for read_01 - Read coils
Source§

fn read_discrete_inputs( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> impl Future<Output = ModbusResult<Vec<bool>>> + Send

Alias for read_02 - Read discrete inputs
Source§

fn read_holding_registers( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> impl Future<Output = ModbusResult<Vec<u16>>> + Send

Alias for read_03 - Read holding registers
Source§

fn read_input_registers( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> impl Future<Output = ModbusResult<Vec<u16>>> + Send

Alias for read_04 - Read input registers
Source§

fn write_single_coil( &mut self, slave_id: SlaveId, address: u16, value: bool, ) -> impl Future<Output = ModbusResult<()>> + Send

Alias for write_05 - Write single coil
Source§

fn write_single_register( &mut self, slave_id: SlaveId, address: u16, value: u16, ) -> impl Future<Output = ModbusResult<()>> + Send

Alias for write_06 - Write single register
Source§

fn write_multiple_coils( &mut self, slave_id: SlaveId, address: u16, values: &[bool], ) -> impl Future<Output = ModbusResult<()>> + Send

Alias for write_0f - Write multiple coils
Source§

fn write_multiple_registers( &mut self, slave_id: SlaveId, address: u16, values: &[u16], ) -> impl Future<Output = ModbusResult<()>> + Send

Alias for write_10 - Write multiple registers

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more