Replace the C stdio calls in the GNSS-SDR.dump_flowgraph code with
std::ofstream. This removes the reliance on <cstdio>, <cstring> and
<cerrno>, which were only included transitively, and closes the file
on every path.
A failure to open or write the file is now reported with a single
warning, and the success message is logged only if the file was
actually written.
The flag that makes the preamble search skip the head of the buffer
after a CRC failure was set and consumed within the same call to
cnav_add_symbol_(), so it does not need to be stored in
cnav_v27_part_t. Pass it to cnav_rescan_preamble_() as a parameter and
keep it as a local variable. The decoder behaves as before.
Shorten the changelog entry.
EVK1029_CtrlApp writes a 16 KiB metadata header at the start of every
recording. In file mode, EVK1029_Signal_Source now starts reading after
it instead of decoding it as samples. seconds_to_skip is counted from
the end of the header.
Signed-off-by: joebre <joel.brenner@saphyrion.ch>
The BeiDou DNAV and GLONASS GNAV decoders find from the sign of the
preamble (or time mark) correlation that the carrier loop is locked
180 degrees off and invert the symbols they decode, but they never set
Flag_PLL_180_deg_phase_locked, so the flag that reaches the
observables is the one the tracking block set.
Keep the sign of the last frame that passed its CRC check and, as the
GPS and Galileo decoders do, report it in
Flag_PLL_180_deg_phase_locked and add half a cycle to the carrier
phase while it is set.
The new unit tests feed BeiDou D1 subframes and GLONASS strings,
normal and inverted, to the decoders and check the reported flag and
carrier phase, a polarity change, and a GLONASS string that fails its
Hamming check.
Signed-off-by: Oleksandr Suvorov <cryosay@gmail.com>
The preamble search of the CNAV message decoder (libswiftcnav) started
at position 1 of the decoded bits buffer and stopped one window short
of its end, and when it found nothing it kept the last 7 bits, which
became positions 0 to 6 of the next search. The Viterbi decoder
delivers 32 bits at a time, so every search saw 39 bits and tested the
windows starting at 1 to 30. A preamble starting at position 31 was
complete in the buffer but not tested, and lost its first bit in the
shift; one starting at position 32 landed at position 0 of the next
search, which was skipped. For 2 of the 32 positions of the preamble
with respect to the 32-bit blocks, the first message after the start
of tracking was lost although all its symbols were received. With a
short capture this can leave a GPS L2C or L5 satellite without the
MT10, MT11 and clock messages needed for an ephemeris set.
Skipping position 0 is right only when the search follows a CRC
failure, where the buffer starts with the preamble pattern that has
just been rejected. Test every complete 8-bit window, from position 0
to n_decoded - 8, and skip position 0 only in that rescan (new
skip_first flag of cnav_v27_part_t, set where the CRC failure is
handled and cleared by the search).
The new unit tests encode two consecutive CNAV messages (CRC-24Q,
rate 1/2 K=7 convolutional code) and feed them to the decoder with the
first preamble at each of the 32 positions, for both symbol-pair
phases and both polarities, and with a preamble pattern that fails
the CRC check at each distance from 8 to 371 bits ahead of the first
message.
Signed-off-by: Ben Gant <indigma04@gmail.com>
Since v0.0.22, Galileo observables reached RINEX and RTCM only through
select_galileo_ephemeris(), which rejects the E5 signal that the solver
leaves out. With E5a and E5b enabled, the PVT uses I/NAV and E5b, so the
E5a RINEX fields stayed blank and E5a was missing from MSM. Admit that
signal when its own F/NAV ephemeris is usable and reports it healthy (or
PVT.use_unhealthy_sats is set). The solver still never sees it.
With PVT.iono_model=Iono-Free-LC, prange() drops every satellite that
lacks either band of its system's pair, so receivers such as Galileo
E5a+E5b without E1, or any single-band one, computed no position and
wrote no RINEX. Fall back to the broadcast model, with a log warning,
when no enabled constellation provides a pair, and log the constellations
left out otherwise.
The MSM fine pseudorange, phase-range and phase-range-rate fields (DF400,
DF401, DF404, DF405, DF406) were computed against a rough value rounded
from each signal's own measurement instead of the satellite's DF397 to
DF399, so the other signals of a satellite were occasionally decoded
292.77 m or 1 m/s off. DF401/DF406 also moved the phase-range to within
one cycle of the rough range at every epoch, which broke its integer
continuity. Reference all fine fields to the satellite's rough values and
send the phase-range as is, or as invalid beyond 1171 m.
Keep RTCM lock times per signal instead of per PRN and band group (GPS
L2C/L5 and Galileo E5a/E5b shared one), and restart them on cycle and
half-cycle slips and when the PVT block realigns a channel's carrier
phase.
prange() already returns iono_scale=(f_L1/f_band)^2 for single-band measurements on the second slot. The SPP solver then applied the wavelength factor (lambda_band/lambda_L1)^2 again, so L2C/L5 iono corrections were over-scaled by 1.65x/1.79x. For L5 this biases the height solution by about -4 m on an otherwise sub-metre 2D fix.
Only apply the legacy wavelength factor when prange() did not already provide a band factor (iono_scale == 1.0). L1 is unaffected.
Signed-off-by: yangli-cnasp <66191093+yangli-cnasp@users.noreply.github.com>
Pick the band rule from the estimator that produced the fix:
prange() pairing for single-point fixes, vsat[] for DGPS/RTK.
Check that each signal's slot holds its own obs code, via the new
rtklib_obs_code() helper shared with insert_obs_to_rtklib(), so
B1I next to B1C and excluded E5/E6 signals are not reported as used.
Move prange_band_pair() to rtklib_pntpos and document the per-signal
semantics in monitor_pvt.proto.
Resolve the CHANGELOG conflict, and fix the EVK1029 shared-memory input
on top of the merge:
- In shared-memory mode, Evk1029SignalSource is real-time and cannot
wait, so the deterministic mode refuses it and the Signal Conditioner
no longer plans it as an unthrottled replay. Read
shm_stop_on_buffer_overflow only on Linux, avoiding an unused variable
warning elsewhere.
- Stopping the receiver no longer hangs when EVK1029_CtrlApp is idle,
has crashed or has been restarted. ReadBlock() waits at most 100 ms at
a time, RawStreamReader::read() then returns to its caller (see
end_of_stream()), and Evk1029Source releases a decode worker waiting
for data when GNU Radio stops the flowgraph. The stream ends if the
producer publishes nothing for SignalSource.shm_stall_timeout_s
seconds (default 5, 0 waits forever).
- request_stop() bumps data_event before waking the reader, and
ReadBlock() takes its snapshot of data_event before checking the stop
flag, the ring and the stream state, so that no wake-up is lost.
- Count overflows and producer silence from the first sample read, not
from the attach: nothing reads the ring while the flowgraph is built,
so shm_stop_on_buffer_overflow=true stopped the receiver at startup.
Update the CHANGELOG entry with the actual parameter names and the new
shm_stall_timeout_s parameter.
Extend the change of the previous merge to the remaining tracking
blocks: kf_tracking and gps_l1_ca_gaussian_tracking_cc (binary dump and
.mat file; records grow from 96 to 100 bytes), and the GPS L1 C/A and
Galileo E1 TCP connector and GPS L1 C/A GPU blocks (records grow from 88
to 92 bytes). The Galileo E1 TCP connector block accumulated the carrier
phase in a float, which is now a double.
Update the KF readers in utils/matlab and utils/python accordingly.
Tracking_Dump_Reader now takes the record layout, since the FPGA and
Gaussian tests read dumps that lack the TOW and WN fields (and, for the
Gaussian block, have the carrier noise variance in place of the code
frequency rate) with the dll_pll_veml_tracking layout.
Add a CHANGELOG entry.
Resolve the conflicts with the deterministic processing mode: keep the
deterministic loss-of-lock dispatch together with the "forced" suffix in
the loss-of-lock log line, and convert the two deterministic telemetry
fault paths in dll_pll_veml_tracking and kf_tracking, which still forced
the loss of lock by writing 200000 into the carrier lock fail counter,
to d_force_loss_of_lock.
Remove the conflict markers left in docs/CHANGELOG.md by the merge of
the deterministic branch, and add a CHANGELOG entry for this fix.
Add a deterministic processing mode for recorded signals
Processing the same file twice was not repeatable, even with
Acquisition_XX.blocking=true: the control thread started searches,
assigned satellites and applied channel events at whatever sample
each block had reached, and the PVT and observables applied each
other's messages whenever they arrived.
With GNSS-SDR.deterministic=true (default: false), events and
messages carry the sample at which they happened, the control
thread handles channel events in sample order, and their effects
take place a fixed lookahead later (deterministic_lookahead_ms,
default 100 ms). A gate at the Signal Conditioner output keeps the
stream within that horizon, blocks take their stamped messages at
the start of each work call, maintenance runs on signal time
(deterministic_tick_ms), and the receiver stops once the whole
input has reached the PVT. Dumps, RINEX, NMEA, KML, GPX and GeoJSON
outputs are then bit-identical from run to run on the same machine
(same FFTW wisdom and VOLK configuration), whatever the CPU load.
Supported: all file sources (throttled or not, including LabSat,
EVK1029 and ION), all acquisitions except assisted and FPGA, and
the DLL/PLL VEML, KF and Gaussian trackers. Live front ends, HAS
and NTRIP corrections, strict OSNMA, Galileo E6 with the TOW map,
GNSS assistance and visibility-aware search are refused.
carlesfernandez's review of this PR (gnss-sdr/gnss-sdr#1154) raised several
issues. This addresses all but the DCO/signing requirement (handled
separately via rebase) and the GPL licensing question on shm_ring.h (his
call, not mine to answer in code):
- Build: shared_memory_stream_reader.cc/shm_ring.h are now gated to Linux
only (CMAKE_SYSTEM_NAME), matching the EVK1029_SHM_INPUT compile
definition the adapter checks before including/constructing
SharedMemoryStreamReader; an unavailable shared_memory input now throws
std::invalid_argument instead of failing to build.
- librt is linked on glibc < 2.34, same as core_receiver already does for
its own shm_open use.
- ReadBlock() now treats StreamState::Error as terminal (it previously
blocked forever), and rejects a length prefix larger than the block can
hold instead of reading past it (reproduced his reported 64 MiB ASan
overread).
- An unrecognized SignalSource.input value now throws instead of silently
falling back to file mode; enable_throttle_control is ignored with a
warning in shared_memory mode.
- Dangling references to the (not-in-repo) spec doc removed; diagnostics
moved from std::cout to LOG(INFO)/LOG(WARNING); added the missing
gnss_sdr_make_unique.h include; fixed the clang-tidy violations he listed
(brace-less ifs, long -> int64_t).
Backpressure and loss detection redesigned per further discussion: the SHM
ring's WriteBlock() blocks (not drops) a full ring, so a stalled GNSS-SDR
consumer backs up through EVK1029_CtrlApp's own buffering instead of ever
reaching the USB/target side -- the target must never see an overflow
condition from this path. Real, unrecoverable loss is instead detected on
EVK1029_CtrlApp's side via the existing IF_TO_AXIS hardware overflow flag
(now also polled during SHM streaming, not just recording) and surfaced
through the ring's Header as overflow_event_count (protocol bumped to v3).
It's a count of occurrences, not bytes -- the hardware only latches a
sticky bit -- so SharedMemoryStreamReader can't zero-fill a known gap; it
either stops the stream (new SignalSource.shm_stop_on_buffer_overflow,
default false) or logs and continues, leaving the sample count to jump in
place.
Also fixes request_stop() not waking a blocked read(): setting the stop
flag alone doesn't wake a ReadBlock() already asleep in FUTEX_WAIT on
data_event, so Evk1029Source's join() of the decode-ahead thread could hang
on shutdown with an idle producer -- the same class of bug his review
caught elsewhere, found while re-checking this change for others like it.
Verified with standalone tests (plain and under AddressSanitizer), not
just a clean build: round-trip, terminal Error, corrupted-length
rejection, WriteBlock's blocking-plus-abortFlag-wake behavior, overflow
detection (both log-and-continue and stop-on-overflow), and request_stop()
unblocking a waiting read(). Full gnss-sdr build (including install/)
clean throughout.
Signed-off-by: joebre <joel.brenner@saphyrion.ch>
The Monitor is fed from the Observables, which since ed5a75e31 fill
channels without a valid time reference with their latest tracking
data. That never worked in Galileo E6-only configurations: the GPS L1
C/A, GPS L5, Galileo, BeiDou D1/D2 and BeiDou B1C telemetry decoders
produced no output until they decoded the time of week, so the
Observables never received E6 tracking data. The GLONASS, GPS L2C,
BeiDou B2a and SBAS decoders already forwarded every symbol with
Flag_valid_word unset; now all telemetry decoders do. Dumps,
telemetry_to_trk and nav-data monitor messages are still issued only
with a valid time of week.
The tracking-only entries also had fs set to 0, which gnss-sdr-monitor
takes as an empty channel, hiding SBAS channels. fs is now kept, with
the validity flags still unset; the PVT only uses observations with
Flag_valid_pseudorange.
As a side effect, the secondary-band acquisition assistance can use a
primary-band channel as soon as its tracking locks, instead of after
its time of week is decoded. The Galileo F/NAV test sink now records
the first item with a valid word.
Alternative to PR #1122, without new options or changes to tracking
and to the PVT time-of-week reset handling. Related to #1018.
A one-code-period PCPS window starts at an arbitrary code phase, so a
secondary-code or data sign transition at the code epoch inside it
splits the correlation peak up to +-0.74/T away from the true Doppler.
For GPS L5 (the I5 NH10 code changes sign at 6 of every 10 epochs),
about 40 % of the acquisitions started tracking 250-900 Hz off. The
1 ms Costas loop then either held a false lock at exactly +-500 Hz
(lock test 0.97, C/N0 3.9 dB low, secondary-code sync impossible)
until bit_synchronization_time_limit_s, or never locked and lost lock
a few seconds after pull-in.
After a positive decision, refine_doppler() despreads the dwells with
the replica aligned to the detected code epoch, scores the two sides
of the epoch under both sign hypotheses (summed non-coherently over
dwells), and re-estimates the Doppler over +-1/T around the grid peak.
It only runs on positive acquisitions, so its cost is negligible, also
with the CUDA grid. It applies to every pcps_acquisition search over
one code period without bit_transition_flag. The new
Acquisition_XX.refine_doppler parameter (default true) disables it.
With -DENABLE_CUDA=ON, band<n>_cuda=true computes that band's
frequency-translating FIR (complex composite taps applied to the real
capture) on an NVIDIA GPU through the new CudaDdcEngine, instead of on
a CPU worker thread. As with the CUDA acquisition engine, the public
interface has no CUDA types and hides the implementation behind a
PIMPL. Each band falls back to the CPU, with a warning in the log, if
its engine cannot be created or a GPU call fails. Builds without CUDA,
and bands without the flag, are unchanged.
Taken from PR #1144, plus:
- Report the CUDA status per band with LOG instead of std::cout/cerr
- Check cudaGetLastError() after the kernel launch, so a failed launch
is not mistaken for valid output
- Select the engine's device in set_taps(), compute() and the
destructor, since compute() runs on the band worker threads
- Build the engine only with both ENABLE_CUDA and ENABLE_EVK1029
With enable_freq_xlating=true, Evk1029Source translates, filters and
decimates each band itself and exposes one gr_complex output port per
band, so Bypass Signal Conditioners can connect the channels straight
to the source. Each band's FIR runs on its own worker thread, and the
next chunk of the capture is decoded while the current one is filtered.
Per-band filter design: band<n>_IF, _decimation_factor, _bw, _tw,
_window, _attenuation_dB and _kaiser_beta.
Taken from PR #1143 without its SignalConditioner Bypass commits (next
already provides Bypass), plus:
- Center shorter band filters on the longest one, so every band has the
same group delay (mismatched tap counts biased pseudoranges between
bands by up to km)
- Fix source dump in fused mode: one gr_complex file per band (_ch<n>)
- Reject unequal or non-positive band decimation factors
- Build with GNU Radio < 3.9 (firdes window type) and VOLK < 2.5
(rotator), use volk_gnsssdr::vector
- Link Gnuradio::filter privately and only with ENABLE_EVK1029
- Start worker threads after the capture file is opened
Select batch targets from sample rate, latency and memory limits, and
consumer buffer requirements. Replace eligible pass-through stages before
channel fan-out without machine-specific profiles or configuration edits.
Preserve samples and tags across partial batches, deadlines, and EOF.
Handle conditioned output ports consistently and clean up stream and
message connections on disconnect or connection failure.
GPS L5 is pre-operational, and the L5 health bit of CNAV message type 10 (IS-GPS-200N 30.3.3.1.1.2) is broadcast as "unhealthy" on every SV. As a result, every GPS L5 signal was reported with healthy = false in the monitor_pvt tracked_satellites list, and "not used for navigation" was printed for every GPS satellite. Neither affected the PVT solution: CNAV L2C/L5/J5 observables are not gated on these bits (the L5 exclusion was dropped in v0.0.17), and the CNAV ephemeris handed to RTKLIB carries no svh. GPS L5 now reports the LNAV SV health of the same satellite; GPS L2C and QZSS L5 keep the CNAV bits; and the console message is replaced by a LOG(INFO) line.
- CHANGELOG: document Tracking_<Sig>.f_error_dump (default: false) and the
new Octave/MATLAB scripts
- f_error_sim.m: match cn0_m2m4_estimator when sqrt argument is negative,
seed with rng() (fallback for Octave < 7), fix stale comments
- plot_all_f_error_scans.m: do not require gnuplot, restore the previous
graphics toolkit on exit
- Use fprintf instead of printf for MATLAB compatibility