Snapshot without errors.

This commit is contained in:
mattbk
2026-09-12 16:33:57 -05:00
parent 7c9e033015
commit e0a06f1941
3 changed files with 398 additions and 18 deletions
+39 -17
View File
@@ -11,6 +11,9 @@ use std::io::ErrorKind;
use std::io::Write;
use std::thread::sleep;
use std::time::Duration;
use riglib::{Rig as Rig_riglib, ReceiverId, RigEvent};
use riglib::kenwood::KenwoodBuilder;
use riglib::kenwood::models::ts_590s;
/// Command-line arguments using Clap.
#[derive(Parser, Debug)]
@@ -160,7 +163,7 @@ fn build_rig(
fn get_rig(x: &str) -> Rig {
match x {
"qmx" => build_rig("qmx", 9600, 8, 2, "none", "SM", "FA"),
//"ic-7300" => build_rig("ic-7300", 115200, 8, 1, "none", "1502"),
"ic-7300" => build_rig("ic-7300", 115200, 8, 1, "none", "1502", "FA"),
_ => {
// This prints a message every loop but that's OK.
println!("Rig '{x}' in rig list. Using default connection values.");
@@ -184,7 +187,9 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
.expect("Failed to open port");
// Set the requested frequency
let output = format!("{}{};", rig.freq_cat, frequency);
// let output = "FA00014075000;"; // set VFO A frequency
let output = format!("{}{:011};", rig.freq_cat, frequency);
// dbg!(&output);
match port.write(output.as_bytes()) {
Ok(_) => {
@@ -195,8 +200,6 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
}
// Duh, you need the ";" on the end!
// let output = "FA14075000;"; // set VFO A frequency
// let output = "FA;"; // ask for VFO A frequency
let output = format!("{};", rig.s_meter_cat); //"SM;"; // ask for S-meter reading
// What are we actually sending?
//dbg!(output.as_bytes());
@@ -259,11 +262,12 @@ fn write_row(str_arr: [String; 5], file: &String, fmt: &str) -> Result<(), Box<d
}
// Main funtion
fn main() {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Arguments
let cli = Cli::parse();
let rig = match cli.rig {
let rig_name = match cli.rig {
Some(rig) => {
println!("Connecting to rig {}", rig);
rig
@@ -284,7 +288,7 @@ fn main() {
println!("{}", p.port_name);
}
println!("\nMissing `-c` rig port argument, use one listed above.");
return;
return Ok(());
} //todo!()
};
@@ -298,7 +302,7 @@ fn main() {
println!("{}", p.port_name);
}
println!("\nMissing `-g` GPS port argument, use one listed above.");
return;
return Ok(());
} //todo!()
};
@@ -316,19 +320,28 @@ fn main() {
let frequency = match cli.freq {
Some(frequency) => frequency,
None => {
return;
return Ok(());
} //todo!()
};
let wait: u16 = match cli.wait {
Some(wait) => wait,
None => {
return;
return Ok(());
} //todo!()
};
println!("Press Ctrl + C to quit");
let rig1 = KenwoodBuilder::new(ts_590s())
.serial_port(&com)
.build()
.await?;
let info = rig1.info();
println!("Connected: {} {}\n", info.manufacturer, info.model_name);
let rx = ReceiverId::VFO_A;
// Simple test loop to make sure we are getting values each time
//for _i in 1..11 {
loop {
@@ -337,18 +350,26 @@ fn main() {
// Get datestamp
let date = Local::now();
// Get S-meter
let s_val = get_smeter(&com, &rig, frequency);
//let s_val = get_smeter(&com, &rig_name, frequency);
let s_val = rig1.get_s_meter(rx).await?;
//println!("{a}");
match s_val.parse::<i32>() {
// Simple graph as we go. Eventually this will be replaced.
Ok(n) => println!(
let n = s_val as i32;
println!(
"{} {} {}",
date.format("%Y-%m-%d %H:%M:%S").to_string(),
s_val,
"#".repeat(n.try_into().unwrap())
),
Err(_e) => todo!(),
}
);
// match s_val {
// // Simple graph as we go. Eventually this will be replaced.
// Ok(n) => println!(
// "{} {} {}",
// date.format("%Y-%m-%d %H:%M:%S").to_string(),
// s_val,
// "#".repeat(n.try_into().unwrap())
// ),
// Err(_e) => todo!(),
//}
// If they provided a file name
if file_out != "no file" {
if let Err(err) = write_row(
@@ -368,4 +389,5 @@ fn main() {
}
sleep(Duration::from_millis((wait as u64 * 1000) - 1000));
}
Ok(())
}