|
@@ -139,6 +139,13 @@ class CC1101:
|
|
|
|
|
|
def __init__(self) -> None:
|
|
def __init__(self) -> None:
|
|
self._spi = spidev.SpiDev()
|
|
self._spi = spidev.SpiDev()
|
|
|
|
+ self._spi_bus = 0
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ self._spi_chip_select = 0
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def _log_chip_status_byte(chip_status: int) -> None:
|
|
def _log_chip_status_byte(chip_status: int) -> None:
|
|
@@ -432,7 +439,18 @@ class CC1101:
|
|
|
|
|
|
def __enter__(self) -> "CC1101":
|
|
def __enter__(self) -> "CC1101":
|
|
|
|
|
|
- self._spi.open(0, 0)
|
|
+ try:
|
|
|
|
+ self._spi.open(self._spi_bus, self._spi_chip_select)
|
|
|
|
+ except PermissionError as exc:
|
|
|
|
+ raise PermissionError(
|
|
|
|
+ "Could not access /dev/spidev{}.{}".format(
|
|
|
|
+ self._spi_bus, self._spi_chip_select
|
|
|
|
+ )
|
|
|
|
+ + "\nVerify that the current user has both read and write access."
|
|
|
|
+ + "\nOn some devices, like Raspberry Pis,"
|
|
|
|
+ + "\n\tsudo usermod -a -G spi $USER"
|
|
|
|
+ + "\nfollowed by a re-login grants sufficient permissions."
|
|
|
|
+ ) from exc
|
|
self._spi.max_speed_hz = 55700
|
|
self._spi.max_speed_hz = 55700
|
|
self._reset()
|
|
self._reset()
|
|
partnum = self._read_status_register(StatusRegisterAddress.PARTNUM)
|
|
partnum = self._read_status_register(StatusRegisterAddress.PARTNUM)
|