Fix UART hang after master restart from the dashboard.

ReadFrame now returns on serial timeout instead of looping forever, and
serve closes and reopens the port after a master reboot so polling and
API commands can resume.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 16:45:57 +02:00
co-authored by Cursor
parent e4ce18edd8
commit ab1844ac32
5 changed files with 44 additions and 7 deletions
+3 -3
View File
@@ -416,7 +416,7 @@ func readUartMessageUntil(sp *serialPort, deadline time.Time, want pb.MessageTyp
if err := sp.port.SetReadTimeout(wait); err != nil {
return nil, err
}
payload, err := uartframe.ReadFrame(sp.port, nil)
payload, err := uartframe.ReadFrame(sp.port, nil, wait)
if err != nil {
return nil, err
}
@@ -536,7 +536,7 @@ func waitOtaStatus(sp *serialPort, want uint32, timeout time.Duration, onPrepari
if err := sp.port.SetReadTimeout(readWait); err != nil {
return nil, err
}
payload, err := uartframe.ReadFrame(sp.port, nil)
payload, err := uartframe.ReadFrame(sp.port, nil, readWait)
if err != nil {
continue
}
@@ -562,7 +562,7 @@ func waitOtaStatus(sp *serialPort, want uint32, timeout time.Duration, onPrepari
}
func readOtaStatus(sp *serialPort) (*pb.OtaStatusPayload, error) {
payload, err := uartframe.ReadFrame(sp.port, nil)
payload, err := uartframe.ReadFrame(sp.port, nil, readTimeout)
if err != nil {
return nil, fmt.Errorf("read response: %w", err)
}