With ENABLE_LIBIIO_V1, the Linux external build now fetches libiio
v1.0.0 instead of v0.26, points LIBIIO_INCLUDE_DIR at its include/
directory (for iio/iio.h) and sets LIBIIO_V1. The 0.x compatibility
library, utilities, iiod, examples and tests are not built. libiio 1.x
additionally needs libzstd and libavahi-client.
Building libiio 1.x from source is not set up for Windows and macOS yet:
there ENABLE_LIBIIO_V1 prints a warning and the 0.x build is used.
Nothing changes when ENABLE_LIBIIO_V1 is off.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
libiio 1.0 is new and not yet packaged by distributions, so keep the
0.x API as the default and add ENABLE_LIBIIO_V1 (default OFF) to build
against 1.x explicitly.
The finder used to look for the 1.x header in IIO_DIR and in the system
paths before falling back to 0.x, independently of where it found the
library. With 1.x installed system-wide and IIO_DIR pointing at 0.26,
it combined 1.x headers with the 0.26 library and the link failed. Now
each candidate install (IIO_DIR, then the one pkg-config reports, then
the system paths) must provide both the header and the library for the
requested API; an install with the other API is skipped with a message.
Changing ENABLE_LIBIIO_V1 triggers detection again in an existing build
directory.
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>
Resolve GCC -Wreorder by moving m_spectrumBinHz before
m_autoUnlockedSamples in the constructor initializer list to
match declaration order in the header. C++ initializes members
in declaration order regardless of initializer list order, so
keeping the list aligned avoids misleading initialization
sequences and helps prevent future initialization bugs.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Resolve GCC -Wtype-limits warnings by removing upper-bound
comparisons that are always true or false for uint16_t.
The port's type already enforces the maximum value of 65535;
validation of wider input values remains in place before casting.
Signed-off-by: Robin Getz <rgetz503@gmail.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>
Remove the unused eta variable in Receiver::decodeFrame().
The value returned by bitsPerCell() was never used, so its
calculation is unnecessary and removing it eliminates the
unused-variable compiler warning without changing behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Resolve the compiler warning for the unused frequencyHz parameter
in processAcquisitionSample(). Use Q_UNUSED to explicitly document
that the parameter is intentionally unused without changing behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>
Resolve GCC -Wmissing-field-initializers by explicitly initializing
the onEdit callback to an empty std::function. This ensures the
callback starts in a defined empty state and avoids relying on
implicit aggregate initialization behavior.
Signed-off-by: Robin Getz <rgetz503@gmail.com>