Erle Stanley Gardner's 'The Case of the Reluctant Model' |
Piface Digital for the Raspberry Pi Model A |
I was an early user of the Piface Digital running on the Raspberry Pi Model A. While not the cheapest systems around, you get get IoT systems up up and running very fast, e.g., as motor driver for an IoT robot platform. In addition to the relay outputs, here are also inputs with very handy LED indicators. There was even a PiFace Digital 2 which lets you upgrade to a Raspberry Pi Model B:
Piface Digital 2 for the Raspberry Pi Model B |
# python3 /usr/share/doc/python3-pifacedigitalio/examples/blink.py
Traceback (most recent call last):
File "/usr/share/doc/python3-pifacedigitalio/examples/blink.py", line 9, in <module>
pifacedigital = pifacedigitalio.PiFaceDigital()
File "/usr/lib/python3/dist-packages/pifacedigitalio/core.py", line 82, in __init__
self.init_board()
File "/usr/lib/python3/dist-packages/pifacedigitalio/core.py", line 107, in init_board
h=self.hardware_addr, b=self.bus, c=self.chip_select))
pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).
This is really Piface's problem - it dropped the ball maintaining the software, but for now, Mike Richards has a good writeup on the solution, which is to get the latest update directly from the Piface github.
So I upgraded and found exactly the same problem! Dropping the ball seems to be getting to be a habit for Piface, or perhaps something went awry during the upgrade.
From the original link, I simply need to specify the SPI speed in the file spi.py. In my installation it came up as /usr/lib/python3/dist-packages/pifacecommon/spi.py
At line 65:
# create the spi transfer struct
transfer = spi_ioc_transfer(
tx_buf=ctypes.addressof(wbuffer),
rx_buf=ctypes.addressof(rbuffer),
len=ctypes.sizeof(wbuffer)
)
Change to
# create the spi transfer struct
transfer = spi_ioc_transfer(
tx_buf=ctypes.addressof(wbuffer),
rx_buf=ctypes.addressof(rbuffer),
len=ctypes.sizeof(wbuffer),
speed_hz=ctypes.c_uint32(15000) # 2019-06-25
)
# python3 /usr/share/doc/python3-pifacedigitalio/examples/blink.py
That seems to conclude the Case of the Reluctant Piface Model 2. Later when I checked, the same problem recurs if you upgraded the software to a Piface Digital 1. The same solution applies.
(Update 2020-01-16)
The piface github repository has updated their code, and the proper solution is now:
# create the spi transfer struct
transfer = spi_ioc_transfer(
tx_buf=ctypes.addressof(wbuffer),
rx_buf=ctypes.addressof(rbuffer),
len=ctypes.sizeof(wbuffer),
speed_hz=ctypes.c_uint32(self.speed_hz)
)
Sadly if you have an up-to-date version of Raspbian, the ugrade instructions no longer work:
$ sudo apt-get install python{,3}-pifacedigitalio
Instead, use:pip3 install pifacedigitalio
Or,
pip install pifacedigitalio
Happy trails.
No comments:
Post a Comment