tvonderhaar
Posts: 3
Joined: Fri Oct 27, 2017 12:20 am

pifacedigitalio stopped working on PI 2 after last upgrade.

Fri Oct 27, 2017 12:46 am

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

User avatar
DougieLawson
Posts: 36310
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

Fri Oct 27, 2017 5:14 pm

Have you enabled SPI in raspi-config?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

tvonderhaar
Posts: 3
Joined: Fri Oct 27, 2017 12:20 am

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

Fri Oct 27, 2017 10:11 pm

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.

User avatar
DougieLawson
Posts: 36310
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

Fri Oct 27, 2017 10:55 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

tvonderhaar
Posts: 3
Joined: Fri Oct 27, 2017 12:20 am

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

Sun Oct 29, 2017 4:24 am

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

garbur
Posts: 2
Joined: Sat Nov 04, 2017 10:45 am

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

Sat Nov 04, 2017 10:48 am

i think i have the same problem,
can u try to tell me how i can change the speed?

christoph

neurobot
Posts: 1
Joined: Tue Nov 07, 2017 6:47 pm

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

Tue Nov 07, 2017 10:00 pm

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

garbur
Posts: 2
Joined: Sat Nov 04, 2017 10:45 am

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

Thu Nov 09, 2017 10:31 am

thank you so much,
problem now is fixed!

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

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

Thu Apr 12, 2018 7:00 am

It works so much better if you use a comma.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

balanga
Posts: 118
Joined: Sat Aug 23, 2014 6:56 pm

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

Fri Nov 02, 2018 12:33 pm

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.

balanga
Posts: 118
Joined: Sat Aug 23, 2014 6:56 pm

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

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.

User avatar
DougieLawson
Posts: 36310
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

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

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

balanga
Posts: 118
Joined: Sat Aug 23, 2014 6:56 pm

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

Thu Nov 08, 2018 3:05 pm

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.

2245maxx
Posts: 1
Joined: Fri Mar 08, 2019 4:56 pm

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

Fri Mar 08, 2019 5:26 pm

Thank you for the code piface2 back up & blinking on RBPi 3 B+.

pedromferreira
Posts: 1
Joined: Tue Aug 13, 2019 2:32 pm

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

Sat Sep 28, 2019 3:20 pm

Thank you for the code! It works with piface 1 (old board) & blinking on RBPi 1 B+ (512M old board running raspbian-buster).

Return to “Automation, sensing and robotics”