Skip to content

Commit 25d8800

Browse files
committed
consistent naming
1 parent a5c640a commit 25d8800

6 files changed

+27
-8
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
can/*.so
66
can/build/
77
can/obj/
8-
can/packer_impl.cpp
8+
can/packer_pyx.cpp
99
can/parser_pyx.cpp

can/SConscript

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@ for x in os.listdir('../'):
1717
libdbc = env.SharedLibrary('libdbc', ["dbc.cc", "parser.cc", "packer.cc", "common.cc"]+dbcs, LIBS=["capnp", "kj"])
1818

1919
# packer
20-
env.Command(['packer_impl.so'],
21-
['packer_impl.pyx', 'packer_setup.py'],
22-
"cd opendbc/can && python3 packer_setup.py build_ext --inplace")
20+
env.Command(['packer_pyx.so'],
21+
['packer_pyx.pyx', 'packer_pyx_setup.py'],
22+
"cd opendbc/can && python3 packer_pyx_setup.py build_ext --inplace")
2323

2424
# parser
2525
env.Command(['parser_pyx.so'],
2626
[libdbc, cereal, 'parser_pyx_setup.py', 'parser_pyx.pyx', 'common.pxd'],
2727
"cd opendbc/can && python3 parser_pyx_setup.py build_ext --inplace")
28-

can/packer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# pylint: skip-file
2-
from opendbc.can.packer_impl import CANPacker
2+
from opendbc.can.packer_pyx import CANPacker
33
assert CANPacker
File renamed without changes.

can/packer_setup.py can/packer_pyx_setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
setup(name='CAN Packer API Implementation',
88
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},
9-
ext_modules=cythonize(Extension("packer_impl", ["packer_impl.pyx"], language="c++", extra_compile_args=["-std=c++11"])))
9+
ext_modules=cythonize(Extension("packer_pyx", ["packer_pyx.pyx"], language="c++", extra_compile_args=["-std=c++11"])))

can/tests/test_packer_parser.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44

55
from opendbc.can.parser import CANParser
66
from opendbc.can.packer import CANPacker
7-
from opendbc.boardd.boardd import can_list_to_can_capnp
7+
import cereal.messaging as messaging
8+
9+
10+
# Python implementation so we don't have to depend on boardd
11+
def can_list_to_can_capnp(can_msgs, msgtype='can'):
12+
dat = messaging.new_message()
13+
dat.init(msgtype, len(can_msgs))
14+
15+
for i, can_msg in enumerate(can_msgs):
16+
if msgtype == 'sendcan':
17+
cc = dat.sendcan[i]
18+
else:
19+
cc = dat.can[i]
20+
21+
cc.address = can_msg[0]
22+
cc.busTime = can_msg[1]
23+
cc.dat = bytes(can_msg[2])
24+
cc.src = can_msg[3]
25+
26+
return dat.to_bytes()
27+
828

929
class TestCanParserPacker(unittest.TestCase):
1030
def test_civic(self):

0 commit comments

Comments
 (0)