pub struct PpsDevice(/* private fields */);Implementations§
Source§impl PpsDevice
impl PpsDevice
Sourcepub fn new(path: PathBuf) -> Result<PpsDevice>
pub fn new(path: PathBuf) -> Result<PpsDevice>
Examples found in repository?
examples/non_blocking.rs (line 18)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/non_blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_non_blocking().expect("Could not fetch!");
43 println!("{:#?}", data);
44 }
45}More examples
examples/timeout.rs (line 18)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/timeout /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_timeout(0, 500_000_000);
43 println!("{:#?}", data); // half of these should be timeouts for 1PPS devices
44 }
45}examples/blocking.rs (line 18)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 if capabilities & pps::PPS_CANWAIT == 0 {
42 println!("Cannot CANWAIT");
43 return;
44 }
45
46 loop {
47 let data = pps.fetch_blocking().expect("Could not fetch!");
48 println!("{:#?}", data);
49 }
50}Sourcepub fn get_params(&self) -> Result<pps_kparams>
pub fn get_params(&self) -> Result<pps_kparams>
Examples found in repository?
examples/non_blocking.rs (line 23)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/non_blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_non_blocking().expect("Could not fetch!");
43 println!("{:#?}", data);
44 }
45}More examples
examples/timeout.rs (line 23)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/timeout /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_timeout(0, 500_000_000);
43 println!("{:#?}", data); // half of these should be timeouts for 1PPS devices
44 }
45}examples/blocking.rs (line 23)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 if capabilities & pps::PPS_CANWAIT == 0 {
42 println!("Cannot CANWAIT");
43 return;
44 }
45
46 loop {
47 let data = pps.fetch_blocking().expect("Could not fetch!");
48 println!("{:#?}", data);
49 }
50}Sourcepub fn set_params(&self, params: &mut pps_kparams) -> Result<()>
pub fn set_params(&self, params: &mut pps_kparams) -> Result<()>
Examples found in repository?
examples/non_blocking.rs (line 39)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/non_blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_non_blocking().expect("Could not fetch!");
43 println!("{:#?}", data);
44 }
45}More examples
examples/timeout.rs (line 39)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/timeout /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_timeout(0, 500_000_000);
43 println!("{:#?}", data); // half of these should be timeouts for 1PPS devices
44 }
45}examples/blocking.rs (line 39)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 if capabilities & pps::PPS_CANWAIT == 0 {
42 println!("Cannot CANWAIT");
43 return;
44 }
45
46 loop {
47 let data = pps.fetch_blocking().expect("Could not fetch!");
48 println!("{:#?}", data);
49 }
50}Sourcepub fn get_cap(&self) -> Result<c_uint>
pub fn get_cap(&self) -> Result<c_uint>
Examples found in repository?
examples/non_blocking.rs (line 20)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/non_blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_non_blocking().expect("Could not fetch!");
43 println!("{:#?}", data);
44 }
45}More examples
examples/timeout.rs (line 20)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/timeout /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_timeout(0, 500_000_000);
43 println!("{:#?}", data); // half of these should be timeouts for 1PPS devices
44 }
45}examples/blocking.rs (line 20)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 if capabilities & pps::PPS_CANWAIT == 0 {
42 println!("Cannot CANWAIT");
43 return;
44 }
45
46 loop {
47 let data = pps.fetch_blocking().expect("Could not fetch!");
48 println!("{:#?}", data);
49 }
50}Sourcepub fn fetch_blocking(&self) -> Result<pps_fdata>
pub fn fetch_blocking(&self) -> Result<pps_fdata>
Fetch next PPS event, blocking until it arrives
Device must support PPS_CANWAIT, otherwise it will give an EOPNOTSUPP error
Examples found in repository?
examples/blocking.rs (line 47)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 if capabilities & pps::PPS_CANWAIT == 0 {
42 println!("Cannot CANWAIT");
43 return;
44 }
45
46 loop {
47 let data = pps.fetch_blocking().expect("Could not fetch!");
48 println!("{:#?}", data);
49 }
50}Sourcepub fn fetch_timeout(&self, seconds: i64, nanoseconds: i32) -> Result<pps_fdata>
pub fn fetch_timeout(&self, seconds: i64, nanoseconds: i32) -> Result<pps_fdata>
Fetch next PPS event with a timeout, giving an ETIMEDOUT error if event does not come in time
Device must support PPS_CANWAIT, otherwise it will give an EOPNOTSUPP error
Examples found in repository?
examples/timeout.rs (line 42)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/timeout /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_timeout(0, 500_000_000);
43 println!("{:#?}", data); // half of these should be timeouts for 1PPS devices
44 }
45}Sourcepub fn fetch_non_blocking(&self) -> Result<pps_fdata>
pub fn fetch_non_blocking(&self) -> Result<pps_fdata>
Fetch newest PPS event without blocking
Examples found in repository?
examples/non_blocking.rs (line 42)
7fn main() {
8 let args: Vec<String> = std::env::args().collect();
9 if args.len() < 2 {
10 println!("Example usage:");
11 println!("$ sudo ./target/debug/examples/non_blocking /dev/pps0");
12 return;
13 }
14
15 let path = PathBuf::from(&args[1]); // path to PPS device
16
17 println!("Opening PPS device {}", path.display());
18 let pps = PpsDevice::new(path).expect("Could not open file!");
19
20 let capabilities = pps.get_cap().expect("Could not get capabilities!");
21 println!("Capabilities: {:#x}", capabilities);
22
23 let mut params = pps.get_params().expect("Could not get params!");
24 println!("{:?}", params);
25
26 // Turn on CAPTUREASSERT if available
27 if capabilities & pps::PPS_CAPTUREASSERT != 0 {
28 params.mode |= pps::PPS_CAPTUREASSERT as i32;
29 } else {
30 println!("Cannot CAPTUREASSERT");
31 }
32 // Turn on CAPTURECLEAR if available
33 if capabilities & pps::PPS_CAPTURECLEAR != 0 {
34 params.mode |= pps::PPS_CAPTURECLEAR as i32;
35 } else {
36 println!("Cannot CAPTURECLEAR");
37 }
38
39 pps.set_params(&mut params).expect("Could not set params!");
40
41 loop {
42 let data = pps.fetch_non_blocking().expect("Could not fetch!");
43 println!("{:#?}", data);
44 }
45}Auto Trait Implementations§
impl Freeze for PpsDevice
impl RefUnwindSafe for PpsDevice
impl Send for PpsDevice
impl Sync for PpsDevice
impl Unpin for PpsDevice
impl UnsafeUnpin for PpsDevice
impl UnwindSafe for PpsDevice
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more