Skip to content

Commit

Permalink
Added masked_write_register to sync client.
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi committed Sep 26, 2024
1 parent f68a4a3 commit c9392ca
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/client/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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),
)
}
}

0 comments on commit c9392ca

Please sign in to comment.