diff --git a/__init__.py b/__init__.py index dfb2bbf1c..25120f7f7 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,7 @@ from .python.constants import McuType, BASEDIR, FW_PATH, USBPACKET_MAX_SIZE # noqa: F401 from .python.spi import PandaSpiException, PandaProtocolMismatch # noqa: F401 from .python.serial import PandaSerial # noqa: F401 +from .python.canhandle import CanHandle # noqa: F401 from .python import (Panda, PandaDFU, # noqa: F401 pack_can_buffer, unpack_can_buffer, calculate_checksum, unpack_log, DLC_TO_LEN, LEN_TO_DLC, ALTERNATIVE_EXPERIENCE, CANPACKET_HEAD_SIZE) diff --git a/python/base.py b/python/base.py index d19a2b861..509d3ebf7 100644 --- a/python/base.py +++ b/python/base.py @@ -15,7 +15,7 @@ class BaseHandle(ABC): ... @abstractmethod - def controlWrite(self, request_type: int, request: int, value: int, index: int, data, timeout: int = TIMEOUT) -> int: + def controlWrite(self, request_type: int, request: int, value: int, index: int, data, timeout: int = TIMEOUT, expect_disconnect: bool = False): ... @abstractmethod diff --git a/tests/pedal/canhandle.py b/python/canhandle.py similarity index 91% rename from tests/pedal/canhandle.py rename to python/canhandle.py index 0d7582f04..ff6e62555 100644 --- a/tests/pedal/canhandle.py +++ b/python/canhandle.py @@ -1,8 +1,10 @@ import struct import signal +from .base import BaseHandle -class CanHandle(object): + +class CanHandle(BaseHandle): def __init__(self, p, bus): self.p = p self.bus = bus @@ -29,7 +31,10 @@ class CanHandle(object): return ret - def controlWrite(self, request_type, request, value, index, data, timeout=0): + def close(self): + pass + + def controlWrite(self, request_type, request, value, index, data, timeout=0, expect_disconnect=False): # ignore data in reply, panda doesn't use it return self.controlRead(request_type, request, value, index, 0, timeout) diff --git a/tests/pedal/enter_canloader.py b/tests/pedal/enter_canloader.py index bdd0d6286..7465c0a07 100755 --- a/tests/pedal/enter_canloader.py +++ b/tests/pedal/enter_canloader.py @@ -1,8 +1,7 @@ #!/usr/bin/env python3 import time import argparse -from panda import Panda, McuType -from panda.tests.pedal.canhandle import CanHandle +from panda import Panda, CanHandle, McuType if __name__ == "__main__": diff --git a/tests/pedal/test_pedal.py b/tests/pedal/test_pedal.py index 416a20fa0..7888ada75 100755 --- a/tests/pedal/test_pedal.py +++ b/tests/pedal/test_pedal.py @@ -3,9 +3,8 @@ import os import time import subprocess import unittest -from panda import Panda, BASEDIR +from panda import Panda, CanHandle, BASEDIR from panda_jungle import PandaJungle # pylint: disable=import-error -from panda.tests.pedal.canhandle import CanHandle JUNGLE_SERIAL = os.getenv("PEDAL_JUNGLE")