Skip to content
Snippets Groups Projects
Commit 350e5200 authored by Federico Lolli's avatar Federico Lolli
Browse files

Added sync mode

And made non-sync mode default (this should solve Win system issues with ACK receiving)
parent b9da0b28
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,11 @@ pub struct Cli { ...@@ -21,6 +21,11 @@ pub struct Cli {
/// baud rate /// baud rate
#[clap(short, long, default_value = "115200")] #[clap(short, long, default_value = "115200")]
pub baud_rate: u32, pub baud_rate: u32,
/// SYNC-MODE: for each packet sent wait for a signal from the device before
/// sending the next one
#[clap(short, long)]
pub sync: bool,
} }
pub fn get_styles() -> Styles { pub fn get_styles() -> Styles {
......
...@@ -81,9 +81,21 @@ fn main() { ...@@ -81,9 +81,21 @@ fn main() {
packets.total_packets() packets.total_packets()
); );
// if sync mode is enabled then wait for ACK
if args.sync {
wait_for_ack(&mut port, &mut buffer);
}
}
info!("sent {} packets", packets.sent_packets());
print_stats(times);
}
/// Wait for ACK signal from the device
fn wait_for_ack(port: &mut Box<dyn SerialPort>, buffer: &mut [u8]) {
// wait ACK // wait ACK
loop { loop {
match port.read(&mut buffer) { match port.read(buffer) {
Ok(t) => { Ok(t) => {
// eprint!("{}", String::from_utf8_lossy(&buffer[..t])); // eprint!("{}", String::from_utf8_lossy(&buffer[..t]));
// if didn't get the signal then print the buffer and exit with error // if didn't get the signal then print the buffer and exit with error
...@@ -104,10 +116,6 @@ fn main() { ...@@ -104,10 +116,6 @@ fn main() {
// eprintln!(); // eprintln!();
} }
info!("sent {} packets", packets.sent_packets());
print_stats(times);
}
trait MavLinkPort { trait MavLinkPort {
fn write_packet(&mut self, packet: MavMessage); fn write_packet(&mut self, packet: MavMessage);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment