Code: Select all
// First, find the serial port
let port_info = find_receiver();
// If we didn't find a port, then we can't continue
if port_info.is_none() {
panic!("Could not find a serial port");
}
let mut port = serialport::new(port_info.unwrap().port_name, 9600)
.timeout(Duration::from_millis(1000))
.open()
.expect("Could not open serial port");
let mut serial_buf: Vec<u8> = vec![0; 8];
loop {
let n = port.read_exact(serial_buf.as_mut_slice()).unwrap();
println!("Buffer is {:?}", serial_buf);
}
I've tried varying the size of the buffer from 1 byte to 1000, I've tried different versions of reading into the port, I've tried skipping over timeout errors, and I've tried directly outputting the read bytes to io::Stdout. Any ideas on what to do?
----------------------------
code from Arduino books.