[style](trx-rs): apply cargo fmt formatting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -144,9 +144,15 @@ impl ImageAssembler {
|
||||
}
|
||||
debug_assert_eq!(img_data.len(), expected_bytes);
|
||||
|
||||
writer
|
||||
.write_image_data(&img_data)
|
||||
.map_err(|e| format!("write PNG data ({} bytes, {}x{}): {}", img_data.len(), width, height, e))?;
|
||||
writer.write_image_data(&img_data).map_err(|e| {
|
||||
format!(
|
||||
"write PNG data ({} bytes, {}x{}): {}",
|
||||
img_data.len(),
|
||||
width,
|
||||
height,
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
// Explicitly finish the writer (writes IEND). Relying on Drop
|
||||
// alone swallows any I/O error and can yield a truncated file.
|
||||
|
||||
@@ -129,8 +129,7 @@ impl LineSlicer {
|
||||
// of the NEXT line in the range [spl - max_shift, spl + max_shift].
|
||||
while self.buffer.len() >= 2 * spl + max_shift {
|
||||
let prev = &self.buffer[0..spl];
|
||||
let (best_d, _best_r) =
|
||||
search_best_shift(prev, &self.buffer, spl, max_shift);
|
||||
let (best_d, _best_r) = search_best_shift(prev, &self.buffer, spl, max_shift);
|
||||
|
||||
let start = (spl as i32 + best_d) as usize;
|
||||
let next_line = self.buffer[start..start + spl].to_vec();
|
||||
|
||||
@@ -95,8 +95,7 @@ pub async fn run_remote_client(
|
||||
// soon as short names are discovered. Runs independently so the meter
|
||||
// bar in the UI updates at the full server-side 30 Hz without being
|
||||
// gated on state polls or user commands.
|
||||
let meter_supervisor =
|
||||
tokio::spawn(run_meter_supervisor(config.clone(), shutdown_rx.clone()));
|
||||
let meter_supervisor = tokio::spawn(run_meter_supervisor(config.clone(), shutdown_rx.clone()));
|
||||
|
||||
let mut reconnect_delay = Duration::from_secs(1);
|
||||
|
||||
@@ -228,10 +227,7 @@ async fn run_spectrum_connection(
|
||||
/// one dedicated TCP connection per rig that streams `MeterUpdate` JSON lines
|
||||
/// (see `trx_protocol::MeterUpdate`). Each per-rig task owns its own watch
|
||||
/// sender in `config.rig_meters` and reconnects on failure.
|
||||
async fn run_meter_supervisor(
|
||||
config: RemoteClientConfig,
|
||||
mut shutdown_rx: watch::Receiver<bool>,
|
||||
) {
|
||||
async fn run_meter_supervisor(config: RemoteClientConfig, mut shutdown_rx: watch::Receiver<bool>) {
|
||||
let mut tasks: HashMap<String, tokio::task::JoinHandle<()>> = HashMap::new();
|
||||
let mut poll = time::interval(Duration::from_millis(500));
|
||||
|
||||
@@ -345,7 +341,11 @@ async fn stream_meter(
|
||||
let (reader, mut writer) = stream.into_split();
|
||||
let mut reader = BufReader::new(reader);
|
||||
|
||||
let envelope = build_envelope(config, ClientCommand::SubscribeMeter, Some(short_name.to_string()));
|
||||
let envelope = build_envelope(
|
||||
config,
|
||||
ClientCommand::SubscribeMeter,
|
||||
Some(short_name.to_string()),
|
||||
);
|
||||
let mut payload = serde_json::to_string(&envelope)
|
||||
.map_err(|e| RigError::communication(format!("JSON serialize failed: {e}")))?;
|
||||
payload.push('\n');
|
||||
|
||||
@@ -16,29 +16,63 @@ pub enum ClientCommand {
|
||||
GetState,
|
||||
GetRigs,
|
||||
GetSatPasses,
|
||||
SetFreq { freq_hz: u64 },
|
||||
SetCenterFreq { freq_hz: u64 },
|
||||
SetMode { mode: String },
|
||||
SetPtt { ptt: bool },
|
||||
SetFreq {
|
||||
freq_hz: u64,
|
||||
},
|
||||
SetCenterFreq {
|
||||
freq_hz: u64,
|
||||
},
|
||||
SetMode {
|
||||
mode: String,
|
||||
},
|
||||
SetPtt {
|
||||
ptt: bool,
|
||||
},
|
||||
PowerOn,
|
||||
PowerOff,
|
||||
ToggleVfo,
|
||||
Lock,
|
||||
Unlock,
|
||||
GetTxLimit,
|
||||
SetTxLimit { limit: u8 },
|
||||
SetAprsDecodeEnabled { enabled: bool },
|
||||
SetHfAprsDecodeEnabled { enabled: bool },
|
||||
SetCwDecodeEnabled { enabled: bool },
|
||||
SetCwAuto { enabled: bool },
|
||||
SetCwWpm { wpm: u32 },
|
||||
SetCwToneHz { tone_hz: u32 },
|
||||
SetFt8DecodeEnabled { enabled: bool },
|
||||
SetFt4DecodeEnabled { enabled: bool },
|
||||
SetFt2DecodeEnabled { enabled: bool },
|
||||
SetWsprDecodeEnabled { enabled: bool },
|
||||
SetLrptDecodeEnabled { enabled: bool },
|
||||
SetWefaxDecodeEnabled { enabled: bool },
|
||||
SetTxLimit {
|
||||
limit: u8,
|
||||
},
|
||||
SetAprsDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetHfAprsDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetCwDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetCwAuto {
|
||||
enabled: bool,
|
||||
},
|
||||
SetCwWpm {
|
||||
wpm: u32,
|
||||
},
|
||||
SetCwToneHz {
|
||||
tone_hz: u32,
|
||||
},
|
||||
SetFt8DecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetFt4DecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetFt2DecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetWsprDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetLrptDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
SetWefaxDecodeEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
ResetAprsDecoder,
|
||||
ResetHfAprsDecoder,
|
||||
ResetCwDecoder,
|
||||
@@ -48,18 +82,44 @@ pub enum ClientCommand {
|
||||
ResetWsprDecoder,
|
||||
ResetLrptDecoder,
|
||||
ResetWefaxDecoder,
|
||||
SetBandwidth { bandwidth_hz: u32 },
|
||||
SetSdrGain { gain_db: f64 },
|
||||
SetSdrLnaGain { gain_db: f64 },
|
||||
SetSdrAgc { enabled: bool },
|
||||
SetSdrSquelch { enabled: bool, threshold_db: f64 },
|
||||
SetSdrNoiseBlanker { enabled: bool, threshold: f64 },
|
||||
SetWfmDeemphasis { deemphasis_us: u32 },
|
||||
SetWfmStereo { enabled: bool },
|
||||
SetWfmDenoise { level: WfmDenoiseLevel },
|
||||
SetSamStereoWidth { width: f32 },
|
||||
SetSamCarrierSync { enabled: bool },
|
||||
SetRecorderEnabled { enabled: bool },
|
||||
SetBandwidth {
|
||||
bandwidth_hz: u32,
|
||||
},
|
||||
SetSdrGain {
|
||||
gain_db: f64,
|
||||
},
|
||||
SetSdrLnaGain {
|
||||
gain_db: f64,
|
||||
},
|
||||
SetSdrAgc {
|
||||
enabled: bool,
|
||||
},
|
||||
SetSdrSquelch {
|
||||
enabled: bool,
|
||||
threshold_db: f64,
|
||||
},
|
||||
SetSdrNoiseBlanker {
|
||||
enabled: bool,
|
||||
threshold: f64,
|
||||
},
|
||||
SetWfmDeemphasis {
|
||||
deemphasis_us: u32,
|
||||
},
|
||||
SetWfmStereo {
|
||||
enabled: bool,
|
||||
},
|
||||
SetWfmDenoise {
|
||||
level: WfmDenoiseLevel,
|
||||
},
|
||||
SetSamStereoWidth {
|
||||
width: f32,
|
||||
},
|
||||
SetSamCarrierSync {
|
||||
enabled: bool,
|
||||
},
|
||||
SetRecorderEnabled {
|
||||
enabled: bool,
|
||||
},
|
||||
GetSpectrum,
|
||||
/// Subscribe to a per-rig meter stream on this connection. After the
|
||||
/// server receives this command, the connection becomes a one-way flow of
|
||||
|
||||
@@ -12,7 +12,6 @@ use tokio::time::{self, Instant};
|
||||
use tracing::{debug, error, info, warn};
|
||||
|
||||
use trx_backend::{RegistrationContext, RigAccess};
|
||||
use trx_protocol::MeterUpdate;
|
||||
use trx_core::radio::freq::Freq;
|
||||
use trx_core::rig::command::RigCommand;
|
||||
use trx_core::rig::controller::{
|
||||
@@ -24,6 +23,7 @@ use trx_core::rig::request::RigRequest;
|
||||
use trx_core::rig::state::{RigMode, RigSnapshot, RigState};
|
||||
use trx_core::rig::{RigCat, RigRxStatus, RigTxStatus};
|
||||
use trx_core::{DynResult, RigError, RigResult};
|
||||
use trx_protocol::MeterUpdate;
|
||||
|
||||
use crate::audio::DecoderHistories;
|
||||
use crate::error::is_invalid_bcd_error;
|
||||
|
||||
Reference in New Issue
Block a user