Giter Club home page Giter Club logo

adafruit-beaglebone-io-python's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit-beaglebone-io-python's Issues

PWM refuses to start for all pins other than P8_13

I've been trying to use BBIO to drive three servos. But I am finding (both on the current Angstrom and on Debian Wheezy 7.2) that it will only work on pin P8_13.

If I change the servo.py example to use P8_19, P9_14, or P9_16, I see
RuntimeError: You must start() the PWM channel first

I've installed BBIO with pip install Adafruit_BBIO, and I'm currently testing on Debian from http://rcn-ee.net/deb/flasher/wheezy/BBB-eMMC-flasher-debian-7.2-2013-10-25.img.xz

My Angstrom experiments were on https://s3.amazonaws.com/angstrom/demo/beaglebone/BBB-eMMC-flasher-2013.06.20.img.xz

I think that (because I'm using the latest versions in all these cases) this is not the same as issue 22. Any ideas ? :-)

Thanks,

Richard

GPIO example does not working under Angstrom current version

I cannot get any GPIO lines to toggle nor do I see any changes in slot entries in /sys/devices/bone_capemgr.8/slots or exported PGIO's in /sys/class/gpio/?

I tried
import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("P9_12", GPIO.OUT)
GPIO.output("P9_12", GPIO.HIGH)

However, I can control GPIO 60 P9_12 using a device overlaid I obtained from a tutorial.

If I perform the following I can control GPIO 60 P9_12 Using a device overlaid from github.com/derekmolloy/boneDeviceTree/

and
echo DM-GPIO-Test > /sys/devices/bone_capemgr.8/slots
echo 60 > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio60direction
echo 1 > /sys/class/gpio/gpio60/value

I have noticed on the Web that some documentation references /sys/devices/bone_capemgr.8/slots and some /sys/devices/bone_capemgr.9/slots I'm not sure if this is random or a versioning issue?

I'm running
uname -a
Linux beaglebone 3.8.13 #1 SMP Tue Jun 18 02:11:09 EDT 2013 armv7l GNU/Linux
Linux version 3.8.13 (koen@rrMBP) (gcc version 4.7.3 20130205 (prerelease) (Linaro GCC 4.7-2013.02-01) ) #1 SMP Tue Jun 18 02:11:09 EDT 2013

Question
if I don't run GPIO.cleanup() should I still see slot entries in /sys/devices/bone_capemgr.8/slots and exported PGIO's in /sys/class/gpio/?

Calling SPI cshigh method results in exit without warning

Hi,

See reproducer below. For me, if I comment out the 'print spi.cshigh' line, the routine runs indefinitely, but without it, it exits without warning after 37 iterations. For info, I'm running debian-armhf 3.8.13-bone30 with Adafruit_BBIO-0.0.18.

Any help appreciated!

Regards,
Graham

import time
from threading import Timer
from Adafruit_BBIO.SPI import SPI

spi = SPI(0,0)

def scheduleScan():
        Timer(0.005, scan).start()

def scan():
        print "scanning"
        print spi.cshigh
        scheduleScan()

scheduleScan()

SPI.xfer crashes python after 3 calls

The SPI xfer and xfer2 methods result in a crashing Python.
On the 3rd call to xfer(), no SPI signals are generated and and empty array is returned. A subsequent call will then terminate with a "Fatal Python error" - see attached python output

System is a clean Angstrom release (June 18) with Adafruit_BBIO 0.18

Rob

Python 2.7.3 (default, May 29 2013, 21:25:00)
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
]]] from Adafruit_BBIO.SPI import SPI
]]] spi = SPI(0,0)
]]] data = [64, 192, 255]
]]] spi.xfer(data)
[255, 255, 255]
]]] spi.xfer(data)
[255, 255, 255]
]]] spi.xfer(data)
[]
]]] spi.xfer(data)
Fatal Python error: GC object already tracked
Aborted
root@beaglebone:~#

GPIO not able to pull pin high or low

I'm running ubuntu 12.04 on BBB. Cloned and installed from this repo on build ff6f11a

I can't seem to get the GPIO pins working off of the example code. Here's what I've tried:

import Adafruit_BBIO.GPIO as GPIO
GPIO.setup("P8_3", GPIO.OUT)
GPIO.output("P8_3", GPIO.LOW)

I've also tried using the GPIO1_6 syntax and got the same results. I've tried on P8_10 and P8_14 as well.

I'm running the script with sudo python gpio.py

The pin works if I echo the pin and state into /sys/class

I ran the tests and they've all passed:

ubuntu@ubuntu-armhf:~/adafruit-beaglebone-io-python$ sudo py.test
============================= test session starts ==============================
platform linux2 -- Python 2.7.3 -- pytest-2.5.1
collected 52 items

test/test_adc.py ......
test/test_gpio_input.py ..
test/test_gpio_output.py ......
test/test_gpio_setup.py ..........
test/test_pwm_setup.py .........................
test/test_uart.py ...

========================== 52 passed in 17.30 seconds ==========================

Is there any more diagnosing I can do on this?

PWM duty cycle is inverted

I am using BBIO with Angstrom and the original BeagleBone (white).
Every time I set a PWM duty cycle to a value x, the output duty cycle is actually (100% - x). For instance, if I set to 25%, I get 75%.

GPIO callback causing segmentation fault

I am attempting to perform some tasks on a rising edge of the P8 14, but everytime after the callback function ends, there's a segmentation fault and the script stops.

The following counter in incremented, the line is properly printed, but right after that comes the error message.

import Adafruit_BBIO.GPIO as GPIO

counterX = 0

def updateEncoderX(channel):
    global counterX
    counterX = counterX + 1
    print "Encoder counter updated: %d" % counterX

GPIO.setup("P8_14", GPIO.IN)
GPIO.add_event_detect("P8_14", GPIO.RISING, callback=updateEncoderX)

try:
    while 1:
        pass

except KeyboardInterrupt:
    GPIO.cleanup()
GPIO.cleanup()

GPIO.setmode(x) missing

GPIO.setmode(x) is missing. It should be either a dummy function or it should do something meaningful.

Currently when 'P8_10' or 'GPIO0_10' is for instance used. with GPIO.setmode(BOARD or BCM) the additional syntax of using integer 10 could be mapped to either P8_10 or GPIO0_10 .

Device Tree Overlays failures?

The test below fails on Ubuntu 13.04 (Linux bbb1 3.8.12-bone17 #1 SMP Thu May 9 12:04:53 UTC 2013 armv7l armv7l armv7l GNU/Linux) which is at this point not a problem.

I wonder if this has to do with my system being Ubuntu or with the new Device Tree support in the latest distributions?

BTW some good information on http://hipstercircuits.com/capture-input-events-via-gpio-on-beaglebone-black/ and http://derekmolloy.ie/


test/test_gpio_input.py F

self =
def test_input(self):
    GPIO.setup("P8_10", GPIO.IN)
    #returned as an int type
    input_value = GPIO.input("P8_10")
    #value read from the file will have a \n new line
  value = open('/sys/class/gpio/gpio68/value').read()

E IOError: [Errno 2] No such file or directory: '/sys/class/gpio/gpio68/value'

test/test_gpio_input.py:15: IOError

Request for ChipCon SPI Support

The SPI implementation doesn't support radio chips like the CC2420 or CC2520.

The ChipCon radios/processors use slightly different SPI -- where when the processor clocks in the first byte over MOSI to the radio, the radio returns a status byte over MISO. I.e. byte 0 bit 8 is set on MOSI, SCLK comes high, MISO is read to get byte 0 bit 8 of the status byte, and then SCLK goes low (example at http://sourceforge.net/p/goodfet/code/HEAD/tree/trunk/firmware/apps/radios/ccspi.c in function ccspitrans8).

Getting SegFault when using edge detection callback function

I am having an issue that I cannot seem to track down. The test code below simply adds falling edge detection to a pin with a call back function to print out to the command prompt. The issue is I get a SegFault just after the callback function is executed and I have no clue where to look. Running a trace it appears to be a stack issue. Any ideas where the problem is?

Output:
gdb output

Test Code:

import Adafruit_BBIO.GPIO as GPIO
import sys
import time
sys.settrace

class Motion:
    def __init__(self, relays,sensors,timestamp,timeout,status):
        self.relays = relays        #List of relays to be controlled
        self.sensors = sensors      #List of sensors to control these relays
        self.timestamp = timestamp  #Time of last motion detected
        self.timeout = timeout      #Turn off relays if no motion detected in this interval
        self.status = status        #Relays on = '1', Relays off = '0'

    def __str__(self):
        return "Relays: {0}, Sensors: {1}, Timestamp: {2}, Timeout: {3}, Status: {4}".format(self.relays,self.sensors,self.timestamp,self.timeout,self.status)

    def MOTION_DETECTED(self, GPIOport):
        print self

def GPIO_MOTION_ON(motionName):
    for index in motionName.sensors:
        GPIO.add_event_detect(index, GPIO.FALLING, callback=motionName.MOTION_DETECTED, bouncetime=motionName.timeout)
    print "Edge detection added"


#START TEST
MotionEvent1 = Motion(['P8_7'], ['P9_12'], int(time.time()), 1000, 0)

print "Turn on P8_7 from P9_12 falling edge"
GPIO_MOTION_ON(MotionEvent1)

while True:
    print "main loop"

gcc not found (arm-linux-gnueabihf-gcc hardcoded?)

'sudo python setup.py install' works fine on Ubuntu 13.04 (after installing gcc). However, gcc was not automatically found. It looks like arm-linux-gnueabihf-gcc is hardcoded instead.

Doing an 'alias arm-linux-gnueabihf-gcc=gcc' fixed the problem.

Probem with PWM pairs

I get a "RuntimeError: You must start() the PWM channel first" whenever I use two "contiguous" PWM pins. For example, If I want to use P9_29 and P9_31, which correspond to EHRPWM0A and EHRPWM0B (or P9_14 and P9_16), I can start them with PWM.start, and I can change the duty cycle of the first one without problems, but when I try to call PWM.set_duty_cycle on the second one, I get the aforementioned error.

Thanks in advance!

spi readbytes(1) always returns [255] or in hex [0xff]

Hi,
Sorry if this isnt the correct place for this. Ive been trying to get api interfaced with an ADC (MCP3008 specifically). I believe the DT overlay has been correctly applied (Ive follow Robert C. Nelson's blog) and what I've tried in python to read in a value is:

import Adafruit.SPI as spi
obj=spi.SPI(0,0)
obj.readbytes(1)

and invariably get the value 255. Im at a loss of what Im doing wrong as Im fairly confident that I have wired the BBB and MCP3008 up correctly. Is there something obvious that I am missing. Thanks!

Adafruit_BBIO.GPIO

Hello,

after installing this library i am getting this error.

ubuntu@ubuntu-armhf:~/desktop/adafruit-beaglebone-io-python-master$ sudo python test.py
Traceback (most recent call last):
File "test.py", line 1, in
import Adafruit_BBIO.GPIO as GPIO
ImportError: No module named GPIO

can anybody help me with this.
I used distribute 0.6.49 for installation.
thanks

set polarity function not working

The pwm_set_polarity function in c_pwm.c is still not working. At the moment it writes a 0 to the duty file instead of the polarity file. You need a fd_polarity in your pwm struct and write to that instead.

GPIO access as user even with rigth permissions to /sys doesn't work

Hi
My problem is described here http://stackoverflow.com/questions/18926979/beaglebone-black-adafruit-io-python-library-gpio-user-permissions

In short: GPIO works only with root even when all permissions to /sys are OK for user and I can control gpio from user's shell, but not with python.
By experimenting I found that it works if you add delay in event_gpio.c in gpio_export function after closing file:

len = snprintf(str_gpio, sizeof(str_gpio), "%d", gpio);
write(fd, str_gpio, len);
close(fd);
volatile int i = 0; // very cruel delay
for (i = 0; i < 100000000; i++);

// add to list
new_gpio = malloc(sizeof(struct gpio_exp));

fsync(fd) and fdatasync(fd) before closing don't help. It seems like some kind of race condition which shows up only for regular user.

PWM only works for 2 outputs at once

I'm trying to get 4 motors running at once with a PWM signal and ESC.
However, i'm unable to get more than 2 motors running at the same time.

Running all the motors separate works fine, also every combination of 2 motors at once. But it doesn't start the 3rd and 4th motor, if I try to set the duty cycle, I get the next error:

Traceback (most recent call last):
  File "test.py", line 27, in <module>
    PWM.set_duty_cycle("P8_19", duty)
RuntimeError: You must start() the PWM channel first

I think something goes wrong with the initialization of the 3rd and 4th PWM pin. If I list the files in the OCP directory, I get this:

root@beaglebone:~# ls /sys/devices/ocp.2/pwm_test_P8_13.24/
driver  duty  modalias  period  polarity  power  run  subsystem  uevent
root@beaglebone:~# ls /sys/devices/ocp.2/pwm_test_P8_19.25/
modalias  power  subsystem  uevent
root@beaglebone:~# ls /sys/devices/ocp.2/pwm_test_P9_14.26/
driver  duty  modalias  period  polarity  power  run  subsystem  uevent
root@beaglebone:~# ls /sys/devices/ocp.2/pwm_test_P9_16.27/
modalias  power  subsystem  uevent

As you can see, P8_19 and P9_16 are missing some crucial files here.
Is there something I should be able to fix, or is something wrong in the code.

Basic Info:
BeagleBone Black A5C

Angstrom Version:

Angstrom v2012.12 (Core edition)
Built from branch: angstrom-staging-yocto1.3
Revision: 93f9f674059d8003a84ef1caad39339c2d940d4d
Target system: arm-angstrom-linux-gnueabi

Linux Version:

Linux beaglebone 3.8.13 #1 SMP Tue Jun 18 02:11:09 EDT 2013 armv7l GNU/Linux

Raise IOError exception when fopen fails

On Debian 7.1, /sys/devices/bone_capemgr.9/slots is owned by root with 644 permissions by default. This means that the call to fopen in load_device_tree() will fail with Permission Denied. In this case, load_device_tree() returns -1, presumably as an error indicator. In initialize_adc() this check

if (!adc_initialized && load_device_tree("cape-bone-iio"))

will not catch the fact that the call to load_device_tree() failed. Even if it did, the return value of initialize_adc() is not checked in py_adc_setup().

Installation doesn't work on Ubuntu

I tried installing the newest version on ubuntu today, and got multiple errors.

I got the following error:

dtc: invalid option -- '@' || 4 times, followed by the help of DTC

Traceback (most recent call last):
File "setup.py", line 25, in
builder.copy()
File "/home/ubuntu/adafruit-beaglebone-io-python/overlays/builder.py", line 15, in copy
shutil.move("overlays/ADAFRUIT-SPI0-00-00A0.dtbo", "/lib/firmware/ADAFRUIT-SPI0-00-00A0.dtbo")
File "/usr/lib/python2.7/shutil.py", line 301, in move
copy2(src, real_dst)
File "/usr/lib/python2.7/shutil.py", line 130, in copy2
copyfile(src, dst)
File "/usr/lib/python2.7/shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'overlays/ADAFRUIT-SPI0-0000A0.dtbo'

After removing the @ option from the overlays/builder.py I got the error:

DTC: dts->dtb on file "overlays/ADAFRUIT-SPI0-00-00A0.dts"
Error: overlays/ADAFRUIT-SPI0-00-00A0.dts:2.2-8 syntax error
FATAL ERROR: Unable to parse input tree

uname -a outputs:

Linux arm 3.8.13-bone21 #1 SMP Fri Jun 14 03:10:29 UTC 2013 armv7l armv7l >armv7l GNU/Linux

Anything i'm doing wrong, or is the install just not compatible with ubnutu (yet)?

Memory leak in SPI.readbytes()

Memory quickly fills when running following code:

import Adafruit_BBIO.SPI
spi = Adafruit_BBIO.SPI.SPI(0,0)
while True:
spi.readbytes(1)

I do not see the effect with spi.writebytes(). Seen on a Bealebone Black and an up to date Angstrom.

SPI writebytes / xfer / xfer2 clocks out arrays of bytes in reverse order

Just wanted to open this as a separate issue, as I'm experiencing the same behaviour as tweekzilla as mentioned here:

#47

That is, that executing spi.writebytes([0x44, 0x88, 0xBB, 0xDD]) clocks out in reverse order (i.e. 0xDD, 0xBB, 0x44, 0x88). I can confirm the same behaviour with xfer and xfer2. Is this a problem with the spidev C++ implementation, or with the bindings?

Python3 Support?

Does this library support Python3? It's mentioned in the classifiers in the setup.py script, but I'm not sure how to go about installing this library for Python3. I tried running 2to3 on the library followed by an install, but the build was broken (and this is probably a really bad approach!).

PWM sine wave

Hello, I am trying to create sine wave from the PWM (io-python lib), the thing is that I don't know:

  1. sample frequency? (5 Khz?)
  2. PWM resolution? ( 12 bit? )
  3. how to mange the interrupts?

Thank you!

Internal pull down resistors are always enabled

The parameter "pull_up_down" to GPIO.setup() has no effect. The mode of the input pins always remain set to pull-down mode.

This can be observed by connecting a 100k ohm resistor to 3.3V and the other end to an input pin, such as P8_16.

If the internal pull down is disabled (by specifying pull_up_down=GPIO.PUD_NONE), a voltmeter on P8_16 should read close to 3.3V. However, the voltage is significantly lower (nearly 1 volt lower), as it could be explained by an internal pull down resitor. Changing the pull_up_down mode to GPIO.PUD_UP or GPIO.PUD_NONE has no effect on voltage.

import Adafruit_BBIO.GPIO as GPIO
import time

GPIO.setup("P8_16", GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
print "P8_16 set to pull down mode"
time.sleep(4.0)

GPIO.setup("P8_16", GPIO.IN, pull_up_down=GPIO.PUD_UP)
print "P8_16 set to pull up mode"
time.sleep(4.0)

GPIO.setup("P8_16", GPIO.IN, pull_up_down=GPIO.PUD_NONE)
print "P8_16 disabled internal resistor"
time.sleep(4.0)

Cannot set spi.lsbfirst

Setting spi.lsbfirst = True

throws:

IOError: [Errno 22] Invalid argument

You can set spi.lsbfirst = False

Two tests fail on debian wheezy install from armhf.com

=================================== FAILURES ===================================
_________________________ TestPwmSetup.test_start_pwm __________________________

self = <test_pwm_setup.TestPwmSetup instance at 0x6edaa8>

    def test_start_pwm(self):
        PWM.start("P9_14", 0)

        files = os.listdir('/sys/devices')
        ocp = '/sys/devices/'+[s for s in files if s.startswith('ocp')][0]
        files = os.listdir(ocp)
        pwm_test = ocp+'/'+[s for s in files if s.startswith('pwm_test_P9_14')][0]

        assert os.path.exists(pwm_test)
>       duty = open(pwm_test + '/duty').read()
E       IOError: [Errno 2] No such file or directory: '/sys/devices/ocp.2/pwm_test_P9_14.12/duty'

test/test_pwm_setup.py:19: IOError
_____________________ TestPwmSetup.test_pwm_duty_modified ______________________

self = <test_pwm_setup.TestPwmSetup instance at 0x6835f8>

    def test_pwm_duty_modified(self):
        PWM.start("P9_14", 0)

        files = os.listdir('/sys/devices')
        ocp = '/sys/devices/'+[s for s in files if s.startswith('ocp')][0]
        files = os.listdir(ocp)
        pwm_test = ocp+'/'+[s for s in files if s.startswith('pwm_test_P9_14')][0]

        assert os.path.exists(pwm_test)
>       duty = open(pwm_test + '/duty').read()
E       IOError: [Errno 2] No such file or directory: '/sys/devices/ocp.2/pwm_test_P9_14.12/duty'

test/test_pwm_setup.py:68: IOError
===================== 2 failed, 44 passed in 3.69 seconds ======================

I am not using any pwm stuff and don't really have the time to get into it. but I thought I would post these in case someone else wants to fix them.

Thanks,
Chris Desjardins

Using an int for PWM.set_duty_cycle returns unclear error

With the following code:

#!/usr/bin/python

import Adafruit_BBIO.PWM as PWM
import time

PWM.start("P8_13", 100)

for i in range(100, 0, -1):
        PWM.set_duty_cycle("P8_13", i) # Passing duty cycle as an int
        time.sleep(.1)

PWM.stop("P8_13")
PWM.cleanup()

PWM.set_duty_cycle expects a float for the duty cycle value. If you pass an int, the error message is unclear:

Traceback (most recent call last):
  File "pwm.py", line 9, in <module>
    PWM.set_duty_cycle("P8_13", i)
RuntimeError: You must start() the PWM channel first

Suggested solution: handle ints as well as float values, or make the error clearer that the function expects a float value, not integer.

ubuntu install Adafruit_BBIO error

ubuntu@arm:~$ sudo pip install Adafruit_BBIO
Downloading/unpacking Adafruit-BBIO
Downloading Adafruit_BBIO-0.0.10.tar.gz
Running setup.py egg_info for package Adafruit-BBIO
The required version of distribute (>=0.6.45) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.

UART example broken with Angstrom

Here is my Angstrom version .

[root@beaglebone firmware]$ cat /etc/angstrom-version
Angstrom v2012.12 (Core edition)
Built from branch: angstrom-staging-yocto1.3
Revision: 2ac8ed60f1c4152577f334b223b9203f57ed1722
Target system: arm-angstrom-linux-gnueabi

[root@beaglebone firmware]$ cat /etc/dogtag
Cloud9 GNOME Image 2013.09.04

Trying the simple UART1 setup

[root@beaglebone:~# python -c 'import Adafruit_BBIO.UART as UART; UART.setup("UART1")'
return 1 lookup_uart_by_name

the error is dmesg

[ 113.031095] bone-capemgr bone_capemgr.8: part_number 'ADAFRUIT', version 'N/A'
[ 113.031169] bone-capemgr bone_capemgr.8: slot #7: generic override
[ 113.031187] bone-capemgr bone_capemgr.8: bone: Using override eeprom data at slot 7
[ 113.031205] bone-capemgr bone_capemgr.8: slot #7: 'Override Board Name,00A0,Override Manuf,ADAFRUIT'
[ 113.031305] bone-capemgr bone_capemgr.8: slot #7: Requesting part number/version based 'ADAFRUIT-00A0.dtbo
[ 113.031324] bone-capemgr bone_capemgr.8: slot #7: Requesting firmware 'ADAFRUIT-00A0.dtbo' for board-name 'Override Board Name', version '00A0'
[ 113.042374] bone-capemgr bone_capemgr.8: failed to load firmware 'ADAFRUIT-00A0.dtbo'

Looking at /lib/firmware/ I see that ADAFRUIT-00A0.dtbo is not present. However /lib/firmware does have the below UART dtbo files

root@beaglebone:# ls -l /lib/firmware/_ADAFRUIT_UART*
-rw-r--r-- 1 root root 865 Nov 11 2013 /lib/firmware/ADAFRUIT-UART1-00A0.dtbo
-rw-r--r-- 1 root root 865 Nov 11 2013 /lib/firmware/ADAFRUIT-UART2-00A0.dtbo
-rw-r--r-- 1 root root 865 Nov 11 2013 /lib/firmware/ADAFRUIT-UART4-00A0.dtbo
-rw-r--r-- 1 root root 865 Nov 11 2013 /lib/firmware/ADAFRUIT-UART5-00A0.dtbo
root@beaglebone:
#

I guessing that its looking for the wrong file ?.

only 5 PWM pins possible at a time

Using Angstrom, any of the PWM pin pairs (say "9_14" and "9_16") are not available to be used at the same time.

I believe the actual hardware limitation here is that you must use the same frequency on the two pins, but you may have a different duty cycle.

BBIO does not seem to enable the pins even though the hardware should allow it.

This only allows the use of 5 PWM pins at the same time even after disabling HDMI.

Try for instance:
PWM.start("P9_16", 50, 25000, 1)
PWM.start("P9_22", 50, 25000, 1)
PWM.start("P9_28", 50, 25000, 1)
PWM.start("P9_42", 50, 25000, 1)
PWM.start("P8_13", 50, 25000, 1)

Then try to enable either "P8_34" or "P8_19", and the script will look like it is working, and even add the line to the slots file, but a scope reading will confirm otherwise.

Segfault after many analog reads

If I run the following code:

import Adafruit_BBIO.ADC as ADC
import time

ADC.setup()

for x in range(0,10000):
    ADC.read("AIN1")
    print x

Then the code consistently segfaults after printing 1020. Adding a time.sleep(.01) to the loop doesn't fix it.

I'm running on arch. The PyBBIO library does not have this issue (after fixing their code to get around a pwm issue), so I know the operating system is capable of reading that fast (or that many times.)

Here is a backtrace with gdb:

#0  0xb6cfeee4 in fseek () from /usr/lib/libc.so.6
#1  0xb69c9c6c in read_value () from /root/BeagleCommand/lib/python2.7/site-packages/Adafruit_BBIO-0.0.8-py2.7-linux-armv7l.egg/Adafruit_BBIO/ADC.so
#2  0xb69c9a30 in py_read () from /root/BeagleCommand/lib/python2.7/site-packages/Adafruit_BBIO-0.0.8-py2.7-linux-armv7l.egg/Adafruit_BBIO/ADC.so
#3  0xb6ed53d8 in PyCFunction_Call () from /usr/lib/libpython2.7.so.1.0
#4  0xb6f32db4 in PyEval_EvalFrameEx () from /usr/lib/libpython2.7.so.1.0
#5  0xb6f341a8 in PyEval_EvalCodeEx () from /usr/lib/libpython2.7.so.1.0
#6  0xb6f34304 in PyEval_EvalCode () from /usr/lib/libpython2.7.so.1.0
#7  0xb6f4d810 in run_mod () from /usr/lib/libpython2.7.so.1.0
#8  0xb6f4e5f8 in PyRun_FileExFlags () from /usr/lib/libpython2.7.so.1.0
#9  0xb6f4f028 in PyRun_SimpleFileExFlags () from /usr/lib/libpython2.7.so.1.0
#10 0xb6f6048c in Py_Main () from /usr/lib/libpython2.7.so.1.0
#11 0xb6cb00d8 in __libc_start_main () from /usr/lib/libc.so.6
#12 0x00008600 in _start ()

Detecting Interrupts and Distinguishing between Rising and Falling

Considering the following code, in which we're looking for rising or falling on an interrupt:

GPIO.add_event_detect("P9_12", GPIO.BOTH) # look for RISING or FALLING

if GPIO.event_detected("P9_12"): # Executed in either case
  print "event detected!"

while True:
 print "things happening here"
 time.sleep(1)

Is there a way to distinguish whether rising or falling happened (rather than just "event")? So that I could print "the button was pressed" or the "the button was released" when appropriate?

reverseByteOrder works on a byte level instead of the word level

if you feed 255 (which is 0xff and also 0x00ff) to the original method, you will get 0xff back. To get 0xff00 back, please make the following modification:

def reverseByteOrder(self, data):
"Reverses the byte order of an int (16-bit) or long (32-bit) value"
# Courtesy Vishal Sapre
wordCount = len(hex(data)[2:].replace('L','')[::4])
val = 0
for i in range(wordCount):
# first byte of the word
val = (val << 8) | (data & 0xff)
data >>= 8
# second byte of the word
val = (val << 8) | (data & 0xff)
data >>= 8
return val

PWM not starting

I have just installed Adafruit BBIO per your tutorial. GPIO works great in a simple test. however, no luck with the PWM routines. When I enter the PWM start code (from the tutorial)
PWM.start("P9_14", 50)
I get no errors thrown, but no waveform on my 'scope on P9 pin 14.
When I add
PWM.set_frequency("P9_14",100)
I get the error "runtime error: you must start() the PWM channel first."
This doesnt make sense to me, given that I already have issued the PWM.start command
Also, the examples that come with the install all use the line
Import BBIO.xxx
This is out of date, given the new adafruit library Adafruit_BBIO
Any idea what Is wrong? ( at my end probably)
Many thanks.

Angstrom: conflict with python-nose

Hi,

First off, congratulations. This a really and helpful piece of software.
There's a conflict on Angstrom with python-nose, when following the easy installation method. I made it work removing python-nose and following:

/usr/bin/ntpdate -b -s -u pool.ntp.org
opkg update && opkg install python-pip python-setuptools
pip install Adafruit_BBIO

When following the manual installation method:

python setup.py install
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.45.tar.gz
Extracting in /tmp/tmpDBbprQ
Now working in /tmp/tmpDBbprQ/distribute-0.6.45
Building a Distribute egg in /home/root/adafruit-beaglebone-io-python
/home/root/adafruit-beaglebone-io-python/distribute-0.6.45-py2.7.egg
/home/root/adafruit-beaglebone-io-python/distribute-0.6.45-py2.7.egg/setuptools/command/install_scripts.py:3: UserWarning: Module overlays was already imported from /home/root/adafruit-beaglebone-io-pythh
running install
running bdist_egg
running egg_info
creating Adafruit_BBIO.egg-info
writing Adafruit_BBIO.egg-info/PKG-INFO
writing top-level names to Adafruit_BBIO.egg-info/top_level.txt
writing dependency_links to Adafruit_BBIO.egg-info/dependency_links.txt
writing manifest file 'Adafruit_BBIO.egg-info/SOURCES.txt'
reading manifest file 'Adafruit_BBIO.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'Adafruit_BBIO.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv7l/egg
running install_lib
running build_py
creating build
creating build/lib.linux-armv7l-2.7
copying Adafruit_I2C.py -> build/lib.linux-armv7l-2.7
creating build/lib.linux-armv7l-2.7/overlays
copying overlays/__init__.py -> build/lib.linux-armv7l-2.7/overlays
copying overlays/builder.py -> build/lib.linux-armv7l-2.7/overlays
creating build/lib.linux-armv7l-2.7/Adafruit_BBIO
copying Adafruit_BBIO/__init__.py -> build/lib.linux-armv7l-2.7/Adafruit_BBIO
running build_ext
building 'Adafruit_BBIO.GPIO' extension
creating build/temp.linux-armv7l-2.7
creating build/temp.linux-armv7l-2.7/source
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
source/py_gpio.c:36:18: warning: 'bb_revision' defined but not used [-Wunused-variable]
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.o
building 'Adafruit_BBIO.PWM' extension
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
source/py_pwm.c:29:12: warning: 'init_module' defined but not used [-Wunused-function]
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.o
building 'Adafruit_BBIO.ADC' extension
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
source/py_adc.c:30:18: warning: 'py_cleanup' defined but not used [-Wunused-function]
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.o
building 'Adafruit_BBIO.SPI' extension
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.o
building 'Adafruit_BBIO.UART' extension
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -Oo
arm-angstrom-linux-gnueabi-gcc -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -mtune=cortex-a8 -D__SOFTFP__ -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed build/temp.linux-armv7l-2.o
creating build/bdist.linux-armv7l
creating build/bdist.linux-armv7l/egg
creating build/bdist.linux-armv7l/egg/overlays
copying build/lib.linux-armv7l-2.7/overlays/__init__.py -> build/bdist.linux-armv7l/egg/overlays
copying build/lib.linux-armv7l-2.7/overlays/builder.py -> build/bdist.linux-armv7l/egg/overlays
creating build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/__init__.py -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/GPIO.so -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/PWM.so -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/UART.so -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/ADC.so -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_BBIO/SPI.so -> build/bdist.linux-armv7l/egg/Adafruit_BBIO
copying build/lib.linux-armv7l-2.7/Adafruit_I2C.py -> build/bdist.linux-armv7l/egg
writing byte-compilation script '/tmp/tmpZQMXwe.py'
/usr/bin/python /tmp/tmpZQMXwe.py
removing /tmp/tmpZQMXwe.py
creating stub loader for Adafruit_BBIO/GPIO.so
creating stub loader for Adafruit_BBIO/PWM.so
creating stub loader for Adafruit_BBIO/ADC.so
creating stub loader for Adafruit_BBIO/SPI.so
creating stub loader for Adafruit_BBIO/UART.so
writing byte-compilation script '/tmp/tmp3vkaQP.py'
/usr/bin/python /tmp/tmp3vkaQP.py
removing /tmp/tmp3vkaQP.py
creating build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_BBIO.egg-info/PKG-INFO -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_BBIO.egg-info/SOURCES.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_BBIO.egg-info/dependency_links.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
copying Adafruit_BBIO.egg-info/top_level.txt -> build/bdist.linux-armv7l/egg/EGG-INFO
writing build/bdist.linux-armv7l/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/Adafruit_BBIO-0.0.13-py2.7-linux-armv7l.egg' and adding 'build/bdist.linux-armv7l/egg' to it
removing 'build/bdist.linux-armv7l/egg' (and everything under it)
Creating /usr/lib/python2.7/site-packages/site.py
Processing distribute-0.6.45-py2.7.egg
creating /usr/lib/python2.7/site-packages/distribute-0.6.45-py2.7.egg
Extracting distribute-0.6.45-py2.7.egg to /usr/lib/python2.7/site-packages
Adding distribute 0.6.45 to easy-install.pth file
Installing easy_install script to /usr/bin
Installing easy_install-2.7 script to /usr/bin

Installed /usr/lib/python2.7/site-packages/distribute-0.6.45-py2.7.egg
Processing dependencies for distribute==0.6.45
Finished processing dependencies for distribute==0.6.45
Processing Adafruit_BBIO-0.0.13-py2.7-linux-armv7l.egg
creating /usr/lib/python2.7/site-packages/Adafruit_BBIO-0.0.13-py2.7-linux-armv7l.egg
Extracting Adafruit_BBIO-0.0.13-py2.7-linux-armv7l.egg to /usr/lib/python2.7/site-packages
Adding Adafruit-BBIO 0.0.13 to easy-install.pth file

Installed /usr/lib/python2.7/site-packages/Adafruit_BBIO-0.0.13-py2.7-linux-armv7l.egg
Processing dependencies for Adafruit-BBIO==0.0.13
Finished processing dependencies for Adafruit-BBIO==0.0.13

Seems to be fine but then:

python
Python 2.7.3 (default, May 29 2013, 21:25:00) 
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Adafruit_BBIO.GPIO as GPIO
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named GPIO

It seems that it recognized the Adafruit_BBIO though:

 python
Python 2.7.3 (default, May 29 2013, 21:25:00) 
[GCC 4.7.3 20130205 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Adafruit_BBIO
>>> 

spi xfer method with bpw>8 locks the system

running the latest debian bbb image (bone-debian-7.4-2014-03-27-2gb.img) and an A5C board, the spi xfer method with 12bit wordlength freezes the computer.

debian@beaglebone:~$ sudo python
Python 2.7.3 (default, Mar 14 2014, 17:55:54)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

from Adafruit_BBIO.SPI import SPI
spi= SPI(0, 0)
spi.bpw= 12
spi.xfer([10, 20, 30])
!!!here the system completely locks up!!!

PWM not able to start channel

root@ubuntu-armhf:~# sudo python
Python 2.7.3 (default, Apr 10 2013, 09:13:13)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import Adafruit_BBIO.PWM as PWM
PWM.start("P9_14", 50)
PWM.set_frequency("P9_14", 2000)
Traceback (most recent call last):
File "", line 1, in
RuntimeError: You must start() the PWM channel first

Issue #12 appeared to have the same problem. Unfortunately I am having the same problem running the following distro: ubuntu-precise-12.04.2-armhf-3.8.13-bone20

I installed Adafruit_BBIO via sudo pip install Adafruit_BBIO, so I am running 0.0.13.

No PWM working?

HI JW

Having investigated a bit further, tried a few restarts...
On ubuntu, PWM does not appear to be working:
This is the sort of response I get:

import Adafruit_BBIO.PWM as PWM
PWM.start("P9_14", 50, 1000, 1)
PWM.set_frequency("P9_14", 10)
Traceback (most recent call last):
File "", line 1, in
RuntimeError: You must start() the PWM channel first

Have you got any tips as to how to get this to work?
I could be doing something wrong -- but I have tried it on a heap of the PWM pins-- and cannot get it working .

THanks
Matt

Not accessing correct GPIO pins?

I am having a problem with a few pins (P8_07 through P8_10) at this time. I am able to setup the pins as output and set the value high without errors from the code. The problem is that the code is activating the wrong pin! ( I have yet to figure out the location of the pin that is being controlled)

An example is setting up and turning on P8_07 (gpio2_2) exports and controls "gpio0" in the "/sys/class/gpio/" directory. But it should be actually controlling "gpio66" in that directory.

Any ideas as to if I am doing anything wrong or is this a bug?

ADC Sample limit

I posted to the adafruit forums but I thought this might be the more appropriate venue.

I've been taking analog samples from an electret microphone and can't ever take more than 1020 samples before whatever python script I'm running exits without an error message. I don't even need to save the samples or output them, just access the ADC reading function.

PWM breaks after working for a moment

Hello
I'm using this code and the program brakes afer few seconds working.

    a= (int(data)+1000)/20
    print (a)
    PWM.start("P9_14", a)

it shows that error:
IOError: [Errno 24] Too many open files: '/sys/devices/bone_capemgr.8/slots'

when i delete the last line it works fine, so i don't know why it crashes. hope someone could help me. thanks.

PWM segfaults with multiple calls to PWM.start()

This is with version 0.0.20 of the library.

If I execute this script on a Beaglebone Black running Debian:

import time
import Adafruit_BBIO.PWM as PWM

while(1):
    PWM.start("P9_14", 50)
    PWM.start("P9_14", 50)
    time.sleep(5);
    PWM.stop("P9_14")
    time.sleep(5);

the PWM signal looks good for the first 30 seconds (3 loop iterations), and then the script hangs. The fourth burst of square waves is not emitted, and the script cannot be exited with Ctrl-C.

If I do the same at a console, I see:

>>> import Adafruit_BBIO.PWM as PWM
>>> PWM.start("P9_14", 50)
>>> PWM.start("P9_14", 50)
>>> PWM.stop("P9_14")
>>> PWM.start("P9_14", 50)
>>> PWM.start("P9_14", 50)
[1]    1201 segmentation fault  python

If I execute the script under GDB, the PWM fails after three cycles, but doesn't segfault. If I interrupt the script after 3 cycles with Ctrl-C, I see:

pwm_disable (key=0xbefff88c "P9_14") at source/c_pwm.c:241

The offending line of code is https://github.com/adafruit/adafruit-beaglebone-io-python/blob/master/source/c_pwm.c#L241

My hunch is that we're inadvertently getting trapped in the while (pwm != NULL) loop, but I don't understand the code well enough to be sure.

Please let me know if there is more I can do to help debug. Also, I should add that, yeah, it's stupid to call PWM.start() twice in a row, but I spend a lot of time teaching beginners this stuff; it would be nice to be robust enough to not segfault in the hands of non-experts.

common.c ; unload_device_tree doesn't initialize ctrl_dir

...so if you have a python program that just does:

PWM.stop(..)

(presumably a different invocation did a PWM.start(..))

then it dies with:
IOError: [Errno 2] No such file or directory: '/slots'

.. and, by the by, blames the line previous to the .stop() call for the IOError.

Can't add multiple event detections to a single pin

#16 seems to indicate that this should be possible but it's not working for me.

import Adafruit_BBIO.GPIO as GPIO

def hello(channel):  
    print "Hello"  

def goodbye(channel):  
    print "Goodbye"  

GPIO.setup("P8_14", GPIO.IN)
GPIO.add_event_detect("P8_14", GPIO.FALLING, callback=hello)
GPIO.add_event_detect("P8_14", GPIO.RISING, callback=goodbye)

I get this result:

traceback (most recent call last):
  File "test.py", line 12, in <module>
    GPIO.add_event_detect("P8_14", GPIO.RISING, callback=goodbye)
RuntimeError: Failed to add edge detection

If I comment out either add_event_detect the other one works fine. It just doesn't like setting up both at once.

Running Adafruit-BBIO (0.0.17) and Linux beaglebone 3.8.13 #1 SMP Tue Jun 18 02:11:09 EDT 2013 armv7l GNU/Linux.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.