From c9392ca1c02ac094007207e59d929bfa512a2c12 Mon Sep 17 00:00:00 2001 From: fpagliughi Date: Thu, 26 Sep 2024 12:00:28 -0400 Subject: [PATCH] Added masked_write_register to sync client. --- src/client/sync/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/client/sync/mod.rs b/src/client/sync/mod.rs index a68f0b3a..2c1e10c4 100644 --- a/src/client/sync/mod.rs +++ b/src/client/sync/mod.rs @@ -71,6 +71,8 @@ pub trait Writer: Client { fn write_multiple_coils(&mut self, addr: Address, coils: &[Coil]) -> Result<()>; fn write_single_register(&mut self, addr: Address, word: Word) -> Result<()>; fn write_multiple_registers(&mut self, addr: Address, words: &[Word]) -> Result<()>; + fn masked_write_register(&mut self, addr: Address, and_mask: Word, or_mask: Word) + -> Result<()>; } /// A synchronous Modbus client context. @@ -193,4 +195,18 @@ impl Writer for Context { self.async_ctx.write_multiple_coils(addr, data), ) } + + fn masked_write_register( + &mut self, + addr: Address, + and_mask: Word, + or_mask: Word, + ) -> Result<()> { + block_on_with_timeout( + &self.runtime, + self.timeout, + self.async_ctx + .masked_write_register(addr, and_mask, or_mask), + ) + } }