Community
cancel
Showing results for 
Search instead for 
Did you mean: 
REdwa1
New Contributor I
1,323 Views

MRAA button detect script unresponsive after some time

I have an Edison (Yocto Poky on Sparkfun blocks) with a script running to detect button presses (using the GPIO block), which becomes unresponsive after some time (trying to pin down how long, but over an hour). The python script is below, based on an example from https://github.com/intel-iot-devkit/mraa/blob/master/examples/python/hello_isr.py https github.com/intel-iot-devkit/mraa/blob/master/examples/python/hello_isr.py :

button.py

# !/usr/bin/env python

import mraa

import time

import subprocess

def press(args):

subprocess.call("echo $(date) >> button_log.txt", shell=True)

pin = mraa.Gpio(32)

pin.dir(mraa.DIR_IN)

pin.isr(mraa.EDGE_BOTH, press, press)

time.sleep(600)

pin.isrExit()

I have another bash script that detects if button.py has ended, and restarts a new instance if so. This appears to work perfectly, and I've tested the button on an instance of button.py that was created by the bash script, and that worked ok.

Any idea why this can become unresponsive?

2 Replies
Pedro_M_Intel
Employee
70 Views

Hello geotheory,

Which version of mraa are you using? I'm going to test your script with my Edison+Arduino Expansion Board (I don't have access to a GPIO block) and see if I get the same behavior.

Peter.

REdwa1
New Contributor I
70 Views

Hi Peter. `mraa.getVersion()` in python returns `v0.7.2`.

I think however I've found the culprit - `pin.isrExit()` seems to hang the script, which prevents the process from ending and a fresh working one from starting up. Commenting it out seems to work.

Reply