Skip to content

Commit

Permalink
Fix large number for int32 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
GJSBRT committed Apr 9, 2024
1 parent 518d16b commit e95d151
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modbus/modbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,17 @@ func (m *Modbus) updateMetricsRegisters(connection *Connection, inverter Inverte
return err
}

res = int32(reg)
if reg > 9999999 {
regBytes, err := connection.client.ReadBytes(register.Address, register.Quantity * 2, modbus.HOLDING_REGISTER)
if err != nil {
return err
}

res = int32(convertTooLargeNumber(regBytes))
} else {
res = int32(reg)
}

result = int(res)
}

Expand Down

0 comments on commit e95d151

Please sign in to comment.