Skip to content

derive debug for Pin and PinPoller, open file instead of creating in read_from_device_file #9

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

Merged
merged 2 commits into from
Dec 4, 2015
Merged
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: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use std::fs::{File};
mod error;
pub use error::Error;

#[derive(Debug)]
pub struct Pin {
pin_num : u64,
}
Expand Down Expand Up @@ -109,7 +110,7 @@ impl Pin {

fn read_from_device_file(&self, dev_file_name: &str) -> io::Result<String> {
let gpio_path = format!("/sys/class/gpio/gpio{}/{}", self.pin_num, dev_file_name);
let mut dev_file = try!(File::create(&gpio_path));
let mut dev_file = try!(File::open(&gpio_path));
let mut s = String::new();
try!(dev_file.read_to_string(&mut s));
Ok(s)
Expand Down Expand Up @@ -325,6 +326,7 @@ impl Pin {
}
}

#[derive(Debug)]
pub struct PinPoller {
pin_num : u64,
epoll_fd : RawFd,
Expand Down