python: common base handle for SPI + USB (#1231)

* base handle

* usb handle

* rm

* more types
This commit is contained in:
Adeeb Shihadeh
2023-01-28 16:01:54 -08:00
committed by GitHub
parent e7f36a2992
commit 6ec0c80754
4 changed files with 59 additions and 4 deletions

25
python/base.py Normal file
View File

@@ -0,0 +1,25 @@
from abc import ABC, abstractmethod
from typing import List
# This mimics the handle given by libusb1 for easy interoperability
class BaseHandle(ABC):
@abstractmethod
def close(self) -> None:
...
@abstractmethod
def controlWrite(self, request_type: int, request: int, value: int, index: int, data, timeout: int = 0) -> int:
...
@abstractmethod
def controlRead(self, request_type: int, request: int, value: int, index: int, length: int, timeout: int = 0) -> bytes:
...
@abstractmethod
def bulkWrite(self, endpoint: int, data: List[int], timeout: int = 0) -> int:
...
@abstractmethod
def bulkRead(self, endpoint: int, length: int, timeout: int = 0) -> bytes:
...