Get the example working with a real lidar

This commit is contained in:
Piv
2022-03-30 18:35:19 +10:30
parent 1461814c27
commit bd300269dd
2 changed files with 58 additions and 26 deletions

View File

@@ -0,0 +1,14 @@
use rplidar_rs::Lidar;
use std::time::Duration;
fn main() {
let serial = serialport::new("/dev/cu.usbserial-0001", 115200)
.timeout(Duration::from_secs(10))
.open_native()
.expect("Failed to open serial port, check it's available");
let mut lidar = Lidar::new(serial);
lidar.start_scanning().expect("Failed to start scanning");
for scan in lidar {
println!("{}", scan.len());
}
}