Compare commits

3 Commits

Author SHA1 Message Date
mattbk 2929fc5038 Non-working snapshot. 2026-09-12 20:38:28 -05:00
mattbk 96beae275e Working snapshot with modified local riglib. 2026-09-12 18:08:30 -05:00
mattbk e0a06f1941 Snapshot without errors. 2026-09-12 16:33:57 -05:00
3 changed files with 428 additions and 29 deletions
Generated
+347 -1
View File
@@ -79,6 +79,12 @@ dependencies = [
"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]]
name = "arrayvec"
version = "0.7.8"
@@ -89,13 +95,27 @@ checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
name = "asmr"
version = "0.1.0"
dependencies = [
"anyhow",
"chrono",
"clap",
"csv",
"io",
"iter",
"nmea",
"riglib",
"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]]
@@ -184,6 +204,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]]
name = "cc"
version = "1.4.5"
@@ -200,6 +226,12 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "cfg_aliases"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]]
name = "chrono"
version = "0.4.45"
@@ -486,6 +518,16 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "find-msvc-tools"
version = "0.1.12"
@@ -952,6 +994,15 @@ dependencies = [
"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]]
name = "log"
version = "0.4.34"
@@ -973,6 +1024,31 @@ version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "nix"
version = "0.26.4"
@@ -984,6 +1060,18 @@ dependencies = [
"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]]
name = "nmea"
version = "0.8.0"
@@ -1073,6 +1161,29 @@ dependencies = [
"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]]
name = "paste"
version = "1.0.15"
@@ -1146,6 +1257,128 @@ dependencies = [
"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]]
name = "rustc-hex"
version = "2.1.0"
@@ -1355,7 +1588,7 @@ dependencies = [
"io-kit-sys",
"libudev",
"mach2",
"nix",
"nix 0.26.4",
"scopeguard",
"unescaper",
"windows-sys 0.52.0",
@@ -1367,6 +1600,16 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "slab"
version = "0.4.12"
@@ -1379,6 +1622,16 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "stable_deref_trait"
version = "1.2.1"
@@ -1481,6 +1734,62 @@ dependencies = [
"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]]
name = "toml_datetime"
version = "1.1.1+spec-1.1.0"
@@ -1511,6 +1820,37 @@ dependencies = [
"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]]
name = "typenum"
version = "1.20.1"
@@ -1586,6 +1926,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "wasm-bindgen"
version = "0.2.128"
+4
View File
@@ -11,4 +11,8 @@ io = "0.0.2"
iter = "0.1.0"
nmea = "0.8.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"
+73 -24
View File
@@ -2,6 +2,7 @@ use chrono::Local;
use clap::Parser;
use nmea::Nmea;
use nmea::SentenceType;
use riglib::kenwood::KenwoodRig;
use serialport::DataBits;
use serialport::Parity;
use serialport::StopBits;
@@ -11,6 +12,10 @@ use std::io::ErrorKind;
use std::io::Write;
use std::thread::sleep;
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.
#[derive(Parser, Debug)]
@@ -160,17 +165,17 @@ 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.");
println!("Rig '{x}' not in rig list. Using default connection values.");
build_rig("qmx", 9600, 8, 2, "none", "SM", "FA")
}
}
}
// Read S-meter
fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> i32 {
fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> String {
// Get the serial connection info for the rig name
let rig = get_rig(rig_name);
@@ -184,7 +189,9 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> i32 {
.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 +202,6 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> i32 {
}
// 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());
@@ -222,13 +227,7 @@ fn get_smeter(comport: &str, rig_name: &str, frequency: u32) -> i32 {
//let value = data;
// For S-meter, just take the numbers
let value = &data[2..5];
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 format!("{}", value);
// return;
}
Err(_) => {} // lol that I can just not put a return in?
@@ -265,11 +264,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
@@ -290,7 +290,7 @@ fn main() {
println!("{}", p.port_name);
}
println!("\nMissing `-c` rig port argument, use one listed above.");
return;
return Ok(());
} //todo!()
};
@@ -304,7 +304,7 @@ fn main() {
println!("{}", p.port_name);
}
println!("\nMissing `-g` GPS port argument, use one listed above.");
return;
return Ok(());
} //todo!()
};
@@ -322,32 +322,80 @@ 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");
loop {
// Get location
let ll = get_loc(gps.clone());
// Get datestamp
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
let s_val = get_smeter(&com, &rig, frequency);
// Print measurements and simple graph
// If not QMX, use riglib
// let s: (String, String, String) = match rig_name {
// "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!(
"{} {:#03} {}",
"{} {} {} {}",
date.format("%Y-%m-%d %H:%M:%S").to_string(),
s_val,
"#".repeat(s_val.try_into().unwrap())
if s_val_i > 0 {
"#".repeat(s_val_i.try_into().unwrap())
} else {
"".to_string()
},
s_units
);
// If they provided a file name
@@ -359,7 +407,7 @@ fn main() {
format!("{:09}", frequency),
format!("{:.8}", ll[0]),
format!("{:.8}", ll[1]),
format!("{}", s_val),
s_val_i.to_string(),
],
&file_out,
"csv",
@@ -369,4 +417,5 @@ fn main() {
}
sleep(Duration::from_millis((wait as u64 * 1000) - 1000));
}
Ok(())
}