Private
Public Access
2
0

java: Allows Java GPIO ISR sample to exit so IsrExit() method can be tested

Signed-off-by: Henry Bruce <henry.bruce@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Henry Bruce
2016-02-25 13:38:28 -08:00
committed by Brendan Le Foll
parent 9d497e08cd
commit d313ac0579

View File

@@ -22,6 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import mraa.Dir; import mraa.Dir;
import mraa.Edge; import mraa.Edge;
import mraa.Gpio; import mraa.Gpio;
@@ -37,6 +40,7 @@ public class Isr {
System.exit(1); System.exit(1);
} }
} }
public static void main(String argv[]) throws InterruptedException { public static void main(String argv[]) throws InterruptedException {
int pin = 6; int pin = 6;
if (argv.length == 1) { if (argv.length == 1) {
@@ -45,15 +49,17 @@ public class Isr {
} catch (Exception e) { } catch (Exception e) {
} }
} }
System.out.println("Starting ISR for pin " + Integer.toString(pin)); BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Starting ISR for pin " + Integer.toString(pin) + ". Press ENTER to stop");
Gpio gpio = new Gpio(pin); Gpio gpio = new Gpio(pin);
Runnable callback = new JavaCallback(); Runnable callback = new JavaCallback();
gpio.isr(Edge.EDGE_RISING, callback); gpio.isr(Edge.EDGE_RISING, callback);
while (true) try {
Thread.sleep(999999); String input = console.readLine();
}; } catch (IOException e) {
}
gpio.isrExit();
}
} }