Page 1 of 1

pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Oct 27, 2017 12:46 am
by tvonderhaar
The "PiFace digital rev 2" python interface stopped working on a PI 2 with the message:

pifacedigitalio.core.NoPiFaceDigitalDetectedError: No PiFace Digital board detected (hardware_addr=0, bus=0, chip_select=0).

Here is my uname -a output:
Linux bench 4.9.44+ #1029 Tue Aug 22 16:41:39 BST 2017 armv6l GNU/Linux

The board works with python on a PI 3 with an older version of the OS. The board also works
with the C programs "pifacedigital" and "example" based on the C library libpifacedigital.a.

It appears the python interface has gained a bug or broke on some other software upgrade it is
based on. Any help would be appreciated. BTW:I have done both an update and upgrade. I also
removed and reinstalled the pifacedigitalio packages.

Tom

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Oct 27, 2017 5:14 pm
by DougieLawson
Have you enabled SPI in raspi-config?

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Oct 27, 2017 10:11 pm
by tvonderhaar
Yes, I have the SPI enabled. In fact as stated in my original post:

The board also works with the C programs "pifacedigital" and "example" based on the C library libpifacedigital.a.

So the SPI and the board are working. Also, I created dameon based on the Python pifacedigitalio interface which has been running for over a year until my last upgrade. Something has creepped into the current release that broke the detection software(in pifacedigitalio) while initializing.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Oct 27, 2017 10:55 pm
by DougieLawson
The stuff in /proc/cpuinfo has changed. All systems now identify as "Hardware : BCM2835", so that can't be used to determine which flavour of RPi you're running.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Sun Oct 29, 2017 4:24 am
by tvonderhaar
I have discovered the problem. The latest kernel's SPI driver has changed the default of the SPI serial speed from 500Khz to 125Mhz. unfortunately the pifacedigitalio SPI code does not initialize the SPI speed nor does it specify it in the ioctl() option to set the speed temporarily. I have modified the spi.py module to use the temporary speed of 10Mhz. The PiFace digital 2 now works. Once I discovered the problem was an SPI default parameter by comparing to the C library libpifacedigital.a SPI's open() code, I googled changes in the Raspbian SPI driver and found that it is being addressed. As of 10/29/17 12:21PM I don't think the spi.py module has been fixed via a apt-get update.
Tom

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Sat Nov 04, 2017 10:48 am
by garbur
i think i have the same problem,
can u try to tell me how i can change the speed?

christoph

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Tue Nov 07, 2017 10:00 pm
by neurobot
You can search where is your spi.py with a 'find' command => find / -name spi.py > search_result.txt
Look the search reasult with more search_result.txt
[/b]For me, spi.py is in this folder : /usr/local/lib/python3.5/dist-packages/pifacecommon/

we can edit spi.py and look in this :

Code: Select all

# create the spi transfer struct
        transfer = spi_ioc_transfer(
            tx_buf=ctypes.addressof(wbuffer),
            rx_buf=ctypes.addressof(rbuffer),
            len=ctypes.sizeof(wbuffer),
        )
transfer contains all parameters for spi communication. You can see in module where spi_ioc_transfer is define. At the beginning of spi.py, spi_ioc_transfer is import from .linux_spi_spidev.py where we can look this definition :

Code: Select all

class spi_ioc_transfer(ctypes.Structure):
    """<linux/spi/spidev.h> struct spi_ioc_transfer"""

    _fields_ = [
        ("tx_buf", ctypes.c_uint64),
        ("rx_buf", ctypes.c_uint64),
        ("len", ctypes.c_uint32),
        ("speed_hz", ctypes.c_uint32),
        ("delay_usecs", ctypes.c_uint16),
        ("bits_per_word", ctypes.c_uint8),
        ("cs_change", ctypes.c_uint8),
        ("pad", ctypes.c_uint32)]
So we can modify SPI speed in spi.py in add speed_hz=ctypes.c_uint32(15000).

We obtain in spi.py :

Code: Select all

# 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)
        )
Best,
neurobot

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Thu Nov 09, 2017 10:31 am
by garbur
thank you so much,
problem now is fixed!

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Thu Apr 12, 2018 7:00 am
by klintkrossa
It works so much better if you use a comma.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Nov 02, 2018 12:33 pm
by balanga
I've just hit this 'No PiFace Digital board detected ' problem, and am not exactly sure how to fix it.

Can anyone summarise what steps I need to take to fix it?

Code: Select all

uname -a
shows
Linux raspberrypi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux
This is on a Raspberry Pi 2 with a PiFace Digital 2 attached.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Mon Nov 05, 2018 2:32 pm
by balanga
Managed to get it working finally after much trial and error, although I would like to see some simplified instructions for getting it installed from scratch on a new installation.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Mon Nov 05, 2018 7:31 pm
by DougieLawson
balanga wrote:
Mon Nov 05, 2018 2:32 pm
Managed to get it working finally after much trial and error, although I would like to see some simplified instructions for getting it installed from scratch on a new installation.
Write up the instructions and publish on a blog somewhere.
Re-write the instructions and do a pull request (PR) against the PiFace GitHub to get their official docs updated.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Thu Nov 08, 2018 3:05 pm
by balanga
DougieLawson wrote:
Mon Nov 05, 2018 7:31 pm
balanga wrote:
Mon Nov 05, 2018 2:32 pm
Managed to get it working finally after much trial and error, although I would like to see some simplified instructions for getting it installed from scratch on a new installation.
Write up the instructions and publish on a blog somewhere.
Re-write the instructions and do a pull request (PR) against the PiFace GitHub to get their official docs updated.
Here's a little script I came up which seems to get my PiFaceDigital 2 blinking.... starting from a pristine install using this image:-

https://downloads.raspberrypi.org/raspbian_lite_latest

Code: Select all

login:-

sudo sed -i 's/#dtparam=spi=on/dtparam=spi=on/' /boot/config.txt
sudo apt-get install git
git clone git://github.com/piface/pifacedigitalio.git
git clone git://github.com/piface/pifacecommon.git
cd pifacecommon/
sudo python3 setup.py install
cd ../pifacedigitalio
sudo python3 setup.py install
reboot

login:-

python3 pifacedigitalio/examples/blink.py
This was adapted from another post by https://github.com/oh3nfc in https://github.com/piface/pifacecommon/issues/24

It worked for me without apt-get update apt-get upgrade or raspi-config.

YMMV.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Fri Mar 08, 2019 5:26 pm
by 2245maxx
Thank you for the code piface2 back up & blinking on RBPi 3 B+.

Re: pifacedigitalio stopped working on PI 2 after last upgrade.

Posted: Sat Sep 28, 2019 3:20 pm
by pedromferreira
Thank you for the code! It works with piface 1 (old board) & blinking on RBPi 1 B+ (512M old board running raspbian-buster).