Snapshot.
This commit is contained in:
+6
-4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user