Files
panda-meb/tests/pedal/test_pedal.py
Igor Biletskyy ad90646001 Support for STM32H7 and Red Panda (#694)
* H7 drivers

* Include H7 into the code

* fix flash write for H7

* get serial from flasher.h from F4 and H7

* flash.sh and recover.sh for gen3

* add set_data_speed for BRS CAN FD

* build all fws

* gen3 to panda lib

* gen3 name in scons project

* disable fd can and brs

* gen3 to CI tests

* jenkins fix for new tests and build_all

* fix pedal test

* pedal in panda tests again...

* cleanup llfdcan.h

* cleanup clock.h

* Add LDORDY bit check instead of delay

* missing define in stm32h735xx.h lib

* board_id helper

* enable debug detection again

* clean gpio inits

* fix board_id helper, make cleaner

* comment MCUs in stm lib for faster misra

* target MCU

* misra-5.5

* improve headers and misra speed

* cleanup CI tests

* change naming from gen3 to h7

* readable if statement

* cleanup llusb.h

* only cycle one transceifer in bus-off

* move unused funcs to common header

* bus_off_err reset

* misra 10.4 fdcan

* extern to can_data_speed variable

* limit can_data_speed array size to 3

* reinit fd can on data speed change

* Improve test with ELM327 and extaddr check

* bugfix for fdcan

* panda python config naming

* abstracted init request in llfdcan

* misra fdcan

* Improve llusb.h for H7
2021-08-02 20:26:15 -07:00

65 lines
1.8 KiB
Python
Executable File

import os
import time
import subprocess
import unittest
from panda import Panda, BASEDIR
from panda_jungle import PandaJungle # pylint: disable=import-error
from panda.tests.pedal.canhandle import CanHandle
JUNGLE_SERIAL = os.getenv("PEDAL_JUNGLE")
PEDAL_SERIAL = 'none'
PEDAL_BUS = 1
class TestPedal(unittest.TestCase):
def setUp(self):
self.jungle = PandaJungle(JUNGLE_SERIAL)
self.jungle.set_panda_power(True)
self.jungle.set_ignition(False)
def tearDown(self):
self.jungle.close()
def _flash_over_can(self, bus, fw_file):
print(f"Flashing {fw_file}")
while len(self.jungle.can_recv()) != 0:
continue
self.jungle.can_send(0x200, b"\xce\xfa\xad\xde\x1e\x0b\xb0\x0a", bus)
time.sleep(0.1)
with open(fw_file, "rb") as code:
PandaJungle.flash_static(CanHandle(self.jungle, bus), code.read())
def _listen_can_frames(self):
self.jungle.can_clear(0xFFFF)
msgs = 0
for _ in range(10):
incoming = self.jungle.can_recv()
for message in incoming:
address, _, _, bus = message
if address == 0x201 and bus == PEDAL_BUS:
msgs += 1
time.sleep(0.1)
return msgs
def test_usb_fw(self):
subprocess.check_output(f"cd {BASEDIR} && PEDAL=1 PEDAL_USB=1 scons", shell=True)
self._flash_over_can(PEDAL_BUS, f"{BASEDIR}board/obj/pedal_usb.bin.signed")
time.sleep(2)
p = Panda(PEDAL_SERIAL)
self.assertTrue(p.is_pedal())
p.close()
self.assertTrue(self._listen_can_frames() > 40)
def test_nonusb_fw(self):
subprocess.check_output(f"cd {BASEDIR} && PEDAL=1 scons", shell=True)
self._flash_over_can(PEDAL_BUS, f"{BASEDIR}board/obj/pedal.bin.signed")
time.sleep(2)
self.assertTrue(PEDAL_SERIAL not in Panda.list())
self.assertTrue(self._listen_can_frames() > 40)
if __name__ == '__main__':
unittest.main()