piface / pifacecommon

Common functions for interacting with PiFace products
GNU General Public License v3.0
42 stars 30 forks source link

Piface2 board not detected (Rpi3 B) #24

Closed jmbillings closed 6 years ago

jmbillings commented 6 years ago

Noob at this, but it looks like I'm missing a trick to get the board working. I've got a Piface 2 and a Pi 3 B.

Started following the instructions, SPI enabled, rebooted, updates done. The Pi is set up fresh with the latest (scratch?) install.

The install commands didn't work (not found). I found alternative install instructions using PIP which did work:

pip install pifacedigitalio
pip install pifacecommon

for 3(.5)
pip3 install pifacedigitalio
pip3 install pifacecommon

So now I load up Python (or Python3, same problem) and try:

>>> import pifacedigitalio as pfd
>>> pfd.init()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/.local/lib/python3.5/site-packages/pifacedigitalio/core.py", line 166, in init
    raise failed_boards[0]
  File "/home/pi/.local/lib/python3.5/site-packages/pifacedigitalio/core.py", line 162, in init
    init_board)
  File "/home/pi/.local/lib/python3.5/site-packages/pifacedigitalio/core.py", line 82, in __init__
    self.init_board()
  File "/home/pi/.local/lib/python3.5/site-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).

Any ideas? I've seen some people suggest reverting back to an older "jessie" build, but other topics suggest people made it work. I also saw reference to commenting out a line in a "blacklist" file, however mine is empty.

jmbillings commented 6 years ago

Incidentally, this: https://github.com/bulletmark/pifaceio does work- I can perform a 'write' and hear the relay click and an LED illuminates, so I guess the board is physically okay.

matthub commented 6 years ago

For me the hint from joppep at https://www.raspberrypi.org/forums/viewtopic.php?t=170606 solved the issue, copying here for reference:

Within spi.py (at my system it was at /usr/local/lib/python3.5/dist-packages/pifacecommon/spi.py) add a line speed_hz=ctypes.c_uint32(100000) to the transfer struct so that it looks as following

 # 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) 
        )
johnfrancisgit commented 6 years ago

@matthub Thanks! I'm using the pifacerelayplus board and it wasn't being detected. Using your fix it works!

feanor12 commented 6 years ago

Is this fixed?

jmbillings commented 6 years ago

Board appears working now, so yep, happy to close this.

jwarnier commented 6 years ago

I got the same issue on a Pi 1 model B+, and the suggested fix does not work.

I guess it probably has a different max speed? I tried (pure guess) already the following values, without success: 100000, 1000000, 150000, 15000 How do I know the actual value to use?

Thanks

oh4va commented 6 years ago

I got a LED blinking on a Pi1 B using next commands: git clone git@github.com:piface/pifacedigitalio.git git clone https://github.com/piface/pifacecommon.git cd pifacecommon/ sudo python setup.py install cd ../pifacedigitalio/examples/ sudo python blink.py

I hope this helps

jwarnier commented 5 years ago

Any chance this issue is fixed thanks to #23 ?