forked from commaai/panda
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tesla model 3 with honda pilot nidec radar
- Loading branch information
1 parent
14e00ca
commit bfbb84c
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import time | ||
from collections import defaultdict | ||
import binascii | ||
|
||
from panda import Panda | ||
|
||
from opendbc.car.tesla.teslacan import TeslaCAN | ||
tc = TeslaCAN(None) | ||
|
||
# fake | ||
def sec_since_boot(): | ||
return time.time() | ||
|
||
def can_printer(): | ||
p = Panda() | ||
print(f"Connected to id: {p.get_serial()[0]}: {p.get_version()}") | ||
time.sleep(1) | ||
|
||
p.can_clear(0xFFFF) | ||
p.set_power_save(0) | ||
p.set_safety_mode(Panda.SAFETY_TESLA) | ||
|
||
start = sec_since_boot() | ||
lp = sec_since_boot() | ||
msgs = defaultdict(list) | ||
canbus = os.getenv("CAN") | ||
while True: | ||
can_recv = p.can_recv() | ||
for address, dat, src in can_recv: | ||
if canbus is None or str(src) == canbus: | ||
msgs[address].append((dat, src)) | ||
|
||
if sec_since_boot() - lp > 0.1: | ||
p.send_heartbeat() | ||
dd = chr(27) + "[2J" | ||
dd += "%5.2f\n" % (sec_since_boot() - start) | ||
for k, v in sorted(msgs.items()): | ||
last_msg, last_src = v[-1] | ||
dd += "%d: %s(%6d): %s\n" % (last_src, "%04X(%4d)" % (k, k), len(v), binascii.hexlify(last_msg).decode()) | ||
print(dd) | ||
lp = sec_since_boot() | ||
|
||
i = int(sec_since_boot() * 100) % 100 | ||
if i % 5 == 0: | ||
p.can_send_many(tc.create_radar_commands(0, i // 5 % 4)) | ||
|
||
if __name__ == "__main__": | ||
can_printer() |