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
			| 
								 
											6 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
							 | 
						||
| 
								 
											6 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)
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 | 
							
								def can_list_to_can_capnp(can_msgs, msgtype='can', valid=True):
							 | 
						||
| 
								 
											2 years ago
										 
									 | 
							
								  cdef can_frame *f
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  cdef vector[can_frame] can_list
							 | 
						||
| 
								 
											5 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											2 years ago
										 
									 | 
							
								  can_list.reserve(len(can_msgs))
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  for can_msg in can_msgs:
							 | 
						||
| 
								 
											2 years ago
										 
									 | 
							
								    f = &(can_list.emplace_back())
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								    f.address = can_msg[0]
							 | 
						||
| 
								 | 
							
								    f.busTime = can_msg[1]
							 | 
						||
| 
								 | 
							
								    f.dat = can_msg[2]
							 | 
						||
| 
								 | 
							
								    f.src = can_msg[3]
							 | 
						||
| 
								 
											2 years ago
										 
									 | 
							
								
							 | 
						||
| 
								 
											6 years ago
										 
									 | 
							
								  cdef string out
							 | 
						||
| 
								 | 
							
								  can_list_to_can_capnp_cpp(can_list, out, msgtype == 'sendcan', valid)
							 | 
						||
| 
								 | 
							
								  return out
							 |