Catch SPI conflicts properly

Also handle SPI flags in pigpio implementation more elegantly (just
store the flags and manipulate them instead of keeping separate fields)
This commit is contained in:
Dave Jones
2016-10-21 21:51:10 +01:00
parent ba1a7e6497
commit a9f9aa4a3e
2 changed files with 52 additions and 48 deletions

View File

@@ -89,12 +89,6 @@ class LocalPiHardwareSPI(SPI, Device):
self._interface.open(port, device)
self._interface.max_speed_hz = 500000
def _conflicts_with(self, other):
return not (
isinstance(other, LocalPiHardwareSPI) and
(self._port, self._device) != (other._port, other._device)
)
def close(self):
if self._interface:
try:
@@ -165,6 +159,12 @@ class LocalPiSoftwareSPI(SPI, OutputDevice):
self.close()
raise
def _conflicts_with(self, other):
return not (
isinstance(other, LocalPiSoftwareSPI) and
(self.pin.number != other.pin.number)
)
def close(self):
if self._bus:
self._bus.close()