This commit is contained in:
PopCorn
2025-11-13 22:28:48 +08:00
parent 0377201fc9
commit d5e9ce78d9
3 changed files with 60 additions and 58 deletions

View File

@@ -1188,15 +1188,9 @@ func (mc *ModbusClient) readRegistersWithFunctionCode(addr uint16, quantity uint
unitId: mc.unitId,
}
// if functionCode != fcCustomize {
// err = ErrUnexpectedParameters
// mc.logger.Errorf("unexpected function code (%d)", functionCode)
// return
// }
if functionCode == 0 {
if functionCode != fcCustomize {
err = ErrUnexpectedParameters
mc.logger.Errorf("unexpected register type (%v)", functionCode)
mc.logger.Errorf("unexpected function code (%d)", functionCode)
return
}
@@ -1208,7 +1202,8 @@ func (mc *ModbusClient) readRegistersWithFunctionCode(addr uint16, quantity uint
return
}
if quantity > 1024 {
// 16 * 16 * 40
if quantity > 10240 {
err = ErrUnexpectedParameters
mc.logger.Error("quantity of registers exceeds 1024")
return