From d6d488b4b0ebd4eb3102b9e20696fb2fd20de44f Mon Sep 17 00:00:00 2001 From: mattbk Date: Tue, 8 Sep 2026 21:56:32 -0500 Subject: [PATCH] Snapshot. --- src/main.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7b9534f..68e92fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,11 +16,11 @@ fn get_smeter(comport: &str) -> String { .expect("Failed to open port"); // Duh, you need the ";" on the end! - // let output = "FA14075000;"; - let output = "SM;"; + // let output = "FA14075000;"; // set VFO A frequency + // let output = "FA;"; // ask for VFO A frequency + let output = "SM;"; // ask for S-meter reading // What are we actually sending? //dbg!(output.as_bytes()); - // port.write(output).expect("Write failed!"); match port.write(output.as_bytes()) { Ok(_) => { @@ -31,7 +31,8 @@ fn get_smeter(comport: &str) -> String { Err(e) => eprintln!("{:?}", e), } - // Sleep to allow the device to switch from read to write + // Sleep to allow the device to switch from read to write. + // Otherwise we can lose some bytes on read. sleep(Duration::from_millis(50)); let mut buf = [0u8; 1024]; @@ -41,6 +42,7 @@ fn get_smeter(comport: &str) -> String { let data = String::from_utf8_lossy(&buf[..n]).to_string(); //dbg!(data.as_bytes()); //let value = data; + // For S-meter, just take the numbers let value = &data[2..5]; return format!("{}", value); // return;