feat: For steppir & Ultrabeam,possibility to change each element length
This commit is contained in:
@@ -470,6 +470,27 @@ func (c *Client) queryProgress() ([]int, error) {
|
||||
return []int{total, current}, nil
|
||||
}
|
||||
|
||||
// ReadElements reads the current per-element lengths for the active band
|
||||
// (CMD_READ_BANDS). The controller is write-only for ModifyElement, so this is
|
||||
// the only way to see the current lengths — needed so the operator isn't
|
||||
// adjusting blind. The reply payload layout is not documented in the code, so we
|
||||
// LOG it verbatim (once) and parse a best guess: element lengths as 16-bit
|
||||
// little-endian values, matching how ModifyElement WRITES a length. Confirm the
|
||||
// format from the logged bytes on real hardware, then tighten the parse.
|
||||
func (c *Client) ReadElements() ([]int, error) {
|
||||
payload, err := c.sendCommand(CMD_READ_BANDS, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("Ultrabeam: READ_BANDS payload (% X) — %d bytes", payload, len(payload))
|
||||
// Best-guess parse: consecutive 16-bit LE values = element lengths in mm.
|
||||
out := make([]int, 0, len(payload)/2)
|
||||
for i := 0; i+1 < len(payload); i += 2 {
|
||||
out = append(out, int(payload[i])|int(payload[i+1])<<8)
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// SetFrequency changes frequency and optional direction (command 3)
|
||||
func (c *Client) SetFrequency(freqKhz int, direction int) error {
|
||||
// Trace WHO asked for the change — the caller's function + line — so an
|
||||
|
||||
Reference in New Issue
Block a user