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

23
python/usb.py Normal file
View File

@@ -0,0 +1,23 @@
from typing import List
from .base import BaseHandle
class PandaUsbHandle(BaseHandle):
def __init__(self, libusb_handle):
self._libusb_handle = libusb_handle
def close(self):
self._libusb_handle.close()
def controlWrite(self, request_type: int, request: int, value: int, index: int, data, timeout: int = 0):
return self._libusb_handle.controlWrite(request_type, request, value, index, data, timeout)
def controlRead(self, request_type: int, request: int, value: int, index: int, length: int, timeout: int = 0):
return self._libusb_handle.controlRead(request_type, request, value, index, length, timeout)
def bulkWrite(self, endpoint: int, data: List[int], timeout: int = 0) -> int:
return self._libusb_handle.bulkWrite(endpoint, data, timeout)
def bulkRead(self, endpoint: int, length: int, timeout: int = 0) -> bytes:
return self._libusb_handle.bulkRead(endpoint, length, timeout)