Skip to content

Commit

Permalink
fix parse_slice (#29)
Browse files Browse the repository at this point in the history
* fix parse_slice

* fix formatting
  • Loading branch information
Achtuur authored Mar 12, 2024
1 parent 3cd43b1 commit 139ea74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ impl ModbusRequest {
pub fn parse_slice<'a>(&'a self, buf: &'a [u8]) -> Result<&[u8], ErrorKind> {
let (frame_start, frame_end) = self.parse_response(buf)?;
let val = match self.func {
MODBUS_GET_COILS | MODBUS_GET_DISCRETES | MODBUS_GET_HOLDINGS | MODBUS_GET_INPUTS => {
MODBUS_SET_COIL
| MODBUS_SET_COILS_BULK
| MODBUS_SET_HOLDING
| MODBUS_SET_HOLDINGS_BULK => {
// no data bytes count byte -> skip 1 fewer byte
&buf[frame_start + 2..frame_end]
}
Expand Down

0 comments on commit 139ea74

Please sign in to comment.