Closed ratnick closed 10 years ago
It looks like you might already have an overlay loaded that uses the ADC, so PyBBIO is unable to configure it the way it needs.
Post the output of # cat /sys/devices/bone_capemgr.*/slots
Also, reboot and run that same script, then right afterwards get the output of # dmesg
and post that (or a pastebin of that).
Bingo!! Your comment led me to the conclusion that the Adafruit ADC is executed in a python script as part of the startup. When removing this from the boot sequence, your script executes fine. So thanks a lot for the pointer. I would not have located the error without it!!!
Having problems with Adafruit ADC on my Beaglebone Black giving very inconsistent readings on the analog inputs, I decided to check if it was a software problem by installing alexanderhiam/PyBBIO instead (well, on top - Adafruit still installed; don't know if it matters). I installed using:
opkg update && opkg install python-distutils python-setuptools python-mmap python-pyserial python-smbus python-pip
pip install PyBBIO
No errors during installation (see install log at the end).
Then I run a very simple script (based on https://gist.github.com/omundy/2698550):
from bbio import * def setup(): pass print "-----"
print "AIN0 [P9.39] - " + str(analogRead(A0))
and executing:
python 2test.py
Traceback (most recent call last): File "2test.py", line 47, in
print "AIN0 [P9.39] - " + str(analogRead(A0))
File "/usr/lib/python2.7/site-packages/bbio/platform/beaglebone/bone_3_8/adc.py", line 30, in analogRead
cape_manager.load(ADC_ENABLE_DTS_OVERLAY, auto_unload=False)
File "/usr/lib/python2.7/site-packages/bbio/platform/beaglebone/bone_3_8/cape_manager.py", line 22, in load
f.write(overlay)
IOError: [Errno 17] File exists
Thanks in advance. I really have a fight with analog reading of this BBB. Nikolaj
Install Log: root@beaglebone:~# pip install PyBBIO Downloading/unpacking PyBBIO Downloading PyBBIO-0.9.1.tar.gz (95kB): 95kB downloaded Running setup.py egg_info for package PyBBIO
Requirement already satisfied (use --upgrade to upgrade): pyserial in /usr/lib/python2.7/site-packages (from PyBBIO) Installing collected packages: PyBBIO Running setup.py install for PyBBIO PyBBIO device tree overlay directory not found, creating... Generating and compiling GPIO overlays... Done! Generating and compiling ADC overlays... Done! Installing PyBBIO... building 'bbio.platform.util._sysfs' extension arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -DSOFTFP -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c bbio/platform/util/_sysfs.c -o build/temp.linux-armv7l-2.7/bbio/platform/util/_sysfs.o arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -DSOFTFP -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.7/bbio/platform/util/_sysfs.o -L/usr/lib -lpython2.7 -o build/lib.linux-armv7l-2.7/bbio/platform/util/_sysfs.so building 'bbio.platform.util._spi' extension arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -DSOFTFP -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c bbio/platform/util/spimodule.c -o build/temp.linux-armv7l-2.7/bbio/platform/util/spimodule.o arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -DSOFTFP -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.7/bbio/platform/util/spimodule.o -L/usr/lib -lpython2.7 -o build/lib.linux-armv7l-2.7/bbio/platform/util/_spi.so /usr/bin/python /tmp/tmp0PnE0W.py removing /tmp/tmp0PnE0W.py
Successfully installed PyBBIO Cleaning up...