From a6f2f2d75115c6df3834f4cc51d3da15cfcdc5dd Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 29 Nov 2022 16:05:46 -0800 Subject: [PATCH] boardd: cleanup defs from panda (#26628) * more stuff * bump pnada old-commit-hash: c3e3047080cdcfd5fbe275534fdf6980903aebdf --- panda | 2 +- selfdrive/boardd/panda.cc | 9 ++++++--- selfdrive/boardd/panda.h | 12 ++++-------- selfdrive/boardd/tests/test_boardd_usbprotocol.cc | 2 -- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/panda b/panda index e4c4253964..80dac4cd94 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit e4c4253964a25ff980520b70ea9f50aede4a1db6 +Subproject commit 80dac4cd94de8711304b2695b4d348d2152a8e3e diff --git a/selfdrive/boardd/panda.cc b/selfdrive/boardd/panda.cc index b82de593c8..788cdf5cf1 100644 --- a/selfdrive/boardd/panda.cc +++ b/selfdrive/boardd/panda.cc @@ -6,7 +6,6 @@ #include #include "cereal/messaging/messaging.h" -#include "panda/board/dlc_to_len.h" #include "common/swaglog.h" #include "common/util.h" @@ -255,8 +254,12 @@ bool Panda::unpack_can_buffer(uint8_t *data, int size, std::vector &o canData.busTime = 0; canData.address = header.addr; canData.src = header.bus + bus_offset; - if (header.rejected) { canData.src += CANPACKET_REJECTED; } - if (header.returned) { canData.src += CANPACKET_RETURNED; } + if (header.rejected) { + canData.src += CAN_REJECTED_BUS_OFFSET; + } + if (header.returned) { + canData.src += CAN_RETURNED_BUS_OFFSET; + } const uint8_t data_len = dlc_to_len[header.data_len_code]; canData.dat.assign((char *)&recv_buf[pos + CANPACKET_HEAD_SIZE], data_len); diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h index 5b3cbb9a3e..b20d8f0afa 100644 --- a/selfdrive/boardd/panda.h +++ b/selfdrive/boardd/panda.h @@ -11,20 +11,16 @@ #include "cereal/gen/cpp/car.capnp.h" #include "cereal/gen/cpp/log.capnp.h" #include "panda/board/health.h" +#include "panda/board/can_definitions.h" #include "selfdrive/boardd/panda_comms.h" - -#define PANDA_CAN_CNT 3 -#define PANDA_BUS_CNT 4 - #define USB_TX_SOFT_LIMIT (0x100U) #define USBPACKET_MAX_SIZE (0x40) #define RECV_SIZE (0x4000U) -#define CANPACKET_HEAD_SIZE 5U -#define CANPACKET_MAX_SIZE 72U -#define CANPACKET_REJECTED (0xC0U) -#define CANPACKET_RETURNED (0x80U) + +#define CAN_REJECTED_BUS_OFFSET 0xC0U +#define CAN_RETURNED_BUS_OFFSET 0x80U struct __attribute__((packed)) can_header { uint8_t reserved : 1; diff --git a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc index 6a13cbd71f..c7d14fb0ef 100644 --- a/selfdrive/boardd/tests/test_boardd_usbprotocol.cc +++ b/selfdrive/boardd/tests/test_boardd_usbprotocol.cc @@ -6,8 +6,6 @@ #include "cereal/messaging/messaging.h" #include "selfdrive/boardd/panda.h" -const unsigned char dlc_to_len[] = {0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U, 8U, 12U, 16U, 20U, 24U, 32U, 48U, 64U}; - int random_int(int min, int max) { std::random_device dev; std::mt19937 rng(dev());