pub struct ModbusTcpClient { /* private fields */ }Expand description
Modbus TCP client implementation using the generic client
Implementations§
Source§impl ModbusTcpClient
impl ModbusTcpClient
Sourcepub async fn new(addr: SocketAddr, timeout: Duration) -> ModbusResult<Self>
pub async fn new(addr: SocketAddr, timeout: Duration) -> ModbusResult<Self>
Create a new TCP client
Sourcepub async fn with_logging(
addr: &str,
timeout: Duration,
logger: Option<CallbackLogger>,
) -> ModbusResult<Self>
pub async fn with_logging( addr: &str, timeout: Duration, logger: Option<CallbackLogger>, ) -> ModbusResult<Self>
Create a new TCP client with logging
Sourcepub async fn from_address(addr: &str, timeout: Duration) -> ModbusResult<Self>
pub async fn from_address(addr: &str, timeout: Duration) -> ModbusResult<Self>
Create a new TCP client from address string
Sourcepub fn from_transport(transport: TcpTransport) -> Self
pub fn from_transport(transport: TcpTransport) -> Self
Create a new TCP client from transport
Sourcepub fn server_address(&self) -> SocketAddr
pub fn server_address(&self) -> SocketAddr
Get the server address
Sourcepub fn set_packet_logging(&mut self, enabled: bool)
pub fn set_packet_logging(&mut self, enabled: bool)
Enable or disable packet logging on existing client
Sourcepub async fn execute_request(
&mut self,
request: ModbusRequest,
) -> ModbusResult<ModbusResponse>
pub async fn execute_request( &mut self, request: ModbusRequest, ) -> ModbusResult<ModbusResponse>
Execute a raw request
Trait Implementations§
Source§impl ModbusClient for ModbusTcpClient
impl ModbusClient for ModbusTcpClient
Source§async fn read_01(
&mut self,
slave_id: SlaveId,
address: u16,
quantity: u16,
) -> ModbusResult<Vec<bool>>
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>>
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>>
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>>
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<()>
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<()>
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<()>
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<()>
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
fn is_connected(&self) -> bool
Check if the client is connected. Read more
Source§fn get_stats(&self) -> TransportStats
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
fn read_coils( &mut self, slave_id: SlaveId, address: u16, quantity: u16, ) -> impl Future<Output = ModbusResult<Vec<bool>>> + Send
Alias for
read_01 - Read coilsSource§fn read_discrete_inputs(
&mut self,
slave_id: SlaveId,
address: u16,
quantity: u16,
) -> impl Future<Output = ModbusResult<Vec<bool>>> + Send
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 inputsSource§fn read_holding_registers(
&mut self,
slave_id: SlaveId,
address: u16,
quantity: u16,
) -> impl Future<Output = ModbusResult<Vec<u16>>> + Send
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 registersSource§fn read_input_registers(
&mut self,
slave_id: SlaveId,
address: u16,
quantity: u16,
) -> impl Future<Output = ModbusResult<Vec<u16>>> + Send
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 registersSource§fn write_single_coil(
&mut self,
slave_id: SlaveId,
address: u16,
value: bool,
) -> impl Future<Output = ModbusResult<()>> + Send
fn write_single_coil( &mut self, slave_id: SlaveId, address: u16, value: bool, ) -> impl Future<Output = ModbusResult<()>> + Send
Alias for
write_05 - Write single coilSource§fn write_single_register(
&mut self,
slave_id: SlaveId,
address: u16,
value: u16,
) -> impl Future<Output = ModbusResult<()>> + Send
fn write_single_register( &mut self, slave_id: SlaveId, address: u16, value: u16, ) -> impl Future<Output = ModbusResult<()>> + Send
Alias for
write_06 - Write single registerSource§fn write_multiple_coils(
&mut self,
slave_id: SlaveId,
address: u16,
values: &[bool],
) -> impl Future<Output = ModbusResult<()>> + Send
fn write_multiple_coils( &mut self, slave_id: SlaveId, address: u16, values: &[bool], ) -> impl Future<Output = ModbusResult<()>> + Send
Alias for
write_0f - Write multiple coilsSource§fn write_multiple_registers(
&mut self,
slave_id: SlaveId,
address: u16,
values: &[u16],
) -> impl Future<Output = ModbusResult<()>> + Send
fn write_multiple_registers( &mut self, slave_id: SlaveId, address: u16, values: &[u16], ) -> impl Future<Output = ModbusResult<()>> + Send
Alias for
write_10 - Write multiple registersAuto Trait Implementations§
impl !Freeze for ModbusTcpClient
impl !RefUnwindSafe for ModbusTcpClient
impl Send for ModbusTcpClient
impl Sync for ModbusTcpClient
impl Unpin for ModbusTcpClient
impl !UnwindSafe for ModbusTcpClient
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