Skip to content
Snippets Groups Projects
Commit bdd68ce4 authored by Robert Hedman's avatar Robert Hedman
Browse files

Small warning fixes

parent d1f2103d
No related branches found
No related tags found
No related merge requests found
...@@ -11,10 +11,10 @@ use std::net::TcpListener; ...@@ -11,10 +11,10 @@ use std::net::TcpListener;
extern crate serial; extern crate serial;
use std::io; use std::io;
use std::time::Duration; use std::time::Duration;
use std::io::prelude::*; //use std::io::prelude::*;
use serial::prelude::*; use serial::prelude::*;
use std::str; //use std::str;
// should the map matrix be two dim array of const size, vecs of dynamic, or what? // should the map matrix be two dim array of const size, vecs of dynamic, or what?
...@@ -34,7 +34,7 @@ fn main() { ...@@ -34,7 +34,7 @@ fn main() {
thread::sleep(time::Duration::new(1,0)); thread::sleep(time::Duration::new(1,0));
loop { loop {
match stream.read_exact(&mut message) { match stream.read_exact(&mut message) {
Ok(msg) => {println!("server got: {} {}", message[0], message[1]); Ok(_) => {println!("server got: {} {}", message[0], message[1]);
let written_size = stream.write(&[69 as u8, 96 as u8]); let written_size = stream.write(&[69 as u8, 96 as u8]);
println!("server wrote {:?} to stream.", written_size); println!("server wrote {:?} to stream.", written_size);
}, },
...@@ -59,25 +59,21 @@ fn main() { ...@@ -59,25 +59,21 @@ fn main() {
let tracker = thread::spawn(move || { let tracker = thread::spawn(move || {
println!("Tracker started."); println!("Tracker started.");
let mut serialBuf: [u8; 8] = [0; 8]; let mut serial_buf: [u8; 8] = [0; 8];
let device = String::from("/dev/cu.usbmodem41"); let device = String::from("/dev/cu.usbmodem41");
let mut port = serial::open(&device).unwrap(); let mut port = serial::open(&device).unwrap();
interact(&mut port).unwrap(); interact(&mut port).unwrap();
let mut L: i32 = 0;
let mut R: i32 = 0;
let mut pos: (i32, i32) = (0,0); let mut pos: (i32, i32) = (0,0);
loop { loop {
// get encoder data from arduino and update local variables // get encoder data from arduino and update local variables
match port.read_exact(&mut serialBuf){ match port.read_exact(&mut serial_buf){
Ok(_) => { Ok(_) => {
L = freq_to_distance( ( ((serialBuf[0] as u32) << 24) + ((serialBuf[1] as u32) << 16) + ((serialBuf[2] as u32) << 8) + (serialBuf[3] as u32) ) as i32); pos.0 = freq_to_distance( ( ((serial_buf[0] as u32) << 24) + ((serial_buf[1] as u32) << 16) + ((serial_buf[2] as u32) << 8) + (serial_buf[3] as u32) ) as i32);
R = freq_to_distance( ( ((serialBuf[4] as u32) << 24) + ((serialBuf[5] as u32) << 16) + ((serialBuf[6] as u32) << 8) + (serialBuf[7] as u32) ) as i32); pos.1 = freq_to_distance( ( ((serial_buf[4] as u32) << 24) + ((serial_buf[5] as u32) << 16) + ((serial_buf[6] as u32) << 8) + (serial_buf[7] as u32) ) as i32);
print!("L: {}, ", L); print!("L: {}, ", pos.0);
println!("R: {}", R); println!("R: {}", pos.1);
pos.0 += L;
pos.1 += R;
}, },
Err(e) => { Err(e) => {
println!("Could not read all bytes: {:?}", e); println!("Could not read all bytes: {:?}", e);
...@@ -116,7 +112,7 @@ fn main() { ...@@ -116,7 +112,7 @@ fn main() {
// set up connection to lidar // set up connection to lidar
let mut stream = TcpStream::connect("127.0.0.1:8080").unwrap(); let mut stream = TcpStream::connect("127.0.0.1:8080").unwrap();
let mut lidarBuf: [u8; 2] = [0; 2]; let mut lidar_buf: [u8; 2] = [0; 2];
// main loop for this thread // main loop for this thread
loop { loop {
...@@ -133,9 +129,9 @@ fn main() { ...@@ -133,9 +129,9 @@ fn main() {
let stream_write_response = stream.write(&[65 as u8, 66 as u8]); let stream_write_response = stream.write(&[65 as u8, 66 as u8]);
println!("mapper wrote {:?} to stream.", stream_write_response); println!("mapper wrote {:?} to stream.", stream_write_response);
match stream.read_exact(&mut lidarBuf){ match stream.read_exact(&mut lidar_buf){
Ok(_) => { Ok(_) => {
println!("mapper got {}, {}, from lidar.", lidarBuf[0], lidarBuf[1]); println!("mapper got {}, {}, from lidar.", lidar_buf[0], lidar_buf[1]);
}, },
Err(e) => { Err(e) => {
println!("Could not read all bytes: {:?}", e); println!("Could not read all bytes: {:?}", e);
...@@ -169,7 +165,6 @@ fn main() { ...@@ -169,7 +165,6 @@ fn main() {
// pathfinder, takes a map and returns a list of nodes to aim for when driving // pathfinder, takes a map and returns a list of nodes to aim for when driving
// This will be a function for mapper to call. // This will be a function for mapper to call.
//
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment