After adding the SFO drift (4.25 * sfo_hat) to the fractional STO, the
value was wrapped back into [-0.5, 0.5] but the removed whole chip was
discarded, misaligning subsequent symbols by m_osFactor samples. This
mostly bites at high SF with clock drift, where the drift term can
reach ~0.3+ chips.
- Fold the wrapped chip(s) into the returned FIFO advance (-chips * os).
- Wrap via loRaRound() (half away from zero), so |sto_frac| >= 0.5 now
wraps; previously exactly 0.5 did not. Equivalent timing either way.
- Reset non-finite STO before rounding (float->int cast of NaN/inf is UB).
- Log when the FIFO advance is clamped to 1.
writeData() runs on the audio input thread and iterates m_audioFifos
without a lock, while addFifo()/removeFifo() are called from other
threads. A modulator with audio input (e.g. SSB Mod) removes and re-adds
its FIFO each time it starts, so starting a Tx device while audio is
flowing could crash in AudioFifo::write() (SIGSEGV in
QBasicMutex::lockInternal) when the list changed under the iteration.
Keying the transmitter often (e.g. FT8 via WSJT-X) hit it within hours.
Protect the list with its own mutex, held only for the list operations.
m_mutex is left alone, so this does not bring back the lockups the
commented out lock in writeData() was removed for.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exporting opened the file ReadWrite without truncation, so exporting over
a longer earlier export left its tail in the file and the import then
failed with "Cannot deserialize configuration from file".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
All existing jobs use libiio 0.x (distribution package or external/),
so the libiio 1.x code path was never compiled in CI. Add a server-only
Ubuntu job that configures with ENABLE_LIBIIO_V1, lets external/ build
libiio 1.0.0, checks that the 1.x API was selected and builds the
PlutoSDR device library and plugins. It only runs when PlutoSDR or
libiio related files change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
RTTY, NAVTEX and ILS demods read logFilename/logEnabled from
getAdsbDemodSettings(), which is null for those channels, so a PATCH of
either key crashes SDRangel. Also fix M17 Mod reverseAPIChannelIndex
(read from NFM Mod settings), Audio CAT SISO settings get and XTRX MIMO
reverse API settings and report (Input instead of MIMO types), and
BladeRF2 Output title (BladeRF1 settings).
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>