Skip to content

Commit

Permalink
Added warning about Raspberry Pi
Browse files Browse the repository at this point in the history
  • Loading branch information
Kixunil committed Dec 17, 2016
1 parent c85cc3b commit 1ee669b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions examples/blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1ee669b

Please sign in to comment.