Panda: add can_send buffer caching (#19910)

old-commit-hash: 5c58a2618e
commatwo_master
Dean Lee 5 years ago committed by GitHub
parent e9b2f0399d
commit 06b8f1042b
  1. 11
      selfdrive/boardd/panda.cc

@ -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) {

Loading…
Cancel
Save