diff --git a/src/main.rs b/src/main.rs index 44fdc73dd51b64960c9207b5e5f21543d48f71ae..82d725878e17e14bc4aa010e881455e83ae54d13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,32 +1,8 @@ -//! Duplex example -//! -//! This example tests the ability to clone a serial port. It works by creating -//! a new file descriptor, and therefore a new `SerialPort` object that's safe -//! to send to a new thread. -//! -//! This example selects the first port on the system, clones the port into a child -//! thread that writes data to the port every second. While this is running the parent -//! thread continually reads from the port. -//! -//! To test this, have a physical or virtual loopback device connected as the -//! only port in the system. - use std::io::{Read, Write}; use std::time::Duration; use std::{io, thread}; fn main() { - // let mut s = String::new(); - // let mut f = std::fs::File::open("mavlink.csv").expect("Unable to open file"); - // f.read_to_string(&mut s).expect("Unable to read string"); - // let values = s - // .trim() - // .split(',') - // .map(|s| s.parse::<f64>().unwrap()) - // .collect::<Vec<_>>(); - - // dbg!(&values); - // Open the first serialport available. let port_name = "/dev/tty.usbmodem143203"; let mut port = serialport::new(port_name, 115200) @@ -46,17 +22,6 @@ fn main() { } mavlink_buffer[152..158].fill(100u8); - // mavlink_buffer[158] = b'\n'; - - // let mut send_buffer = [0u8; 316]; - // for i in 0..316 { - // if i % 2 == 0 { - // send_buffer[i] = mavlink_buffer[i / 2]; - // } else { - // send_buffer[i] = b'\n'; - // } - // } - clone // .write_all(&send_buffer) .write_all(&mavlink_buffer) @@ -69,14 +34,6 @@ fn main() { match port.read(&mut buffer) { Ok(t) => { io::stdout().write_all(&buffer[..t]).unwrap(); - // let mut read = 0; - // for chunk in buffer[..bytes].chunks(4) { - // read += 4; - // let mut utfbuf = [0u8; 4]; - // utfbuf[0..chunk.len()].copy_from_slice(chunk); - // let value = String::from_utf8_lossy(&utfbuf); - // print!("{}", value); - // } } Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (), Err(e) => eprintln!("{:?}", e),