Compare commits

2 Commits

Author SHA1 Message Date
mattbk 90ba8420c5 Convert QMX s-meter measurements to s-units. 2026-09-12 21:56:54 -05:00
mattbk 0d932efc83 Working snapshot. 2026-09-12 21:22:01 -05:00
3 changed files with 29 additions and 428 deletions
Generated
+1 -347
View File
@@ -79,12 +79,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "anyhow"
version = "1.0.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.8" version = "0.7.8"
@@ -95,27 +89,13 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
name = "asmr" name = "asmr"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow",
"chrono", "chrono",
"clap", "clap",
"csv", "csv",
"io", "io",
"iter", "iter",
"nmea", "nmea",
"riglib",
"serialport", "serialport",
"tokio",
]
[[package]]
name = "async-trait"
version = "0.1.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.5",
] ]
[[package]] [[package]]
@@ -204,12 +184,6 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.4.5" version = "1.4.5"
@@ -226,12 +200,6 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]] [[package]]
name = "chrono" name = "chrono"
version = "0.4.45" version = "0.4.45"
@@ -518,16 +486,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "errno"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "find-msvc-tools" name = "find-msvc-tools"
version = "0.1.12" version = "0.1.12"
@@ -994,15 +952,6 @@ dependencies = [
"pkg-config", "pkg-config",
] ]
[[package]]
name = "lock_api"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
dependencies = [
"scopeguard",
]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.34" version = "0.4.34"
@@ -1024,31 +973,6 @@ version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]]
name = "mio"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8"
dependencies = [
"libc",
"log",
"wasi",
"windows-sys 0.61.2",
]
[[package]]
name = "mio-serial"
version = "5.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d4ba3f20276f21b7cad3f1b54c97489cf096a3894fd627cc6951cb3abdd4c60"
dependencies = [
"log",
"mio",
"nix 0.31.3",
"serialport",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.26.4" version = "0.26.4"
@@ -1060,18 +984,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "nix"
version = "0.31.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
dependencies = [
"bitflags 2.13.1",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]] [[package]]
name = "nmea" name = "nmea"
version = "0.8.0" version = "0.8.0"
@@ -1161,29 +1073,6 @@ dependencies = [
"syn 2.0.119", "syn 2.0.119",
] ]
[[package]]
name = "parking_lot"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-link",
]
[[package]] [[package]]
name = "paste" name = "paste"
version = "1.0.15" version = "1.0.15"
@@ -1257,128 +1146,6 @@ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "redox_syscall"
version = "0.5.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
dependencies = [
"bitflags 2.13.1",
]
[[package]]
name = "riglib"
version = "0.1.0"
dependencies = [
"riglib-core",
"riglib-elecraft",
"riglib-flex",
"riglib-icom",
"riglib-kenwood",
"riglib-transport",
"riglib-yaesu",
]
[[package]]
name = "riglib-core"
version = "0.1.0"
dependencies = [
"async-trait",
"thiserror",
"tokio",
]
[[package]]
name = "riglib-elecraft"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"riglib-core",
"riglib-text-io",
"riglib-transport",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "riglib-flex"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"riglib-core",
"riglib-transport",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "riglib-icom"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"riglib-core",
"riglib-transport",
"thiserror",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "riglib-kenwood"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"riglib-core",
"riglib-text-io",
"riglib-transport",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "riglib-text-io"
version = "0.1.0"
dependencies = [
"riglib-core",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "riglib-transport"
version = "0.1.0"
dependencies = [
"async-trait",
"riglib-core",
"thiserror",
"tokio",
"tokio-serial",
"tracing",
]
[[package]]
name = "riglib-yaesu"
version = "0.1.0"
dependencies = [
"async-trait",
"bytes",
"riglib-core",
"riglib-text-io",
"riglib-transport",
"thiserror",
"tokio",
"tracing",
]
[[package]] [[package]]
name = "rustc-hex" name = "rustc-hex"
version = "2.1.0" version = "2.1.0"
@@ -1588,7 +1355,7 @@ dependencies = [
"io-kit-sys", "io-kit-sys",
"libudev", "libudev",
"mach2", "mach2",
"nix 0.26.4", "nix",
"scopeguard", "scopeguard",
"unescaper", "unescaper",
"windows-sys 0.52.0", "windows-sys 0.52.0",
@@ -1600,16 +1367,6 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
dependencies = [
"errno",
"libc",
]
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.12" version = "0.4.12"
@@ -1622,16 +1379,6 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f" checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f"
[[package]]
name = "socket2"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
dependencies = [
"libc",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "stable_deref_trait" name = "stable_deref_trait"
version = "1.2.1" version = "1.2.1"
@@ -1734,62 +1481,6 @@ dependencies = [
"time-core", "time-core",
] ]
[[package]]
name = "tokio"
version = "1.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
dependencies = [
"bytes",
"libc",
"mio",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-macros"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.5",
]
[[package]]
name = "tokio-serial"
version = "5.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd00f5f8b1e01c3e5afccd9e42ed80c2ad2df6d007877f29f8592c62e69cd116"
dependencies = [
"cfg-if",
"futures-core",
"futures-sink",
"log",
"mio-serial",
"serialport",
"tokio",
]
[[package]]
name = "tokio-util"
version = "0.7.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52"
dependencies = [
"bytes",
"futures-core",
"futures-sink",
"pin-project-lite",
"tokio",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "1.1.1+spec-1.1.0" version = "1.1.1+spec-1.1.0"
@@ -1820,37 +1511,6 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "tracing"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]]
name = "tracing-core"
version = "0.1.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
dependencies = [
"once_cell",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.20.1" version = "1.20.1"
@@ -1926,12 +1586,6 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7"
[[package]]
name = "wasi"
version = "0.11.1+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]] [[package]]
name = "wasm-bindgen" name = "wasm-bindgen"
version = "0.2.128" version = "0.2.128"
-4
View File
@@ -11,8 +11,4 @@ io = "0.0.2"
iter = "0.1.0" iter = "0.1.0"
nmea = "0.8.0" nmea = "0.8.0"
serialport = "4.10.0" serialport = "4.10.0"
#riglib = { git = "https://github.com/chadsbrown/riglib.git" }
riglib = {path = "riglib/crates/riglib"}
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.104"
+27 -76
View File
@@ -2,7 +2,6 @@ use chrono::Local;
use clap::Parser; use clap::Parser;
use nmea::Nmea; use nmea::Nmea;
use nmea::SentenceType; use nmea::SentenceType;
use riglib::kenwood::KenwoodRig;
use serialport::DataBits; use serialport::DataBits;
use serialport::Parity; use serialport::Parity;
use serialport::StopBits; use serialport::StopBits;
@@ -12,10 +11,6 @@ use std::io::ErrorKind;
use std::io::Write; use std::io::Write;
use std::thread::sleep; use std::thread::sleep;
use std::time::Duration; use std::time::Duration;
use riglib::{Rig as Rig_riglib, ReceiverId};
use riglib::kenwood::KenwoodBuilder;
use riglib::kenwood::models::ts_990s;
use riglib::s_units_from_dbm;
/// Command-line arguments using Clap. /// Command-line arguments using Clap.
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
@@ -165,17 +160,17 @@ fn build_rig(
fn get_rig(x: &str) -> Rig { fn get_rig(x: &str) -> Rig {
match x { match x {
"qmx" => build_rig("qmx", 9600, 8, 2, "none", "SM", "FA"), "qmx" => build_rig("qmx", 9600, 8, 2, "none", "SM", "FA"),
"ic-7300" => build_rig("ic-7300", 115200, 8, 1, "none", "1502", "FA"), //"ic-7300" => build_rig("ic-7300", 115200, 8, 1, "none", "1502"),
_ => { _ => {
// This prints a message every loop but that's OK. // This prints a message every loop but that's OK.
println!("Rig '{x}' not in rig list. Using default connection values."); println!("Rig '{x}' in rig list. Using default connection values.");
build_rig("qmx", 9600, 8, 2, "none", "SM", "FA") build_rig("qmx", 9600, 8, 2, "none", "SM", "FA")
} }
} }
} }
// Read S-meter // Read S-meter
fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String { fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> i32 {
// Get the serial connection info for the rig name // Get the serial connection info for the rig name
let rig = get_rig(rig_name); let rig = get_rig(rig_name);
@@ -189,9 +184,7 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
.expect("Failed to open port"); .expect("Failed to open port");
// Set the requested frequency // Set the requested frequency
// let output = "FA00014075000;"; // set VFO A frequency let output = format!("{}{};", rig.freq_cat, frequency);
let output = format!("{}{:011};", rig.freq_cat, frequency);
// dbg!(&output);
match port.write(output.as_bytes()) { match port.write(output.as_bytes()) {
Ok(_) => { Ok(_) => {
@@ -202,6 +195,8 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
} }
// Duh, you need the ";" on the end! // 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 let output = format!("{};", rig.s_meter_cat); //"SM;"; // ask for S-meter reading
// What are we actually sending? // What are we actually sending?
//dbg!(output.as_bytes()); //dbg!(output.as_bytes());
@@ -227,7 +222,13 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
//let value = data; //let value = data;
// For S-meter, just take the numbers // For S-meter, just take the numbers
let value = &data[2..5]; let value = &data[2..5];
return format!("{}", value); let value_i = value.parse::<i32>().unwrap();
// return format!("{}", value);
if rig_name == "qmx" {
return (value_i as f32 / 6.0) as i32;
} else {
return value_i;
}
// return; // return;
} }
Err(_) => {} // lol that I can just not put a return in? Err(_) => {} // lol that I can just not put a return in?
@@ -264,12 +265,11 @@ fn write_row(str_arr: [String; 5], file: &String, fmt: &str) -> Result<(), Box<d
} }
// Main funtion // Main funtion
#[tokio::main] fn main() {
async fn main() -> anyhow::Result<()> {
// Arguments // Arguments
let cli = Cli::parse(); let cli = Cli::parse();
let rig_name = match cli.rig { let rig = match cli.rig {
Some(rig) => { Some(rig) => {
println!("Connecting to rig {}", rig); println!("Connecting to rig {}", rig);
rig rig
@@ -290,7 +290,7 @@ async fn main() -> anyhow::Result<()> {
println!("{}", p.port_name); println!("{}", p.port_name);
} }
println!("\nMissing `-c` rig port argument, use one listed above."); println!("\nMissing `-c` rig port argument, use one listed above.");
return Ok(()); return;
} //todo!() } //todo!()
}; };
@@ -304,7 +304,7 @@ async fn main() -> anyhow::Result<()> {
println!("{}", p.port_name); println!("{}", p.port_name);
} }
println!("\nMissing `-g` GPS port argument, use one listed above."); println!("\nMissing `-g` GPS port argument, use one listed above.");
return Ok(()); return;
} //todo!() } //todo!()
}; };
@@ -322,81 +322,33 @@ async fn main() -> anyhow::Result<()> {
let frequency = match cli.freq { let frequency = match cli.freq {
Some(frequency) => frequency, Some(frequency) => frequency,
None => { None => {
return Ok(()); return;
} //todo!() } //todo!()
}; };
let wait: u16 = match cli.wait { let wait: u16 = match cli.wait {
Some(wait) => wait, Some(wait) => wait,
None => { None => {
return Ok(()); return;
} //todo!() } //todo!()
}; };
println!("Press Ctrl + C to quit"); println!("Press Ctrl + C to quit");
loop { loop {
// Get location // Get location
let ll = get_loc(gps.clone()); let ll = get_loc(gps.clone());
// Get datestamp // Get datestamp
let date = Local::now(); let date = Local::now();
// If not QMX, use riglib
let mut s_val;
let mut s_val_i;
if rig_name != "qmx" {
let rig1 = KenwoodBuilder::new(ts_990s())
.serial_port(&com)
.build()
.await?;
//let info = rig1.info();
//println!("Connected: {} {}\n", info.manufacturer, info.model_name);
let rx = ReceiverId::VFO_A;
//let freq = rig1.get_frequency(ReceiverId::VFO_A).await?;
//println!("VFO-A: {} Hz", freq);
let s_val = rig1.get_s_meter(rx).await?; // this is failing on the QMX using TS-890 unless I mess with source
let s_val_i = s_val as i32;
let s_units = s_units_from_dbm(s_val);
} else if rig_name == "qmx" {
//println!("Connecting to QMX...");
// TODO make both of these numbers eventually
let s_val = get_smeter(&com, &rig_name, frequency);
let s_val_i = s_val;
}
// Get S-meter // Get S-meter
// If not QMX, use riglib let s_val = get_smeter(&com, &rig, frequency);
// let s: (String, String, String) = match rig_name { // Print measurements and simple graph
// "qmx" => {
// let s_val = get_smeter(&com, &rig_name, frequency);
// let s_val_i = s_val;
// (s_val, s_val_i, "".to_string())
// },
// _ => {
// let s_val = rig1.get_s_meter(rx).await?; // this is failing on the QMX using TS-890 unless I mess with source
// let s_units = s_units_from_dbm(s_val);
// let s_val_i = s_val as i32;
// (s_val.to_string(), s_val_i.to_string(), s_units.to_string())
// }
// }
println!( println!(
"{} {} {} {}", "{} {:#03} {}",
date.format("%Y-%m-%d %H:%M:%S").to_string(), date.format("%Y-%m-%d %H:%M:%S").to_string(),
s_val, s_val,
if s_val_i > 0 { "#".repeat(s_val.try_into().unwrap())
"#".repeat(s_val_i.try_into().unwrap()) );
} else {
"".to_string()
},
s_units
);
// If they provided a file name // If they provided a file name
if file_out != "no file" { if file_out != "no file" {
@@ -407,7 +359,7 @@ async fn main() -> anyhow::Result<()> {
format!("{:09}", frequency), format!("{:09}", frequency),
format!("{:.8}", ll[0]), format!("{:.8}", ll[0]),
format!("{:.8}", ll[1]), format!("{:.8}", ll[1]),
s_val_i.to_string(), format!("{}", s_val),
], ],
&file_out, &file_out,
"csv", "csv",
@@ -417,5 +369,4 @@ async fn main() -> anyhow::Result<()> {
} }
sleep(Duration::from_millis((wait as u64 * 1000) - 1000)); sleep(Duration::from_millis((wait as u64 * 1000) - 1000));
} }
Ok(())
} }