[fix](trx-backend-soapysdr): remove silent fallback to first device when args are specified
When specific SoapySDR device args are provided (e.g. with a serial number),
fail hard instead of silently falling back to Device::new("") which opens
the first available device. This caused multi-device setups to bind both
rig instances to the same physical device.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -46,35 +46,29 @@ impl RealIqSource {
|
|||||||
) -> Result<Self, String> {
|
) -> Result<Self, String> {
|
||||||
tracing::info!("Initializing SoapySDR device with args: {}", args);
|
tracing::info!("Initializing SoapySDR device with args: {}", args);
|
||||||
|
|
||||||
let device = match Device::new(args) {
|
let device = if args.trim().is_empty() {
|
||||||
Ok(dev) => dev,
|
// No specific device requested — open the first available device.
|
||||||
Err(e) => {
|
Device::new("").map_err(|e| {
|
||||||
tracing::warn!(
|
format!(
|
||||||
"Failed to open device with args '{}': {}. Attempting fallback...",
|
"Failed to open SoapySDR device with empty args: {}\n \
|
||||||
args,
|
Troubleshooting: Check that SoapySDR is installed and plugins are loaded. \
|
||||||
|
Try running SoapySDRUtil --probe to verify device availability.",
|
||||||
e
|
e
|
||||||
);
|
)
|
||||||
match Device::new("") {
|
})?
|
||||||
Ok(dev) => {
|
} else {
|
||||||
tracing::warn!(
|
// Specific device args provided (e.g. "driver=rtlsdr,serial=00000001").
|
||||||
"Successfully opened a device with empty args (fallback). \
|
// Do NOT fall back to empty args — the user explicitly requested a
|
||||||
Note: this may not be the intended device. \
|
// particular device and silently opening a different one would cause
|
||||||
If this is incorrect, check SoapySDR environment variables and plugins."
|
// incorrect behaviour (especially with multiple devices).
|
||||||
);
|
Device::new(args).map_err(|e| {
|
||||||
dev
|
format!(
|
||||||
}
|
"Failed to open SoapySDR device with args '{}': {}\n \
|
||||||
Err(fallback_err) => {
|
Troubleshooting: Verify the device is connected and the args are correct. \
|
||||||
return Err(format!(
|
Run SoapySDRUtil --find to list available devices and their identifiers.",
|
||||||
"Failed to open SoapySDR device:\n \
|
args, e
|
||||||
Original args '{}': {}\n \
|
)
|
||||||
Fallback (empty args): {}\n \
|
})?
|
||||||
Troubleshooting: Check that SoapySDR is installed and plugins are loaded. \
|
|
||||||
Try running SoapySDRUtil --probe to verify device availability.",
|
|
||||||
args, e, fallback_err
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
tracing::info!("SoapySDR device opened successfully");
|
tracing::info!("SoapySDR device opened successfully");
|
||||||
|
|||||||
Reference in New Issue
Block a user