Crate hlk_ld6002
source ·Expand description
A library for community with HLK-LD6002 radar respiratory and heartbeat sensors.
§Usage
use embedded_io_adapters::std::FromStd;
use hlk_ld6002::{Data, MessageStream};
use serialport::ClearBuffer;
use std::time::Duration;
let port = serialport::new("/dev/ttyUSB0", 1_382_400)
.timeout(Duration::from_millis(50))
.open()
.expect("Failed to open port");
let mut messages = MessageStream::new(FromStd::new(port));
let mut data = Data::default();
for message in messages.flatten() {
data.update(message);
println!("{data:?}");
}
Structs§
- A wrapper around
AsyncRead
for reading messages from the sensor - A helper struct to store the received data
- A wrapper around
Read
for reading messages from the sensor
Enums§
- Error type for reading data from the sensor
- The decoded message from the sensor
- Message type sent by the sensor