piface / pifacecad

PiFace Control and Display
GNU General Public License v3.0
46 stars 38 forks source link

No PiFace Control and Display board detected (hardware_addr=0, bus=0, chip_select=1) since kernel 4.9.51 #24

Open DanielChesters opened 6 years ago

DanielChesters commented 6 years ago

Hi, I did a rpi-update this week (and I get the kernel 4.9.51) on Raspbian GNU/Linux 9 and the Piface Control and Display does not work anymore :

pi@raspberrypi:~ $ python /usr/share/doc/python-pifacecad/examples/sysinfo.py 
Traceback (most recent call last):
  File "/usr/share/doc/python-pifacecad/examples/sysinfo.py", line 61, in <module>
    cad = pifacecad.PiFaceCAD()
  File "/usr/lib/python2.7/dist-packages/pifacecad/core.py", line 50, in __init__
    self.init_board()
  File "/usr/lib/python2.7/dist-packages/pifacecad/core.py", line 80, in init_board
    h=self.hardware_addr, b=self.bus, c=self.chip_select))
pifacecad.core.NoPiFaceCADDetectedError: No PiFace Control and Display board detected (hardware_addr=0, bus=0, chip_select=1).
DanielChesters commented 6 years ago

The problem still here with kernel 4.9.56.

jlikeme commented 6 years ago

The spi-max-frequency has changed to 125000000 after kernel 4.9.43. But pifacecad can't support the default frequency. You can read this https://github.com/raspberrypi/linux/issues/2165. In addition, we can modify /usr/lib/python3/dist-packages/pifacecommon/spi.py like this.

    # 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(100000)
    )
DanielChesters commented 6 years ago

Thank for the solution, I use this fix so now I can use my PiFace Control and Display board. I will do a pull request for piface/pifacecommon.

keigezellig commented 6 years ago

Sorry to open this issue again but in the piface package which i installed from Raspbian Stretch (2018-06-27-raspbian-stretch-lite) this issue is still not resolved. Actually when i look at /usr/lib/python3/dist-packages/pifacecommon/spi.py i see:

 # create the spi transfer struct
        transfer = spi_ioc_transfer(
            tx_buf=ctypes.addressof(wbuffer),
            rx_buf=ctypes.addressof(rbuffer),
            len=ctypes.sizeof(wbuffer)

so without above mentioned speed_hz line. When i add this line the piface cad works as expected.

SailingGreg commented 5 years ago

Just hit this issue on upgrading to Stretch and although I did a clean install of the code per the readme, speed_hz was missing from spi.py and needed to be added.