fix typo + new option for configuring whether to save buffer on start
This commit is contained in:
parent
5d217e6c5a
commit
b4c84d71e5
1 changed files with 10 additions and 7 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -33,9 +33,9 @@ struct Args {
|
|||
winsize: Option<u32>,
|
||||
|
||||
#[arg(long, default_value_t = 10, help = "Value in Hz")]
|
||||
requst_rate: u32,
|
||||
request_rate: u32,
|
||||
|
||||
#[arg(short, long)]
|
||||
#[arg(short = 'f', long)]
|
||||
first_sample: bool,
|
||||
|
||||
#[arg(short, long, action = clap::ArgAction::Count)]
|
||||
|
|
@ -55,7 +55,7 @@ fn main() {
|
|||
.init();
|
||||
|
||||
assert!(
|
||||
args.requst_rate >= 1 && args.requst_rate <= 100,
|
||||
args.request_rate >= 1 && args.request_rate <= 100,
|
||||
"Request rate must be in 1..100 range!"
|
||||
);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ fn main() {
|
|||
.unwrap();
|
||||
debug!("Press Ctrl-C to stop");
|
||||
|
||||
let mut last_chunk_id: u32 = 0;
|
||||
let mut last_chunk_id: Option<u32> = None;
|
||||
let mut err_counter: u32 = 0;
|
||||
|
||||
while running.load(Ordering::SeqCst) {
|
||||
|
|
@ -119,7 +119,7 @@ fn main() {
|
|||
value
|
||||
}
|
||||
};
|
||||
if cur_chunk_id != last_chunk_id {
|
||||
if (last_chunk_id != Some(cur_chunk_id) && last_chunk_id.is_some()) || (args.first_sample && last_chunk_id.is_none()) {
|
||||
debug!("New data available: {}", cur_chunk_id);
|
||||
debug!("Getting new chunk!");
|
||||
match get_chunk(&mut port, args.device_id, args.baud_rate, winsize) {
|
||||
|
|
@ -144,7 +144,7 @@ fn main() {
|
|||
info!("WAV file {} has been written.", filename);
|
||||
|
||||
err_counter = err_counter.saturating_sub(1);
|
||||
last_chunk_id = cur_chunk_id;
|
||||
last_chunk_id = Some(cur_chunk_id);
|
||||
}
|
||||
_ => {
|
||||
error!("Couldn't receive new data!");
|
||||
|
|
@ -152,7 +152,10 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis((1000 / args.requst_rate) as u64));
|
||||
if !args.first_sample && last_chunk_id.is_none() {
|
||||
last_chunk_id = Some(cur_chunk_id)
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis((1000 / args.request_rate) as u64));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue