From a5718ce5dd9d3ca568a6b023b2aec5b2bfda5b2d Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Mon, 1 May 2023 19:31:13 -0700 Subject: [PATCH] spi: different ack dummy bytes for debugging (#1382) different ack vals Co-authored-by: Comma Device --- python/spi.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/spi.py b/python/spi.py index 2e6beb54..c098ebbb 100644 --- a/python/spi.py +++ b/python/spi.py @@ -98,12 +98,12 @@ class PandaSpiHandle(BaseHandle): cksum ^= b return cksum - def _wait_for_ack(self, spi, ack_val: int, timeout: int) -> None: + def _wait_for_ack(self, spi, ack_val: int, timeout: int, tx: int) -> None: timeout_s = max(MIN_ACK_TIMEOUT_MS, timeout) * 1e-3 start = time.monotonic() while (timeout == 0) or ((time.monotonic() - start) < timeout_s): - dat = spi.xfer2(b"\x12")[0] + dat = spi.xfer2([tx, ])[0] if dat == NACK: raise PandaSpiNackResponse elif dat == ack_val: @@ -125,7 +125,7 @@ class PandaSpiHandle(BaseHandle): spi.xfer2(packet) logging.debug("- waiting for header ACK") - self._wait_for_ack(spi, HACK, timeout) + self._wait_for_ack(spi, HACK, timeout, 0x11) # send data logging.debug("- sending data") @@ -133,7 +133,7 @@ class PandaSpiHandle(BaseHandle): spi.xfer2(packet) logging.debug("- waiting for data ACK") - self._wait_for_ack(spi, DACK, timeout) + self._wait_for_ack(spi, DACK, timeout, 0x13) # get response length, then response response_len_bytes = bytes(spi.xfer2(b"\x00" * 2))