Skip to content

Commit

Permalink
Heidelberg: fix locking (#4117)
Browse files Browse the repository at this point in the history
  • Loading branch information
premultiply authored Aug 23, 2022
1 parent b40f435 commit 0aa9b01
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions charger/heidelberg-ec.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ func (wb *HeidelbergEC) Status() (api.ChargeStatus, error) {
case 9:
return api.StatusE, nil
case 10:
// ensure RemoteLock is disabled after wake-up
l, err := wb.conn.ReadInputRegisters(hecRegRemoteLock, 1)
if err != nil {
return api.StatusNone, err
}
if binary.BigEndian.Uint16(l) != 1 {
// unlock
err = wb.set(hecRegRemoteLock, 1)
if err != nil {
return api.StatusNone, err
}
}

if wb.wakeup {
// keep status B2 during wakeup
return api.StatusB, nil
Expand Down Expand Up @@ -273,13 +286,14 @@ var _ api.Resurrector = (*HeidelbergEC)(nil)
// WakeUp implements the api.Resurrector interface
func (wb *HeidelbergEC) WakeUp() error {
// force status F by locking
err := wb.set(hecRegRemoteLock, 0)
if err == nil {
// Always takes at least ~10 sec to return to normal operation
if wb.set(hecRegRemoteLock, 0) == nil {
// Takes at least ~10 sec to return to normal operation
// after locking even if unlocking immediately.
wb.wakeup = true
// return to normal operation by unlocking after ~10 sec
err = wb.set(hecRegRemoteLock, 1)
}

// return to normal operation by unlocking after ~10 sec
err := wb.set(hecRegRemoteLock, 1)

return err
}

0 comments on commit 0aa9b01

Please sign in to comment.