mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-24 23:42:05 +08:00
fix chunk buffer size (#22969)
This commit is contained in:
@@ -433,15 +433,15 @@ bool Panda::can_receive(std::vector<can_frame>& out_vec) {
|
||||
static uint8_t tail[CANPACKET_MAX_SIZE];
|
||||
uint8_t tail_size = 0;
|
||||
uint8_t counter = 0;
|
||||
for (int i = 0; i < recv; i += 64) {
|
||||
for (int i = 0; i < recv; i += USBPACKET_MAX_SIZE) {
|
||||
// Check for counter every 64 bytes (length of USB packet)
|
||||
if (counter != data[i]) {
|
||||
LOGE("CAN: MALFORMED USB RECV PACKET");
|
||||
break;
|
||||
}
|
||||
counter++;
|
||||
uint8_t chunk_len = ((recv - i) > 64) ? 63 : (recv - i - 1); // as 1 is always reserved for counter
|
||||
uint8_t chunk[CANPACKET_MAX_SIZE];
|
||||
uint8_t chunk_len = ((recv - i) > USBPACKET_MAX_SIZE) ? 63 : (recv - i - 1); // as 1 is always reserved for counter
|
||||
uint8_t chunk[USBPACKET_MAX_SIZE + CANPACKET_MAX_SIZE];
|
||||
memcpy(chunk, tail, tail_size);
|
||||
memcpy(&chunk[tail_size], &data[i+1], chunk_len);
|
||||
chunk_len += tail_size;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define PANDA_BUS_CNT 4
|
||||
#define RECV_SIZE (0x4000U)
|
||||
#define USB_TX_SOFT_LIMIT (0x100U)
|
||||
#define USBPACKET_MAX_SIZE (0x40U)
|
||||
#define CANPACKET_HEAD_SIZE 5U
|
||||
#define CANPACKET_MAX_SIZE 72U
|
||||
#define CANPACKET_REJECTED (0xC0U)
|
||||
|
||||
Reference in New Issue
Block a user