From 1ee669bbdbc22882d1948430d6952ac445586e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Habov=C5=A1tiak?= Date: Sat, 17 Dec 2016 21:05:40 +0100 Subject: [PATCH] Added warning about Raspberry Pi --- README.md | 4 ++++ examples/blinky.rs | 4 ++++ src/lib.rs | 16 ++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/README.md b/README.md index eb2463c06..edb534d9f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ use std::time::Duration; fn main() { let my_led = Pin::new(127); // number depends on chip, etc. my_led.with_exported(|| { + // There is a known issue on Raspberry Pi with this. + // The exported GPIO doesn't have correct permissions + // immediatelly. + // Try adding sleep(Duration::from_millis(200)) here. loop { my_led.set_value(0).unwrap(); sleep(Duration::from_millis(200)); diff --git a/examples/blinky.rs b/examples/blinky.rs index 18ea15a40..4804eadfe 100644 --- a/examples/blinky.rs +++ b/examples/blinky.rs @@ -24,6 +24,10 @@ struct Arguments { fn blink_my_led(led: u64, duration_ms: u64, period_ms: u64) -> sysfs_gpio::Result<()> { let my_led = Pin::new(led); my_led.with_exported(|| { + // There is a known issue on Raspberry Pi with this. + // The exported GPIO doesn't have correct permissions + // immediatelly. + // Try adding sleep(Duration::from_millis(200)) here. try!(my_led.set_direction(Direction::Low)); let iterations = duration_ms / period_ms / 2; for _ in 0..iterations { diff --git a/src/lib.rs b/src/lib.rs index b81cf25d5..11140d877 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,6 +34,10 @@ //! fn main() { //! let my_led = Pin::new(127); // number depends on chip, etc. //! my_led.with_exported(|| { +//! // There is a known issue on Raspberry Pi with this. +//! // The exported GPIO doesn't have correct permissions +//! // immediatelly. +//! // Try adding sleep(Duration::from_millis(200)) here. //! loop { //! my_led.set_value(0).unwrap(); //! sleep(Duration::from_millis(200)); @@ -186,6 +190,12 @@ impl Pin { /// will be exported. After the closure execution is complete, /// the GPIO will be unexported. /// + /// # Warning + /// + /// There is a known issue in case of Raspberry Pi. The + /// exported pin gets right permissions only after some tim passes. + /// Try adding some sleep at the beginning of the closure to work-around this. + /// /// # Example /// /// ```no_run @@ -239,6 +249,12 @@ impl Pin { /// 3. The requested GPIO is in use by the kernel and cannot /// be exported by use in userspace /// + /// # Warning + /// + /// There is a known issue in case of Raspberry Pi. The + /// exported pin gets right permissions only after some tim passes. + /// Try adding some sleep right-after this call to work-around this. + /// /// # Example /// ```no_run /// use sysfs_gpio::Pin;