Skip to content

Commit

Permalink
tesla model 3 with honda pilot nidec radar
Browse files Browse the repository at this point in the history
  • Loading branch information
gregjhogan committed Oct 17, 2024
1 parent 14e00ca commit bfbb84c
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions board/safety/safety_tesla.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ static safety_config tesla_init(uint16_t param) {
{0x488, 0, 4}, // DAS_steeringControl
{0x2b9, 0, 8}, // DAS_control
{0x27D, 0, 3}, // APS_eacMonitor
{0x300, 1, 8}, // VEHICLE_STATE
{0x301, 1, 8}, // VEHICLE_STATE2
};

tesla_longitudinal = GET_FLAG(param, TESLA_FLAG_LONGITUDINAL_CONTROL);
Expand Down
50 changes: 50 additions & 0 deletions tests/can_printer_radar.py
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()

0 comments on commit bfbb84c

Please sign in to comment.