Skip to content

Commit

Permalink
Added masked_write_register to sync client. (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagliughi authored Sep 29, 2024
1 parent 8e807b8 commit da3be0b
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 da3be0b

Please sign in to comment.