Other applications (e.g. SoapyPlutoSDR, used by gqrx) leave the RX LO
powered down when they close, so SDRangel only received the AD9361's
own noise. In FDD mode the Tx LO also stays up while no stream runs,
radiating LO leakage when the Tx device is merely opened.
Set the LO powerdown attribute explicitly: power the LO up when a
stream starts, down when it stops or fails, and power the Tx LO down
when the Tx device is opened. Applies to the input, output and MIMO
plugins.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace strncmp()/strlen() in withBackendPrefix() with
std::string::rfind(prefix, 0), as done elsewhere in this file. The
inputs were always null-terminated, but static analysis (Flawfinder,
CWE-126) flags any strlen() use.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Pluto reachable both on its USB gadget network (192.168.2.1) and on a
LAN address is reported as two "ip" contexts. Both got the same key
(<serial>_ip), so m_serialMap kept one of them arbitrarily and selecting
"PlutoSDR0 (ip)" could open the wrong address.
When keys collide, append the address to the backend part of the key,
e.g. <serial>_ip:192.168.50.20, which also shows in the device name. A
device with a single address keeps its usual key, so saved device
references still match. Exact duplicate URIs are skipped, and the
serial and URI maps are now cleared on each scan instead of keeping
entries from previous scans.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With LIBIIO_V1, Tx channels are enabled in an iio_channels_mask and
samples are sent through an iio_stream with 4 blocks. createTxBuffer()
takes the first empty block without queueing anything; txBufferPush()
queues the filled block and waits for the next free one, so
txBufferFirst()/End() always point at the block being filled. Cyclic
buffers are not available through iio_stream and SDRangel never
requests them.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With LIBIIO_V1, Rx channels are enabled in an iio_channels_mask and
samples are streamed through an iio_stream with 4 blocks in flight.
rxBufferRefill() fetches the next filled block, which hands the previous
one back to the hardware, and rxBufferFirst()/End()/Step() read from
that block. The box API is unchanged, so the Rx threads need no changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With LIBIIO_V1, create contexts with iio_create_context() and check for
pointer-encoded errors. Attribute access goes through struct iio_attr:
iio_device_identify_filename() is gone, so a small helper resolves the
sysfs file name to a channel, device or debug attribute in the same
order 0.x used. Values are read with iio_attr_read_raw() and written
with iio_attr_write_string() / iio_attr_write_raw().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
iio_create_scan_context() and the iio_context_info list were removed in
libiio 1.x. Use iio_scan() and the iio_scan_get_*() accessors when
LIBIIO_V1 is set. Also release the 0.x scan context when listing fails.
libiio 1.x reports network contexts as a bare mDNS host name with no
"ip:" prefix, so the probe failed and the hostname-to-IP rewrite and
backend labels never applied. Add the prefix when no backend is given,
and probe the rewritten URI: the .local name can resolve to another
interface (e.g. the USB gadget network) than the one that was scanned.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libiio 1.x installs its header as include/iio/iio.h instead of
include/iio.h. Look for the 1.x layout first and fall back to the 0.x
one, and set LIBIIO_V1 so plutosdrdevice can select the API at compile
time. The bundled external build (v0.26) keeps the 0.x path.
The input and output plugin headers only need the iio_buffer type, so
forward-declare it instead of including iio.h.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Avoid copying the UHD shared-pointer handle when enabling automatic
master clock rate selection. Passing the handle by const reference
reduces unnecessary reference-count operations while preserving
access to the underlying USRP device.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Use std::move when initializing the restoreAutoTickRate guard to
avoid an unnecessary copy of properties. Include utility explicitly
for std::move and make ownership transfer intent clear, reducing
overhead during USRP device initialization.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
stop() tore the sample thread down with stopWork() + delete and only then
cleared m_deviceShared.m_thread. The buddy's applySettings() suspends and
resumes that thread through m_thread from another thread, without holding
this device's mutex, so it could restart the thread between stopWork() and
delete (QThread: Destroyed while thread is still running -> qFatal/abort),
or call through the pointer after the delete. The device's own
applySettings() had the same exposure on its own thread pointer, since it
does not take m_mutex either.
Seen when the Satellite Tracker loads presets into the Rx and Tx device
sets of one Pluto at AOS: abort in PlutoSDRInputThread::~PlutoSDRInputThread
<- PlutoSDRInput::stop <- DSPDeviceSourceEngine::gotoIdle.
Add DevicePlutoSDRShared::m_threadsMutex (recursive, shared by all PlutoSDR
device sets) and take it in start() around startWork()/publish, in stop()
and handleError() around unpublish + teardown (unpublishing first), in
suspendBuddies()/resumeBuddies(), and for the whole suspend -> apply ->
resume sequence in applySettings(). Also wait() before deleting the thread
and check the own-thread pointer before resuming it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Fix TX scaling bug that was costing 10dB of output power at max gain.
Improve performance on Windows to reduce overruns at high sample rates.
Add underrun stats.
Display temperature.
Improve error handling.
Move setting device settings off GUI thread. For #1522
Transfer ownership of the temporary fixed URI into DeviceScan and the
newly created shared pointer into the scan list instead of copying them.
Neither object is used after the transfer, so moving avoids unnecessary
string and shared_ptr copies and makes the intended ownership transfer
explicit.
This fixes Coverity CIDs 652268 and 652358 (COPY_INSTEAD_OF_MOVE).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Add a null check for the IIO scan context description before using it
to construct a std::string or std::string_view.
This also makes the non-null assumption explicit for static analysis and
fixes Coverity CID 652283 (FORWARD_NULL).
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Replace signed %d format specifiers with unsigned %u when formatting
sample rates and channel numbers.
The previous format strings passed unsigned int values to %d conversions,
which triggered cppcheck invalidPrintfArgType_sint warnings and could
result in undefined behavior due to variadic argument type mismatches.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Query the PlutoSDR hardware for the current RX gain range and use it
to configure the GUI gain control dynamically.
The AD936x gain limits vary with LO frequency. Previously the GUI used
a fixed gain range, allowing users to select values that the hardware
would reject after changing bands. The gain slider now refreshes its
minimum, maximum, and step size whenever the device center frequency is
updated.
Also change the gain setting serialization to use a signed integer so
negative gain values are preserved for operating modes that support
them.
Changes include:
- Add DevicePlutoSDRBox::getGainRange() to read
in_voltage0_hardwaregain_available.
- Expose gain range through PlutoSDRInput.
- Refresh GUI gain limits when the device frequency changes.
- Avoid unnecessary widget updates when limits are unchanged.
- Store/restore gain as a signed value.
- Add default RX gain limit constants for fallback when the device
cannot provide its range.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Fix mDNS discovery ambiguity where multiple devices across
different network segments/subnets can advertise the same hostname (e.g.
"ip:pluto.local"), resulting in non-unique or misleading URIs.
Replace unresolved mDNS hostnames with the actual discovered endpoint
reported in the scan description.
- Detect ".local" URIs on IP backend and substitute hostname with
resolved endpoint from libiio scan results.
- Preserve URI semantics:
- Keep backend prefix ("ip:")
- Preserve optional port suffix
- Correctly format IPv6 literals with RFC2732 bracket notation when
required
- Add replaceHostnameWithIP() to perform URI normalization during scan:
- Only applies to IP backend URIs
- Only triggers for mDNS-based ".local" hostnames
- Uses scan-provided endpoint (from description string) as authoritative
address instead of advertised hostname
- Extend scan() to emit both original and resolved URIs for debugging
and verification during device discovery.
This resolves inconsistent device addressing when multiple PlutoSDRs
are accessible via mDNS across different subnets or network segments.
No change to backend enumeration or device identity logic; this only
normalizes .local IP URI resolution at scan time.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Improve PlutoSDR device identity handling to correctly distinguish
multiple libiio backends (IP, USB, etc.) and provide stable grouping
of physically identical hardware in the UI.
- Append backend prefix to scanned device serials to ensure uniqueness
across multiple discovery paths (e.g. "<serial>_ip", "<serial>_usb").
This prevents collisions when the same device is visible through
different transports.
- Add physical serial extraction and grouping logic so that devices
discovered via multiple backends are treated as a single physical
unit for display purposes. This stabilizes UI numbering and avoids
duplicate entries for the same hardware.
- Update enumOriginDevices() to:
- group devices by physical serial rather than scan index
- assign stable per-device indices independent of backend enumeration
- include backend label in the display name to distinguish connection
paths when multiple backends are active
- Introduce helper utilities:
- createBackendSuffix(): extract backend identifier from libiio URI
- getPhysicalSerial(): strip backend suffix for grouping logic
- getBackendLabel(): format backend suffix for user-facing display
These changes ensure:
- unique internal identifiers per backend connection
- consistent grouping per physical device across discovery mechanisms
- improved UI clarity when multiple access paths exist for the same SDR
No change to RF/data path behavior; this is purely a discovery and
presentation-layer refactor.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Convert tab-based indentation to spaces to match the project's
existing coding style. No functional changes.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Fix multiple issues preventing SoapySDR output from producing RF:
- handleInputMessages() never called in DSP engine thread (Qt signal
lost without event loop) - scheduled properly
- setGain() moved to start() post-activation (pre-activation gain
silently fails on SoapyUHD)
- fullScale threshold corrected for CS16 format detection
- Timed first write pattern matching gr4-lora SoapySink
MCR pinning for SoapyUHD: inject auto_tick_rate=0 in
DeviceSoapySDR device-open path to prevent UHD from re-deriving the
master clock rate on set_tx_rate(), which breaks the decimator chain
and produces no RF. Also reads SDRANGEL_USRP_MASTER_CLOCK_RATE_HZ env
var for optional MCR override.
TX diagnostic counters: SoapySDROutputThread tracks packets,
underflows, errors. Exposed via REST as streamSettingsArgs
key-value pairs.
Ettus B210 has a maximum sampling rate of 61.44MSPS. Exceeding this limit results in unexpected behavior. Prevent this from occurring by decreasing the maximum sample rate by from 61.444MSP to 61.44MSP (-4k).
Fixes#681.
Relying on memory allocated by `std::vector` via direct pointers is dangerous,
as vectors may move buffers during resize. This fix puts the `DeviceScan`
allocation into a `str::shared_ptr`, which 1) allocates the memory on heap and
2) keeps track of the memory through reference counting. Thus it is safe to
store the `shared_ptr` across different vectors/maps.