fix(ultrabeam): accept an 11-byte status frame from older controllers

An older controller behind an RS232-to-Ethernet bridge returns the status frame
without its trailing FreqMax byte (11 bytes, not 12). The packet checksum is
still valid, so it's a real short frame, not a fragment. queryStatus now accepts
>= 10 bytes and defaults the missing FreqMin/FreqMax rather than rejecting it as
"too short", which reconnect-looped the link. Whether the byte LAYOUT is
otherwise identical across controller versions still needs confirming from the
protocol reference.
This commit is contained in:
2026-08-05 14:49:52 +02:00
parent 7e696a72bb
commit 16e64fd7b7
2 changed files with 17 additions and 5 deletions
+13 -3
View File
@@ -509,7 +509,13 @@ func (c *Client) queryStatus() (*Status, error) {
return nil, err
}
if len(reply) < 12 {
// An older controller — seen behind an RS232-to-Ethernet bridge — answers with
// an 11-byte status frame: the standard one WITHOUT the trailing FreqMax byte.
// The packet checksum was already verified, so a short-but-valid frame is real,
// not a fragment. Accept it and default the missing tail fields instead of
// reconnect-looping on "reply too short". reply[9]/[10] (MotorsMoving, FreqMin)
// are the last we truly need, so 10 bytes is the floor.
if len(reply) < 10 {
return nil, fmt.Errorf("status reply too short: %d bytes", len(reply))
}
@@ -522,8 +528,12 @@ func (c *Client) queryStatus() (*Status, error) {
Direction: int(reply[6] & 0x0F),
OffState: (reply[7] & 0x02) != 0,
MotorsMoving: int(reply[9]),
FreqMin: int(reply[10]),
FreqMax: int(reply[11]),
}
if len(reply) > 10 {
status.FreqMin = int(reply[10])
}
if len(reply) > 11 {
status.FreqMax = int(reply[11])
}
return status, nil