Skip to content

Pending latest changes from Widehopf: Dev - #5

Open
alex-tsbk wants to merge 483 commits into
ADSBexchange:devfrom
wiedehopf:dev
Open

Pending latest changes from Widehopf: Dev#5
alex-tsbk wants to merge 483 commits into
ADSBexchange:devfrom
wiedehopf:dev

Conversation

@alex-tsbk

Copy link
Copy Markdown

No description provided.

@wiedehopf
wiedehopf force-pushed the dev branch 7 times, most recently from 5b827ae to e7d8c49 Compare August 18, 2024 16:07
@wiedehopf
wiedehopf force-pushed the dev branch 2 times, most recently from 30bc0c1 to 6e2434f Compare November 1, 2024 11:46
@wiedehopf
wiedehopf force-pushed the dev branch 2 times, most recently from 8c82ea5 to ae987a9 Compare January 4, 2025 18:09
wiedehopf added 18 commits May 1, 2025 11:30
really no reason to write half finished stuff

also try and nicely spread out the IO a bit for aircraft that have been
inactive for a long time
aircraft objects are somewhat small, roughly 2.5 kB and some are very
long lived
use our own allocator that doesn't really free them but just keeps a
freelist
use backing storage from mmap in sizes of 2 MB which should usually be
transparent hugepages which should reduce TLB contention

due to those hugepages eating up 2 MB of memory even for few aircraft
only use the custom allocator in situations where that is not an issue
at least on x86, pthread_mutex is better or the same
wiedehopf and others added 13 commits May 4, 2026 20:09
TCP json position output: instead of emitting when a new position
is calculated, only emit when the wind was calculated now
(based on data from the last 2.5)

see also: HelenaValleyObservatory/helena-valley-observatory#1

this is a minimal hacky thing so i don't need to touch too much code
but should be fit for purpose
Adds signal level (dBFS) as an optional 23rd field in SBS/BaseStation
output. Only emitted when invoked with --devel=sbs_rssi; off by default so
existing consumers are unaffected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Two hardening fixes for the --devel=sbs_rssi extension:

1. Increase prepareWrite allocation from 200 to 250 bytes when sbs_rssi
   is enabled. The original 200-byte buffer was sized before field 23
   was added; RSSI appends up to ~7 bytes (e.g. ",-48.1") and the
   extra headroom prevents any possibility of overflow on a maximally
   populated SBS line.

2. Add fmax(signalLevel, 1e-10) clamp before log10(). signalLevel is
   bounded [0,1] by unsigned char arithmetic and the > 0 guard already
   prevents log10(0), but the explicit clamp documents the invariant and
   protects against subnormal edge cases if the source path ever changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(*(p+1) << 8) | *(p+2) — if char is signed on the target platform,
bytes with value > 127 sign-extend to negative int before shifting,
corrupting the uint16_t msgLen. Cast both bytes to uint8_t first to
prevent sign extension regardless of platform char signedness.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…S output

Adds a new devel flag, sbs_extra_fields, which appends two optional fields
to the SBS output:
  - Field 23: RSSI in dBFS (e.g. -27.3), empty if signal level unavailable
  - Field 24: aircraft category from ADS-B identification frames (metype 1-4),
    encoded as two hex chars (e.g. A3 = large fixed-wing, A7 = rotorcraft),
    empty if not yet received

The category is derived directly from the received ADS-B DF17 message
(((0x0E - metype) << 4) | mesub) — no external database lookup required.

Both fields are controlled by a single flag to keep the extension self-
contained. Field 23 is always emitted when the flag is active so that
field 24 remains at a fixed position, regardless of whether RSSI data is
available for a given message.

Buffer size is increased from 200 to 260 bytes when the flag is active.
awhite-jetnet added a commit that referenced this pull request Jun 24, 2026
Use-case-defining tests #4 and #5:
- receiver.json: pins capability fields (version/refresh/history, binCraft/zstd/
  json_trace_interval, globeIndexGrid/SpecialTiles). haveTraces is absent in
  3.14.1631, so intentionally not asserted.
- aircraft.json: pins top-level shape + the per-aircraft object field/type
  contract parsed by tar1090/leaderboard/exporters (entries are objects, not
  arrays). Suite now 110.
wiedehopf and others added 9 commits July 27, 2026 14:22
readsb.h: the 'huge' parameter of mmap_or_exit() is only used inside the
#ifdef MADV_HUGEPAGE branch, so on platforms without MADV_HUGEPAGE (macOS,
*BSD) it triggers -Werror,-Wunused-parameter. Mark it unused in the #else.

readsb.c: 'case OptUuidFile:' is immediately followed by a declaration.
A label followed by a declaration is only valid from C23 on, so clang
rejects it under -std=c11 with -Werror,-Wc23-extensions. Wrap the case
body in a block.
C11 7.17.7.4 requires the second argument of atomic_compare_exchange_weak()
to be a pointer to the *non-atomic* type C, i.e. int*, not atomic_int*.
GCC accepts this because its __atomic builtins are not type checked, but
clang rejects it:

    util.c:1186:50: error: incompatible pointer types passing
    'atomic_int *' to parameter of type 'int *'

Declare 'expected' as a plain int.
'int res = 0;' sits after all the 'goto err' / 'goto out' statements and
directly above the err: label, which has two consequences:

- the normal path falls through into 'err:' and returns -1 even when the
  aircraft was loaded successfully;
- 'goto out' at the !Modes.keep_traces branch jumps over the initializer,
  leaving res uninitialized. clang rejects this with
  -Werror,-Wsometimes-uninitialized.

Declare and initialize res at the top of the function and jump to out: on
the success path. Both call sites currently ignore the return value, so
this only makes the function match its intent.
'echo -n' is not portable: on macOS /bin/sh it prints the "-n" literally,
so the binary reports

    readsb version: -n 3.16.15 -n  wiedehopf git: ...

Use printf '%s', which behaves the same everywhere.
…iable

0d9c323 ("make SDR transfer size a variable") dropped MODES_MAG_BUF_SAMPLES
in favour of the runtime Modes.sdr_buf_samples, but did not update
oneoff/convert_benchmark.c, which has failed to compile ever since:

    oneoff/convert_benchmark.c:70:22: error: use of undeclared identifier
    'MODES_MAG_BUF_SAMPLES'

The benchmark never touches an SDR, so define the constant locally, using
the default readsb starts up with (sdr_buf_size 128 kiB, two bytes per
sample). The old value was 256 kiB / 2; using today's default seemed more
useful than preserving the historic one, happy to change it.

The benchmark also needs definitions for Modes and setExit(), which util.o
references and which live in readsb.c. readsb.o can't be linked in here as
it brings its own main(), so provide them locally.
The Apple branch of compat.h defines le16toh/le32toh but not the reverse
direction, so anything using htole16() fails to build on macOS. Currently
that is only oneoff/convert_benchmark.c.
Three things kept 'make benchmarks' from working:

- it ran ./convert_benchmark while the binary is built as
  oneoff/convert_benchmark, so the target failed even once the object
  compiled;
- the link rule still listed only convert.o and util.o with -lm. util.o has
  since grown dependencies on threadpool.o, zlib and zstd, so the link fails
  with a page of undefined symbols. Use $(LDFLAGS) $(LIBS) and add
  threadpool.o plus $(COMPAT);
- 'make clean' removed ./convert_benchmark and left oneoff/*.o and the real
  binary behind.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants