Struct co2mon::OpenOptions [−][src]
pub struct OpenOptions { /* fields omitted */ }
Expand description
Sensor open options.
Opens the first available device with the USB Vendor ID 0x04d9
and Product ID 0xa052
, a 0
encryption key and a 5 seconds timeout.
Normally there’s no need to change the encryption key.
Example
let sensor = OpenOptions::new()
.timeout(Some(Duration::from_secs(10)))
.open()?;
Implementations
Creates a new set of options to be configured.
The defaults are opening the first connected sensor and a timeout of 5 seconds.
Example
let sensor = OpenOptions::new()
.timeout(Some(Duration::from_secs(10)))
.open()?;
Sets the serial number of the sensor device to open.
The serial number appears to be the firmware version.
Example
let sensor = OpenOptions::new()
.with_serial_number("1.40")
.open()?;
Sets the path to the sensor device to open.
Example
let sensor = OpenOptions::new()
.with_path(CString::new("/dev/bus/usb/001/004")?)
.open()?;
Sets the encryption key.
The key is used to encrypt the communication with the sensor, but changing it is probably not very useful.
Example
let sensor = OpenOptions::new()
.with_key([0x62, 0xea, 0x1d, 0x4f, 0x14, 0xfa, 0xe5, 0x6c])
.open()?;
Sets the read timeout.
Example
let sensor = OpenOptions::new()
.timeout(Some(Duration::from_secs(10)))
.open()?;
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for OpenOptions
impl Send for OpenOptions
impl Sync for OpenOptions
impl Unpin for OpenOptions
impl UnwindSafe for OpenOptions
Blanket Implementations
Mutably borrows from an owned value. Read more