Fix potential busy loop with short timeouts (#9320)
This commit is contained in:
parent
7a314c79ee
commit
d883a1bfe1
4 changed files with 6 additions and 6 deletions
|
|
@ -104,7 +104,7 @@ func NewDaheimLadenMB(uri string, id uint8) (api.Charger, error) {
|
|||
return nil, fmt.Errorf("failsafe timeout: %w", err)
|
||||
}
|
||||
if u := binary.BigEndian.Uint16(b); u > 0 {
|
||||
go wb.heartbeat(time.Duration(u/2) * time.Second)
|
||||
go wb.heartbeat(time.Duration(u) * time.Second / 2)
|
||||
}
|
||||
|
||||
return wb, err
|
||||
|
|
|
|||
|
|
@ -117,11 +117,11 @@ func NewKebaFromConfig(other map[string]interface{}) (api.Charger, error) {
|
|||
// failsafe
|
||||
b, err = wb.conn.ReadHoldingRegisters(kebaRegFailsafeTimeout, 2)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failsafe timeout: %w", err)
|
||||
}
|
||||
|
||||
if timeout := binary.BigEndian.Uint32(b); timeout > 0 {
|
||||
go wb.heartbeat(900 * time.Millisecond * time.Duration(timeout))
|
||||
if u := binary.BigEndian.Uint32(b); u > 0 {
|
||||
go wb.heartbeat(time.Duration(u) * time.Second / 2)
|
||||
}
|
||||
|
||||
return decorateKeba(wb, currentPower, totalEnergy, currents, identify, phases), nil
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ func NewObo(uri, device, comset string, baudrate int, proto modbus.Protocol, sla
|
|||
return nil, fmt.Errorf("failsafe timeout: %w", err)
|
||||
}
|
||||
if u := binary.BigEndian.Uint16(b); u > 0 {
|
||||
go wb.heartbeat(time.Duration(u/2) * time.Millisecond)
|
||||
go wb.heartbeat(time.Duration(u) * time.Millisecond / 2)
|
||||
}
|
||||
|
||||
// lightshow
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ func NewWebastoNext(uri string, id uint8) (api.Charger, error) {
|
|||
return nil, fmt.Errorf("failsafe timeout: %w", err)
|
||||
}
|
||||
if u := binary.BigEndian.Uint16(b); u > 0 {
|
||||
go wb.heartbeat(time.Duration(u/2) * time.Second)
|
||||
go wb.heartbeat(time.Duration(u) * time.Second / 2)
|
||||
}
|
||||
|
||||
return wb, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue