Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning about Raspberry Pi #27

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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