You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
837 B
32 lines
837 B
5 years ago
|
# distutils: language = c++
|
||
|
# cython: language_level=3
|
||
|
from libcpp.vector cimport vector
|
||
|
from libcpp.string cimport string
|
||
|
from libcpp cimport bool
|
||
|
|
||
2 years ago
|
cdef extern from "panda.h":
|
||
|
cdef struct can_frame:
|
||
|
long address
|
||
|
string dat
|
||
|
long busTime
|
||
|
long src
|
||
5 years ago
|
|
||
2 years ago
|
cdef extern from "can_list_to_can_capnp.cc":
|
||
|
void can_list_to_can_capnp_cpp(const vector[can_frame] &can_list, string &out, bool sendCan, bool valid)
|
||
5 years ago
|
|
||
|
def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True):
|
||
12 months ago
|
cdef can_frame *f
|
||
5 years ago
|
cdef vector[can_frame] can_list
|
||
4 years ago
|
|
||
12 months ago
|
can_list.reserve(len(can_msgs))
|
||
5 years ago
|
for can_msg in can_msgs:
|
||
12 months ago
|
f = &(can_list.emplace_back())
|
||
5 years ago
|
f.address = can_msg[0]
|
||
|
f.busTime = can_msg[1]
|
||
|
f.dat = can_msg[2]
|
||
|
f.src = can_msg[3]
|
||
12 months ago
|
|
||
5 years ago
|
cdef string out
|
||
|
can_list_to_can_capnp_cpp(can_list, out, msgtype == 'sendcan', valid)
|
||
|
return out
|