mirror of
https://github.com/MoreTore/openpilot.git
synced 2026-08-05 08:16:06 +08:00
Panda: add can_send buffer caching (#19910)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
#include <vector>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common/swaglog.h"
|
||||
@@ -303,9 +303,10 @@ void Panda::send_heartbeat(){
|
||||
}
|
||||
|
||||
void Panda::can_send(capnp::List<cereal::CanData>::Reader can_data_list){
|
||||
int msg_count = can_data_list.size();
|
||||
static std::vector<uint32_t> send;
|
||||
const int msg_count = can_data_list.size();
|
||||
|
||||
uint32_t *send = new uint32_t[msg_count*0x10]();
|
||||
send.resize(msg_count*0x10);
|
||||
|
||||
for (int i = 0; i < msg_count; i++) {
|
||||
auto cmsg = can_data_list[i];
|
||||
@@ -320,9 +321,7 @@ void Panda::can_send(capnp::List<cereal::CanData>::Reader can_data_list){
|
||||
memcpy(&send[i*4+2], can_data.begin(), can_data.size());
|
||||
}
|
||||
|
||||
usb_bulk_write(3, (unsigned char*)send, msg_count*0x10, 5);
|
||||
|
||||
delete[] send;
|
||||
usb_bulk_write(3, (unsigned char*)send.data(), send.size(), 5);
|
||||
}
|
||||
|
||||
int Panda::can_receive(kj::Array<capnp::word>& out_buf) {
|
||||
|
||||
Reference in New Issue
Block a user