From d9c2928e730febcf1ddb866a92cb38094dce74d2 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Thu, 21 Mar 2024 14:32:13 -0700 Subject: [PATCH] boardd: keep same offset for now --- selfdrive/boardd/boardd.cc | 2 +- selfdrive/boardd/panda.cc | 2 +- selfdrive/boardd/panda.h | 2 ++ selfdrive/boardd/tests/test_boardd_usbprotocol.cc | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 22747d0918..fcbf58999e 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -144,7 +144,7 @@ bool safety_setter_thread(std::vector pandas) { Panda *connect(std::string serial="", uint32_t index=0) { std::unique_ptr panda; try { - panda = std::make_unique(serial, (index * PANDA_BUS_CNT)); + panda = std::make_unique(serial, (index * PANDA_BUS_OFFSET)); } catch (std::exception &e) { return nullptr; } diff --git a/selfdrive/boardd/panda.cc b/selfdrive/boardd/panda.cc index 95cfe04efd..a2e5574090 100644 --- a/selfdrive/boardd/panda.cc +++ b/selfdrive/boardd/panda.cc @@ -172,7 +172,7 @@ void Panda::pack_can_buffer(const capnp::List::Reader &can_data for (auto cmsg : can_data_list) { // check if the message is intended for this panda uint8_t bus = cmsg.getSrc(); - if (bus < bus_offset || bus >= (bus_offset + PANDA_BUS_CNT)) { + if (bus < bus_offset || bus >= (bus_offset + PANDA_BUS_OFFSET)) { continue; } auto can_data = cmsg.getDat(); diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h index f46150dd95..3002afeba9 100644 --- a/selfdrive/boardd/panda.h +++ b/selfdrive/boardd/panda.h @@ -23,6 +23,8 @@ #define CAN_REJECTED_BUS_OFFSET 0xC0U #define CAN_RETURNED_BUS_OFFSET 0x80U +#define PANDA_BUS_OFFSET 4 + struct __attribute__((packed)) can_header { uint8_t reserved : 1; uint8_t bus : 3; diff --git a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc index 86476d05cd..aa67e8cf8c 100644 --- a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc +++ b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc @@ -40,7 +40,7 @@ PandaTest::PandaTest(uint32_t bus_offset_, int can_list_size, cereal::PandaState uint32_t id = util::random_int(0, std::size(dlc_to_len) - 1); const std::string &dat = test_data[dlc_to_len[id]]; can.setAddress(i); - can.setSrc(util::random_int(0, 3) + bus_offset); + can.setSrc(util::random_int(0, 2) + bus_offset); can.setDat(kj::ArrayPtr((uint8_t *)dat.data(), dat.size())); total_pakets_size += sizeof(can_header) + dat.size(); }