From 5487124f748781dbfc2be437bab50396b6c99c7d Mon Sep 17 00:00:00 2001 From: Dave Jones Date: Tue, 1 Nov 2016 10:03:04 +0000 Subject: [PATCH] Fix pigpiod SPI conflicts Wrong classname in the software implementation and for some reason I'd reverted a change on spi_flags somewhere... Also removed the clause skipping remote pigpiod tests Tested this commit with hardware and software SPI remotely - working nicely --- gpiozero/pins/pigpiod.py | 5 +++-- gpiozero/spi_devices.py | 2 ++ tests/test_real_pins.py | 5 ----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/gpiozero/pins/pigpiod.py b/gpiozero/pins/pigpiod.py index 07c8d9c..564c376 100644 --- a/gpiozero/pins/pigpiod.py +++ b/gpiozero/pins/pigpiod.py @@ -297,6 +297,7 @@ class PiGPIOHardwareSPI(SPI, Device): self._port = port self._device = device self._factory = proxy(factory) + self._handle = None super(PiGPIOHardwareSPI, self).__init__() self._reserve_pins(*( factory.address + ('GPIO%d' % pin,) @@ -305,7 +306,7 @@ class PiGPIOHardwareSPI(SPI, Device): self._spi_flags = 8 << 16 self._baud = 500000 self._handle = self._factory.connection.spi_open( - device, self._baud, self._spi_flags()) + device, self._baud, self._spi_flags) def _conflicts_with(self, other): return not ( @@ -413,7 +414,7 @@ class PiGPIOSoftwareSPI(SPI, Device): def _conflicts_with(self, other): return not ( - isinstance(other, PiGPIOHardwareSPI) and + isinstance(other, PiGPIOSoftwareSPI) and (self._select_pin) != (other._select_pin) ) diff --git a/gpiozero/spi_devices.py b/gpiozero/spi_devices.py index 3840583..0a30de1 100644 --- a/gpiozero/spi_devices.py +++ b/gpiozero/spi_devices.py @@ -27,6 +27,8 @@ class SPIDevice(Device): specified with the constructor. """ def __init__(self, **spi_args): + self._spi = None + super(SPIDevice, self).__init__() self._spi = self._pin_factory.spi(**spi_args) def close(self): diff --git a/tests/test_real_pins.py b/tests/test_real_pins.py index e570eba..c266828 100644 --- a/tests/test_real_pins.py +++ b/tests/test_real_pins.py @@ -43,11 +43,6 @@ INPUT_PIN = int(os.getenv('GPIOZERO_TEST_INPUT_PIN', '27')) scope='module', params=pkg_resources.get_distribution('gpiozero').get_entry_map('gpiozero_pin_factories').keys()) def pin_factory(request): - # Constructs each pin factory in turn with some extra logic to ensure - # we skip tests if pigpio is set for remote operation - if request.param == 'pigpio': - if os.getenv('PIGPIO_ADDR', 'localhost') != 'localhost': - pytest.skip("skipped factory pigpio: remote host in PIGPIO_ADDR") try: factory = pkg_resources.load_entry_point('gpiozero', 'gpiozero_pin_factories', request.param)() except Exception as e: