From d693e89df2ec21e14a25b0723fe0d828dd82b1c9 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 2 Jul 2023 23:50:30 -0700 Subject: [PATCH] SPI: send hw type with version (#1490) Co-authored-by: Comma Device --- board/drivers/spi.h | 4 ++++ tests/hitl/8_spi.py | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/drivers/spi.h b/board/drivers/spi.h index a219152b..90dd6109 100644 --- a/board/drivers/spi.h +++ b/board/drivers/spi.h @@ -95,6 +95,10 @@ void spi_rx_done(void) { #endif data_len += 12U; + // HW type + spi_buf_tx[data_pos + data_len] = hw_type; + data_len += 1U; + // SPI protocol version spi_buf_tx[data_pos + data_len] = 0x1; data_len += 1U; diff --git a/tests/hitl/8_spi.py b/tests/hitl/8_spi.py index c1e2a86a..eb942c57 100644 --- a/tests/hitl/8_spi.py +++ b/tests/hitl/8_spi.py @@ -21,10 +21,13 @@ class TestSpi: def test_protocol_version(self, p): v = p._handle.get_protocol_version() - uid = binascii.hexlify(v[:-1]).decode() + uid = binascii.hexlify(v[:12]).decode() assert uid == p.get_uid() - assert v[-1:] == b"\x01" + hwtype = v[12] + assert hwtype == ord(p.get_type()) + + assert v[-1] == 1 def test_all_comm_types(self, mocker, p): spy = mocker.spy(p._handle, '_wait_for_ack')