I just set up an spi python test.
first i added the user openhab to the spi group and ran the spi test from the rasberry foundation page to test if it works.
sudo adduser openhab spi
downloaded the exaple and run it as openhab.
sudo -u openhab ./spidev_test -D /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)
FF FF FF FF FF FF
...
So this works.
Then i downloaded the adafruit gpio and installed it, which is not neccessary to get this test running but i had peek into the code. Also had a look into this manual.
I set up an example to trassmit some spi data.
spiTestpython.py
#!/usr/bin/env python
import spidev
import time
spi = spidev.SpiDev()
spi.open(0,0)
spi.max_speed_hz =7629
resp = spi.xfer2([0xaa])
print resp[0]
Made the skript executable
chmod +x spiTestpython.py
And run it as user openhab
sudo -u openhab ./spiTestpython.py
0
The output of my logic analyzer suggest that it works. ![]()
As the postet error line in the SPI.py
is the opening of the spi device
self._device.open(port, device)
And in my test i also opened the spi device, this steps above could help you getting it running.