Skip to content

Commit e43e168

Browse files
committed
Merge pull request #9 from marjakm/fixes
derive debug for Pin and PinPoller, open file instead of creating in read_from_device_file
2 parents 3e92f66 + 2ffd460 commit e43e168

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ use std::fs::{File};
5757
mod error;
5858
pub use error::Error;
5959

60+
#[derive(Debug)]
6061
pub struct Pin {
6162
pin_num : u64,
6263
}
@@ -109,7 +110,7 @@ impl Pin {
109110

110111
fn read_from_device_file(&self, dev_file_name: &str) -> io::Result<String> {
111112
let gpio_path = format!("/sys/class/gpio/gpio{}/{}", self.pin_num, dev_file_name);
112-
let mut dev_file = try!(File::create(&gpio_path));
113+
let mut dev_file = try!(File::open(&gpio_path));
113114
let mut s = String::new();
114115
try!(dev_file.read_to_string(&mut s));
115116
Ok(s)
@@ -325,6 +326,7 @@ impl Pin {
325326
}
326327
}
327328

329+
#[derive(Debug)]
328330
pub struct PinPoller {
329331
pin_num : u64,
330332
epoll_fd : RawFd,

0 commit comments

Comments
 (0)