[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:
@@ -686,16 +686,16 @@ mod tests {
|
|||||||
frame.push(ch << 1);
|
frame.push(ch << 1);
|
||||||
}
|
}
|
||||||
frame.push(0 << 1); // SSID=0, last=false
|
frame.push(0 << 1); // SSID=0, last=false
|
||||||
// Source address (7 bytes)
|
// Source address (7 bytes)
|
||||||
let src_bytes = format!("{:<6}", src);
|
let src_bytes = format!("{:<6}", src);
|
||||||
for &ch in src_bytes.as_bytes().iter().take(6) {
|
for &ch in src_bytes.as_bytes().iter().take(6) {
|
||||||
frame.push(ch << 1);
|
frame.push(ch << 1);
|
||||||
}
|
}
|
||||||
frame.push((0 << 1) | 1); // SSID=0, last=true
|
frame.push((0 << 1) | 1); // SSID=0, last=true
|
||||||
// Control + PID
|
// Control + PID
|
||||||
frame.push(0x03); // UI frame
|
frame.push(0x03); // UI frame
|
||||||
frame.push(0xF0); // No layer-3 protocol
|
frame.push(0xF0); // No layer-3 protocol
|
||||||
// Info field
|
// Info field
|
||||||
frame.extend_from_slice(info);
|
frame.extend_from_slice(info);
|
||||||
frame
|
frame
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,9 +144,15 @@ impl ImageAssembler {
|
|||||||
}
|
}
|
||||||
debug_assert_eq!(img_data.len(), expected_bytes);
|
debug_assert_eq!(img_data.len(), expected_bytes);
|
||||||
|
|
||||||
writer
|
writer.write_image_data(&img_data).map_err(|e| {
|
||||||
.write_image_data(&img_data)
|
format!(
|
||||||
.map_err(|e| format!("write PNG data ({} bytes, {}x{}): {}", img_data.len(), width, height, e))?;
|
"write PNG data ({} bytes, {}x{}): {}",
|
||||||
|
img_data.len(),
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
// Explicitly finish the writer (writes IEND). Relying on Drop
|
// Explicitly finish the writer (writes IEND). Relying on Drop
|
||||||
// alone swallows any I/O error and can yield a truncated file.
|
// 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].
|
// of the NEXT line in the range [spl - max_shift, spl + max_shift].
|
||||||
while self.buffer.len() >= 2 * spl + max_shift {
|
while self.buffer.len() >= 2 * spl + max_shift {
|
||||||
let prev = &self.buffer[0..spl];
|
let prev = &self.buffer[0..spl];
|
||||||
let (best_d, _best_r) =
|
let (best_d, _best_r) = search_best_shift(prev, &self.buffer, spl, max_shift);
|
||||||
search_best_shift(prev, &self.buffer, spl, max_shift);
|
|
||||||
|
|
||||||
let start = (spl as i32 + best_d) as usize;
|
let start = (spl as i32 + best_d) as usize;
|
||||||
let next_line = self.buffer[start..start + spl].to_vec();
|
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
|
// 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
|
// bar in the UI updates at the full server-side 30 Hz without being
|
||||||
// gated on state polls or user commands.
|
// gated on state polls or user commands.
|
||||||
let meter_supervisor =
|
let meter_supervisor = tokio::spawn(run_meter_supervisor(config.clone(), shutdown_rx.clone()));
|
||||||
tokio::spawn(run_meter_supervisor(config.clone(), shutdown_rx.clone()));
|
|
||||||
|
|
||||||
let mut reconnect_delay = Duration::from_secs(1);
|
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
|
/// one dedicated TCP connection per rig that streams `MeterUpdate` JSON lines
|
||||||
/// (see `trx_protocol::MeterUpdate`). Each per-rig task owns its own watch
|
/// (see `trx_protocol::MeterUpdate`). Each per-rig task owns its own watch
|
||||||
/// sender in `config.rig_meters` and reconnects on failure.
|
/// sender in `config.rig_meters` and reconnects on failure.
|
||||||
async fn run_meter_supervisor(
|
async fn run_meter_supervisor(config: RemoteClientConfig, mut shutdown_rx: watch::Receiver<bool>) {
|
||||||
config: RemoteClientConfig,
|
|
||||||
mut shutdown_rx: watch::Receiver<bool>,
|
|
||||||
) {
|
|
||||||
let mut tasks: HashMap<String, tokio::task::JoinHandle<()>> = HashMap::new();
|
let mut tasks: HashMap<String, tokio::task::JoinHandle<()>> = HashMap::new();
|
||||||
let mut poll = time::interval(Duration::from_millis(500));
|
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 (reader, mut writer) = stream.into_split();
|
||||||
let mut reader = BufReader::new(reader);
|
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)
|
let mut payload = serde_json::to_string(&envelope)
|
||||||
.map_err(|e| RigError::communication(format!("JSON serialize failed: {e}")))?;
|
.map_err(|e| RigError::communication(format!("JSON serialize failed: {e}")))?;
|
||||||
payload.push('\n');
|
payload.push('\n');
|
||||||
|
|||||||
@@ -16,29 +16,63 @@ pub enum ClientCommand {
|
|||||||
GetState,
|
GetState,
|
||||||
GetRigs,
|
GetRigs,
|
||||||
GetSatPasses,
|
GetSatPasses,
|
||||||
SetFreq { freq_hz: u64 },
|
SetFreq {
|
||||||
SetCenterFreq { freq_hz: u64 },
|
freq_hz: u64,
|
||||||
SetMode { mode: String },
|
},
|
||||||
SetPtt { ptt: bool },
|
SetCenterFreq {
|
||||||
|
freq_hz: u64,
|
||||||
|
},
|
||||||
|
SetMode {
|
||||||
|
mode: String,
|
||||||
|
},
|
||||||
|
SetPtt {
|
||||||
|
ptt: bool,
|
||||||
|
},
|
||||||
PowerOn,
|
PowerOn,
|
||||||
PowerOff,
|
PowerOff,
|
||||||
ToggleVfo,
|
ToggleVfo,
|
||||||
Lock,
|
Lock,
|
||||||
Unlock,
|
Unlock,
|
||||||
GetTxLimit,
|
GetTxLimit,
|
||||||
SetTxLimit { limit: u8 },
|
SetTxLimit {
|
||||||
SetAprsDecodeEnabled { enabled: bool },
|
limit: u8,
|
||||||
SetHfAprsDecodeEnabled { enabled: bool },
|
},
|
||||||
SetCwDecodeEnabled { enabled: bool },
|
SetAprsDecodeEnabled {
|
||||||
SetCwAuto { enabled: bool },
|
enabled: bool,
|
||||||
SetCwWpm { wpm: u32 },
|
},
|
||||||
SetCwToneHz { tone_hz: u32 },
|
SetHfAprsDecodeEnabled {
|
||||||
SetFt8DecodeEnabled { enabled: bool },
|
enabled: bool,
|
||||||
SetFt4DecodeEnabled { enabled: bool },
|
},
|
||||||
SetFt2DecodeEnabled { enabled: bool },
|
SetCwDecodeEnabled {
|
||||||
SetWsprDecodeEnabled { enabled: bool },
|
enabled: bool,
|
||||||
SetLrptDecodeEnabled { enabled: bool },
|
},
|
||||||
SetWefaxDecodeEnabled { 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,
|
ResetAprsDecoder,
|
||||||
ResetHfAprsDecoder,
|
ResetHfAprsDecoder,
|
||||||
ResetCwDecoder,
|
ResetCwDecoder,
|
||||||
@@ -48,18 +82,44 @@ pub enum ClientCommand {
|
|||||||
ResetWsprDecoder,
|
ResetWsprDecoder,
|
||||||
ResetLrptDecoder,
|
ResetLrptDecoder,
|
||||||
ResetWefaxDecoder,
|
ResetWefaxDecoder,
|
||||||
SetBandwidth { bandwidth_hz: u32 },
|
SetBandwidth {
|
||||||
SetSdrGain { gain_db: f64 },
|
bandwidth_hz: u32,
|
||||||
SetSdrLnaGain { gain_db: f64 },
|
},
|
||||||
SetSdrAgc { enabled: bool },
|
SetSdrGain {
|
||||||
SetSdrSquelch { enabled: bool, threshold_db: f64 },
|
gain_db: f64,
|
||||||
SetSdrNoiseBlanker { enabled: bool, threshold: f64 },
|
},
|
||||||
SetWfmDeemphasis { deemphasis_us: u32 },
|
SetSdrLnaGain {
|
||||||
SetWfmStereo { enabled: bool },
|
gain_db: f64,
|
||||||
SetWfmDenoise { level: WfmDenoiseLevel },
|
},
|
||||||
SetSamStereoWidth { width: f32 },
|
SetSdrAgc {
|
||||||
SetSamCarrierSync { enabled: bool },
|
enabled: bool,
|
||||||
SetRecorderEnabled { 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,
|
GetSpectrum,
|
||||||
/// Subscribe to a per-rig meter stream on this connection. After the
|
/// Subscribe to a per-rig meter stream on this connection. After the
|
||||||
/// server receives this command, the connection becomes a one-way flow of
|
/// 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 tracing::{debug, error, info, warn};
|
||||||
|
|
||||||
use trx_backend::{RegistrationContext, RigAccess};
|
use trx_backend::{RegistrationContext, RigAccess};
|
||||||
use trx_protocol::MeterUpdate;
|
|
||||||
use trx_core::radio::freq::Freq;
|
use trx_core::radio::freq::Freq;
|
||||||
use trx_core::rig::command::RigCommand;
|
use trx_core::rig::command::RigCommand;
|
||||||
use trx_core::rig::controller::{
|
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::state::{RigMode, RigSnapshot, RigState};
|
||||||
use trx_core::rig::{RigCat, RigRxStatus, RigTxStatus};
|
use trx_core::rig::{RigCat, RigRxStatus, RigTxStatus};
|
||||||
use trx_core::{DynResult, RigError, RigResult};
|
use trx_core::{DynResult, RigError, RigResult};
|
||||||
|
use trx_protocol::MeterUpdate;
|
||||||
|
|
||||||
use crate::audio::DecoderHistories;
|
use crate::audio::DecoderHistories;
|
||||||
use crate::error::is_invalid_bcd_error;
|
use crate::error::is_invalid_bcd_error;
|
||||||
|
|||||||
Reference in New Issue
Block a user