Skip to content

Commit

Permalink
Merge pull request #34 from Achtuur/master
Browse files Browse the repository at this point in the history
Fix count in generate_set_holdings_bulk_from_slice
  • Loading branch information
divi255 authored Aug 27, 2024
2 parents 3cf75ce + 347fd6f commit 19d936f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl ModbusRequest {
return Err(ErrorKind::OOB);
}
self.reg = reg;
self.count = u16::try_from(values.len())?;
self.count = u16::try_from((values.len() + 1) / 2)?; // count is number of u16's
self.func = MODBUS_SET_HOLDINGS_BULK;
let mut data: ModbusFrameBuf = [0; 256];
for (i, v) in values.iter().enumerate() {
Expand Down

0 comments on commit 19d936f

Please sign in to comment.