From d694418ddaa0a3e3369b3c398ac936a761798891 Mon Sep 17 00:00:00 2001 From: Martin Brodbeck Date: Tue, 5 Dec 2023 08:58:00 +0100 Subject: [PATCH] do not read power from flrig --- README.md | 2 ++ clrigctl.toml | 2 ++ src/flrig.rs | 4 ++-- src/main.rs | 17 ++++++++++------- src/settings.rs | 1 + 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0a47cdd..6f6ffb5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,8 @@ Copy the example config file `clrigctl.toml` to `$HOME/.config/` and adapt it to # This is an example config file. Please edit it to your needs # and place it, for example, in your `$HOME/.config/` +power = "5" # Output power in W + [cloudlog] # Note: URL should end with "/index.php/api/radio". url = "https://cloudlog.example.com/index.php/api/radio" diff --git a/clrigctl.toml b/clrigctl.toml index 915df54..b1f3995 100644 --- a/clrigctl.toml +++ b/clrigctl.toml @@ -1,6 +1,8 @@ # This is an example config file. Please edit it to your needs # and place it, for example, in your `$HOME/.config/` +power = "5" # Output power in W + [cloudlog] # Note: URL should end with "/index.php/api/radio". url = "https://cloudlog.example.com/index.php/api/radio" diff --git a/src/flrig.rs b/src/flrig.rs index 6ed501a..053373c 100644 --- a/src/flrig.rs +++ b/src/flrig.rs @@ -9,7 +9,7 @@ use std::result::Result; pub fn get_radio_data(fl_host: &str, fl_port: &str) -> Result { let cmd_freq = "rig.get_vfo"; let cmd_mode = "rig.get_mode"; - let cmd_power = "rig.get_power"; + let cmd_power = "rig.get_power"; // Currently not used. let client = reqwest::Client::new(); @@ -21,7 +21,7 @@ pub fn get_radio_data(fl_host: &str, fl_port: &str) -> Result let mode = parse_xml(&mode); let power = parse_xml(&power); - debug!("freq: {freq} --- mode: {mode} --- power: {power}"); + debug!("freq: {freq} --- mode: {mode} --- power: {power} (unused)"); let radio_data = RadioData { key: String::from(""), diff --git a/src/main.rs b/src/main.rs index 211dff0..5592772 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,8 +2,8 @@ mod cloudlog; mod flrig; mod settings; -use std::{thread, time::Duration}; use log::debug; +use std::{process, thread, time::Duration}; use crate::cloudlog::RadioData; use settings::Settings; @@ -13,14 +13,17 @@ fn main() { debug!("clrigctl started.\n"); - let settings = Settings::new().expect("Could not read settings."); + let settings = Settings::new().unwrap_or_else(|err| { + eprintln!("Could not read settings: {}", err); + process::exit(1) + }); let mut radio_data_current = RadioData { key: settings.cloudlog.key, radio: settings.cloudlog.identifier, - frequency: String::from("14017000"), - mode: String::from("CW"), - power: String::from("5"), + frequency: String::from(""), + mode: String::from(""), + power: String::from(&settings.power), }; let mut changes_detected = false; @@ -37,12 +40,12 @@ fn main() { if radio_data_current.frequency != radio_data_new.frequency || radio_data_current.mode != radio_data_new.mode - || radio_data_current.power != radio_data_new.power + //|| radio_data_current.power != radio_data_new.power { changes_detected = true; radio_data_current.frequency = radio_data_new.frequency; radio_data_current.mode = radio_data_new.mode; - radio_data_current.power = radio_data_new.power; + //radio_data_current.power = radio_data_new.power; } if changes_detected { diff --git a/src/settings.rs b/src/settings.rs index 503cee7..e7921e1 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -22,6 +22,7 @@ pub struct Flrig { pub struct Settings { pub cloudlog: Cloudlog, pub flrig: Flrig, + pub power: String, } impl Settings {