From 59e05393a5a3091aff2b83d9f4d5b896ddef39c9 Mon Sep 17 00:00:00 2001 From: gohai Date: Mon, 12 Oct 2015 00:06:39 +0200 Subject: [PATCH] I/O: Improve messaging when user doesn't have permissions to write to LEDs This is e.g. the case with the newly released Raspbian 2015-09-24. --- java/libraries/io/src/processing/io/LED.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/java/libraries/io/src/processing/io/LED.java b/java/libraries/io/src/processing/io/LED.java index 353c2fd0e..7de5fb458 100644 --- a/java/libraries/io/src/processing/io/LED.java +++ b/java/libraries/io/src/processing/io/LED.java @@ -87,7 +87,10 @@ public class LED { String fn = "/sys/class/leds/" + dev + "/trigger"; int ret = NativeInterface.writeFile(fn, "none"); if (ret < 0) { - throw new RuntimeException(fn + ": " + NativeInterface.getError(ret)); + if (ret == -13) { // EACCES + System.err.println("You might need to install a custom udev rule to allow regular users to modify /sys/class/leds/*."); + } + throw new RuntimeException(NativeInterface.getError(ret)); } }