Intel® Makers
Intel® Edison, Intel® Joule™, Intel® Curie™, Intel® Galileo
Announcements
Welcome - This is a Peer-to-Peer Forum only. Intel has discontinued these products but you may find support from other customers on this Forum
9881 Discussions

MRAA button detect script unresponsive after some time

REdwa1
New Contributor I
1,390 Views

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
137 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
137 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