Commit b1f15881 authored by Robert Hedman's avatar Robert Hedman

made sure no uneccessary serial sends

parent d7669ee3
......@@ -110,6 +110,7 @@ fn main() {
let mut message: [u8; message_length] = [0; message_length];
let mut received_bytes = 0;
let mut recording = false;
let mut sucessful_receive = false;
loop {
// get controller input (We expect to set soloMode here.)
......@@ -139,6 +140,7 @@ fn main() {
// reset everything for next message.
recording = false;
received_bytes = 0;
sucessful_receive = true;
break;
}
else if recording {
......@@ -164,9 +166,12 @@ fn main() {
// PID controller
// send voltage to motors.
match port.write(&message[0..message_length]) {
Ok(n) => {println!("Controller: sent {} bytes to arduino!", n);},
Err(e) => {println!("Controller: could not write to arduino: {}", e); },
if sucessful_receive {
sucessful_receive = false;
match port.write(&message[0..message_length]) {
Ok(n) => {println!("Controller: sent {} bytes to arduino!", n);},
Err(e) => {println!("Controller: could not write to arduino: {}", e); },
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment