From 29b4d16b73da9e3a7c32261160107e15716d1f0e Mon Sep 17 00:00:00 2001 From: deanlee Date: Fri, 15 Nov 2024 16:34:36 +0800 Subject: [PATCH] direct capnp to vector[CanData] conversion --- msgq_repo | 2 +- opendbc_repo | 2 +- panda | 2 +- selfdrive/pandad/pandad_api_impl.pyx | 29 ++++++++++++++++------------ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/msgq_repo b/msgq_repo index e621ce0763803e..3e17f865bbd3bb 160000 --- a/msgq_repo +++ b/msgq_repo @@ -1 +1 @@ -Subproject commit e621ce0763803ea821f9b41a20b0b77d83ab6c97 +Subproject commit 3e17f865bbd3bbabb3841227ed0774c8fb74efef diff --git a/opendbc_repo b/opendbc_repo index 8e349c395545b7..bdb716b5378e6f 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 8e349c395545b7d4ba59dcf317ef55baa591510c +Subproject commit bdb716b5378e6f4ad61829e5ad8e31fde4cde28d diff --git a/panda b/panda index 2fbf0c5ff86f2e..dec9223f9726e4 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 2fbf0c5ff86f2e94021d7c937b9f8eb6839af484 +Subproject commit dec9223f9726e400e4a4eb91ca19fffcd745f97a diff --git a/selfdrive/pandad/pandad_api_impl.pyx b/selfdrive/pandad/pandad_api_impl.pyx index 787968f53e7db3..2a97e5952b629a 100644 --- a/selfdrive/pandad/pandad_api_impl.pyx +++ b/selfdrive/pandad/pandad_api_impl.pyx @@ -4,7 +4,7 @@ from cython.operator cimport dereference as deref, preincrement as preinc from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool -from libc.stdint cimport uint8_t, uint32_t, uint64_t +from libc.stdint cimport uint8_t, uint32_t, uint64_t, uintptr_t cdef extern from "panda.h": cdef struct can_frame: @@ -41,16 +41,21 @@ def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True): can_list_to_can_capnp_cpp(can_list, out, msgtype == 'sendcan', valid) return out + +cdef class ParsedCanData: + cdef vector[CanData] *data + + def __cinit__(self): + self.data = new vector[CanData]() + + def __dealloc__(self): + del self.data + + def get_data_pointer(self): + return self.data + + def can_capnp_to_list(strings, msgtype='can'): - cdef vector[CanData] data - can_capnp_to_can_list_cpp(strings, data, msgtype == 'sendcan') - - result = [] - cdef CanData *d - cdef vector[CanData].iterator it = data.begin() - while it != data.end(): - d = &deref(it) - frames = [(f.address, (&f.dat[0])[:f.dat.size()], f.src) for f in d.frames] - result.append((d.nanos, frames)) - preinc(it) + cdef ParsedCanData result = ParsedCanData() + can_capnp_to_can_list_cpp(strings, result.data[0], msgtype == 'sendcan') return result