[−][src]Struct sds011::SDS011
Struct holds a link to a sensor and provides functions to interact with it
Example:
use sds011::{SDS011}; use std::thread::sleep; use std::time::{Duration}; match SDS011::new(port) { Ok(mut sensor) => { sensor.set_work_period(work_period).unwrap(); loop { if let Some(m) = sensor.query() { println!("{:?}", m); } sleep(Duration::from_secs(5u64 * 60)); } }, Err(e) => println!("{:?}", e.description), };
Implementations
impl SDS011
[src]
pub fn new(port: &str) -> Result<SDS011>
[src]
Creates new instance of SDS011
port
is required, for example /dev/ttyUSB0
Example
let mut sensor = SDS011::new("/dev/ttyUSB0").unwrap();
pub fn set_report_mode(&mut self) -> Result<()>
[src]
Sets report mode TODO at the moment sets WRITE and PASSIVE mode only
pub fn query(&mut self) -> Result<Message>
[src]
Reads data from the sensor and returns as Message
pub fn cmd_begin(&self) -> Vec<u8>
[src]
Returns command header and command ID bytes
pub fn set_work_period(&mut self, work_time: u8) -> Result<()>
[src]
Sets working period
work_time
must be between 0 and 30
Auto Trait Implementations
impl !RefUnwindSafe for SDS011
[src]
impl Send for SDS011
[src]
impl !Sync for SDS011
[src]
impl Unpin for SDS011
[src]
impl !UnwindSafe for SDS011
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,