fix(spe): drop the link on power-off so status shows off and ON works
Switching an SPE amp off left the already-open connection reading as connected (the amp stops answering once off, but the stale open handle kept the status at "connected"), so the panel never showed OFF and PowerOn — which only wakes a DISCONNECTED amp, and must NOT pulse RTS/DTR on a running one — did nothing until the operator restarted OpsLog. PowerOff now drops the connection and marks the amp offline, exactly as a fresh start would; the poll's plain reopen never wakes a switched-off amp, so it stays off until the ON button's RTS/DTR edge.
This commit is contained in:
@@ -228,6 +228,18 @@ func (c *Client) PowerOn() error {
|
||||
func (c *Client) PowerOff() error {
|
||||
err := c.sendCmd(cmdOff)
|
||||
applog.Printf("spe: power OFF — SWITCH OFF key sent (err=%v)", err)
|
||||
// Drop the link and mark the amp offline at once, exactly as a fresh start
|
||||
// would see it. The amp stops answering its UART once off, but the connection
|
||||
// that was already open BEFORE the off keystroke kept reading as "connected"
|
||||
// (stale/queued frames), so the UI never showed OFF and PowerOn — which only
|
||||
// wakes a DISCONNECTED amp — did nothing until the operator restarted OpsLog.
|
||||
// The poll loop reopens the port on its next tick; a plain reopen never wakes a
|
||||
// switched-off amp (only PowerOn's RTS/DTR edge does), so it stays offline.
|
||||
time.Sleep(100 * time.Millisecond) // let the 6-byte OFF command flush before we close
|
||||
c.mu.Lock()
|
||||
c.dropLocked()
|
||||
c.mu.Unlock()
|
||||
c.setErr(fmt.Errorf("switched off"))
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user