Source code for panda.python.base

from abc import ABC, abstractmethod

from .constants import McuType

TIMEOUT = int(15 * 1e3)  # default timeout, in milliseconds

[docs] class BaseHandle(ABC): """ A handle to talk to a panda. Borrows heavily from the libusb1 handle API. """
[docs] @abstractmethod def close(self) -> None: ...
[docs] @abstractmethod def controlWrite(self, request_type: int, request: int, value: int, index: int, data, timeout: int = TIMEOUT, expect_disconnect: bool = False): ...
[docs] @abstractmethod def controlRead(self, request_type: int, request: int, value: int, index: int, length: int, timeout: int = TIMEOUT) -> bytes: ...
[docs] @abstractmethod def bulkWrite(self, endpoint: int, data: bytes, timeout: int = TIMEOUT) -> int: ...
[docs] @abstractmethod def bulkRead(self, endpoint: int, length: int, timeout: int = TIMEOUT) -> bytes: ...
[docs] class BaseSTBootloaderHandle(ABC): """ A handle to talk to a panda while it's in the STM32 bootloader. """
[docs] @abstractmethod def get_mcu_type(self) -> McuType: ...
[docs] @abstractmethod def close(self) -> None: ...
[docs] @abstractmethod def clear_status(self) -> None: ...
[docs] @abstractmethod def program(self, address: int, dat: bytes) -> None: ...
[docs] @abstractmethod def erase_sector(self, sector: int) -> None: ...
[docs] @abstractmethod def jump(self, address: int) -> None: ...