Fix DoA reading — skip 1-byte status header in USB response
Response format is [status_byte, angle_lo, angle_hi, vad_lo, vad_hi], not [angle_lo, angle_hi, vad_lo, vad_hi]. Was reading the status byte (0x42=66) as the angle, which is why DoA was always stuck at 66. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -86,11 +86,12 @@ class XVF3800:
|
|||||||
# --- DoA ---
|
# --- DoA ---
|
||||||
|
|
||||||
def read_doa(self) -> tuple[int, bool]:
|
def read_doa(self) -> tuple[int, bool]:
|
||||||
"""Read Direction of Arrival. Returns (angle 0-359, vad True/False)."""
|
"""Read Direction of Arrival. Returns (angle 0-359, vad True/False).
|
||||||
|
Response format: 1 status byte + 2 uint16 words (angle, vad)."""
|
||||||
data = self._read(GPO_RESID, DOA_VALUE_CMD, 2) # 2 uint16 words
|
data = self._read(GPO_RESID, DOA_VALUE_CMD, 2) # 2 uint16 words
|
||||||
if len(data) < 4:
|
if len(data) < 5: # 1 header + 4 data bytes
|
||||||
return 0, False
|
return 0, False
|
||||||
angle, vad = struct.unpack_from("<HH", data)
|
angle, vad = struct.unpack_from("<HH", data, 1) # skip 1-byte header
|
||||||
return angle % 360, bool(vad)
|
return angle % 360, bool(vad)
|
||||||
|
|
||||||
# --- LEDs ---
|
# --- LEDs ---
|
||||||
|
|||||||
Reference in New Issue
Block a user