CCP: fix upload response size and getting seed (#2009)

This commit is contained in:
Greg Hogan 2024-09-03 20:42:12 -07:00 committed by GitHub
parent aac60b8a79
commit 93776fd5bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -177,7 +177,7 @@ class CcpClient():
def get_seed(self, resource_mask: int) -> bytes: def get_seed(self, resource_mask: int) -> bytes:
if resource_mask > 255: if resource_mask > 255:
raise ValueError("resource mask must be less than 256") raise ValueError("resource mask must be less than 256")
self._send_cro(COMMAND_CODE.GET_SEED) self._send_cro(COMMAND_CODE.GET_SEED, bytes([resource_mask]))
resp = self._recv_dto(0.025) resp = self._recv_dto(0.025)
# protected = resp[0] == 0 # protected = resp[0] == 0
seed = resp[1:] seed = resp[1:]
@ -221,7 +221,7 @@ class CcpClient():
if size > 5: if size > 5:
raise ValueError("size must be less than 6") raise ValueError("size must be less than 6")
self._send_cro(COMMAND_CODE.UPLOAD, bytes([size])) self._send_cro(COMMAND_CODE.UPLOAD, bytes([size]))
return self._recv_dto(0.025) return self._recv_dto(0.025)[:size]
def short_upload(self, size: int, addr_ext: int, addr: int) -> bytes: def short_upload(self, size: int, addr_ext: int, addr: int) -> bytes:
if size > 5: if size > 5:
@ -229,7 +229,7 @@ class CcpClient():
if addr_ext > 255: if addr_ext > 255:
raise ValueError("address extension must be less than 256") raise ValueError("address extension must be less than 256")
self._send_cro(COMMAND_CODE.SHORT_UP, bytes([size, addr_ext]) + struct.pack(f"{self.byte_order.value}I", addr)) self._send_cro(COMMAND_CODE.SHORT_UP, bytes([size, addr_ext]) + struct.pack(f"{self.byte_order.value}I", addr))
return self._recv_dto(0.025) return self._recv_dto(0.025)[:size]
def select_calibration_page(self) -> None: def select_calibration_page(self) -> None:
self._send_cro(COMMAND_CODE.SELECT_CAL_PAGE) self._send_cro(COMMAND_CODE.SELECT_CAL_PAGE)