Files
panda-meb/tests/pedal/enter_canloader.py

35 lines
896 B
Python
Raw Normal View History

2019-09-24 17:50:53 -07:00
#!/usr/bin/env python3
2018-03-10 11:31:04 -08:00
import time
2018-03-10 09:34:48 -08:00
import argparse
2018-03-09 14:30:28 -08:00
from panda import Panda
from panda.python.dfu import MCU_TYPE_F2
from panda.tests.pedal.canhandle import CanHandle
2018-03-10 11:22:22 -08:00
2018-03-09 14:30:28 -08:00
if __name__ == "__main__":
2018-03-10 09:34:48 -08:00
parser = argparse.ArgumentParser(description='Flash pedal over can')
parser.add_argument('--recover', action='store_true')
2018-03-10 10:13:30 -08:00
parser.add_argument("fn", type=str, nargs='?', help="flash file")
2018-03-10 09:34:48 -08:00
args = parser.parse_args()
2018-03-09 14:30:28 -08:00
p = Panda()
p.set_safety_mode(Panda.SAFETY_ALLOUTPUT)
2018-03-10 09:34:48 -08:00
2018-03-10 11:22:22 -08:00
while 1:
if len(p.can_recv()) == 0:
break
2018-03-10 09:34:48 -08:00
if args.recover:
p.can_send(0x200, b"\xce\xfa\xad\xde\x1e\x0b\xb0\x02", 0)
2018-03-10 10:13:30 -08:00
exit(0)
2018-03-10 09:34:48 -08:00
else:
p.can_send(0x200, b"\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", 0)
2018-03-09 14:30:28 -08:00
2018-03-10 10:13:30 -08:00
if args.fn:
2018-03-12 18:32:33 -07:00
time.sleep(0.1)
print("flashing", args.fn)
code = open(args.fn, "rb").read()
Panda.flash_static(CanHandle(p, 0), code, mcu_type=MCU_TYPE_F2)
2018-03-10 10:13:30 -08:00
print("can flash done")