[fix](trx-backend-soapysdr): enumerate available devices on match failure for diagnostics
When Device::new(args) fails, enumerate all available SoapySDR devices and include them in the error message. Also hint that args are case-sensitive. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -62,11 +62,21 @@ impl RealIqSource {
|
|||||||
// particular device and silently opening a different one would cause
|
// particular device and silently opening a different one would cause
|
||||||
// incorrect behaviour (especially with multiple devices).
|
// incorrect behaviour (especially with multiple devices).
|
||||||
Device::new(args).map_err(|e| {
|
Device::new(args).map_err(|e| {
|
||||||
|
// Enumerate all available devices to help diagnose the mismatch.
|
||||||
|
let available = match soapysdr::enumerate("") {
|
||||||
|
Ok(devs) if !devs.is_empty() => {
|
||||||
|
let list: Vec<String> = devs.iter().map(|d| format!("{}", d)).collect();
|
||||||
|
format!("Available devices:\n {}", list.join("\n "))
|
||||||
|
}
|
||||||
|
Ok(_) => "No SoapySDR devices found.".to_string(),
|
||||||
|
Err(enum_err) => format!("(could not enumerate devices: {})", enum_err),
|
||||||
|
};
|
||||||
format!(
|
format!(
|
||||||
"Failed to open SoapySDR device with args '{}': {}\n \
|
"Failed to open SoapySDR device with args '{}': {}\n \
|
||||||
Troubleshooting: Verify the device is connected and the args are correct. \
|
{}\n \
|
||||||
|
Hint: SoapySDR args are case-sensitive (e.g. 'driver=airspyhf' not 'driver=AirspyHF').\n \
|
||||||
Run SoapySDRUtil --find to list available devices and their identifiers.",
|
Run SoapySDRUtil --find to list available devices and their identifiers.",
|
||||||
args, e
|
args, e, available
|
||||||
)
|
)
|
||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user