hackerspacesv / I32CTT

I32CTT is a lightweight protocol for control, transport & telemetry for the AT85RF233 and the Teensy.
GNU General Public License v3.0
1 stars 3 forks source link

self.__spi.open(0,0) IOError: [Errno 2] No such file or directory #1

Open neozerosv opened 5 years ago

neozerosv commented 5 years ago

After enabling SPI in a raspberry pi

python i32ctt_test.py 
Traceback (most recent call last):
  File "i32ctt_test.py", line 6, in <module>
    phy = driver_at86rf233(gpio)
  File "/home/pi/I32CTT/python/phy/at86rf233_rpi/driver.py", line 150, in __init__
    self.__spi.open(0,0)

It showed me that message. I had to find out wich ID of SPI i had with

ls /dev/spi*
/dev/spidev0.1

And then replace the

`self.__spi.open(0,0)`

with self.__spi.open(0,1) It worked for me like this blog said https://www.raspberrypi.org/forums/viewtopic.php?t=154317

I guess it should need to read that file to set those vatiables. like this code

import glob
spi_file = glob.glob("/dev/spi*")[0]
spiadd = [spi_file[-3:][:1],spi_file[-1:]]

self.__spi.open(spiadd[0],spiadd[1])

My enviroment:

cat /etc/os-release 
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

uname -a
Linux raspberrypim 4.14.79-v7+ #1159 SMP Sun Nov 4 17:50:20 GMT 2018 armv7l GNU/Linux

cat /proc/cpuinfo |tail -n 3
Hardware    : BCM2835
Revision    : a020d3

Check: https://elinux.org/RPi_HardwareHistory for HW version

neozerosv commented 5 years ago

The main issue is that i had both modules enabled,

/boot/config.txt
#dtoverlay=at86rf233

And also this module must be blacklisted so that no program or module take control of the SPI 0,0 and the python program be able to access it.

cat /etc/modprobe.d/raspi-blacklist.conf 
blacklist at86rf230

After that the SPI 0,0 is available.

ls -alh /dev/spi*
crw-rw---- 1 root spi 153, 0 May  9 22:32 /dev/spidev0.0
crw-rw---- 1 root spi 153, 1 May  9 22:32 /dev/spidev0.1

YAY.