Listen the way the tools that work on this band listen
Still nothing, with rtl-433 receiving the same sensors on the same aerial from a different receiver. That settles where the fault is not: not the aerial, not the sensors, not the band. So the sensible thing is to stop differing from the configuration known to work on that aerial, and this differed from it in three ways, every one of them mine. It tuned a quarter of a megahertz to one side of 433.92 and shifted the signal back in software, to keep the receiver's own spike off a signal that works by being switched off. That is a real effect and avoiding it this way is a bad trade: at the sample rate this ran at, the shift is followed by a filter, and a filter narrow enough to reject the spike is narrow enough to lose a transmitter that has drifted -- or to lose the signal outright if a dongle presents its samples the other way round, which is not a thing to depend on. The spike is a steady addition to the envelope and a burst rises clear of it. Tuning straight at the sensors now, which is what the established tools do. It sampled at a megasample a second where a quarter of one is plenty: the shortest pulse these send is two hundred microseconds, which is fifty samples at the lowest rate a dongle will do. The extra rate bought nothing but the room for that filter to exist in. At 250 kS/s nothing after the mixer is narrower than the band, so the offset now does nothing at all whatever it is set to, and says so. And it turned on the RTL2832's digital gain control along with the tuner's. The two pump: the gain winds up through the silence between one burst and the next, lifting the noise towards the signal and squeezing the very difference the burst detector works on. It matters here in a way it does not for aircraft, where a frame is found by correlating a preamble over microseconds rather than by comparing a burst with the quiet around it. Three more faults found while going over the rest of it, all the same mistake in different clothes -- treating the middle of a distribution as though it were the quiet part of one. The check that skips an empty block measured the peak against the median. A recording that is mostly burst measures its own burst against its own burst, finds no difference and is discarded as silence, which is what happened to every short capture. The gate's scatter had the same trouble one level down and could come out above the peak, which is the one setting that cannot be right, so it is now capped below it. And the rule deciding where one message ends keyed on the middle gap in a burst. Where a one is drawn as a gap three times a zero and most of the bits are zeroes, the middle gap is the short one, twice it still falls inside the message, and every one-bit ended a burst -- the message coming apart into pieces of three pulses. It keys on the widest gap now, which is a fact about the message rather than about the data it happened to carry. The pieces of a message are also put back together after being sliced rather than before. Grouping has to be tight, because the group is what fixes the threshold and a group holding two sensors of unequal strength fixes it on the louder; but the gaps inside one message run from two hundred microseconds on the newer sensors to four thousand on the oldest, and a grouping tight enough for the first tears the second into a bit at a time. So each piece is measured at its own amplitude and joined to its neighbours afterwards, and anything that comes out longer than the longest message there is gets cut at its largest gaps. Measured rather than argued: across four hundred and eighty combinations of pulse and gap timing, 464 now read where 417 did; across twenty-one gap-keyed combinations, 18 where 12 did; and eighty seconds of receiver noise still yields nothing at all. --from-iq FILE reads a saved capture instead of the receiver, so a recording made where the aerial is can be worked on anywhere, as many times as it takes. Everything downstream of the dongle is the real thing, which is what tells a receiver problem and a decoder problem apart. --save-iq writes the settings beside the samples, a file of raw samples with no record of its rate being unreadable by anything. The invented garden now waits like a dongle instead of running as fast as the machine allows, which it should have done from the start: --seconds meant nothing against it and a capture came out fifty times too large. Full suite 2331 passed; this work checked against sixteen deliberately broken builds, two of which it survived until the tests were made to catch them, and one change was removed for being unable to earn a test at all. Built as 2026-09-07_03. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016PsWPTweCT6pwxKngvVxcg
This commit is contained in:
parent
335d83f8a0
commit
706c632f47
10 changed files with 978 additions and 92 deletions
|
|
@ -742,3 +742,202 @@ def test_the_pulse_lengths_of_a_burst_are_reported_as_the_protocol_shape():
|
|||
def test_a_burst_of_one_length_is_reported_as_one_length():
|
||||
assert a.timings([400.0] * 12) == [(400.0, 12)]
|
||||
assert len(a.timings([200.0] * 6 + [400.0] * 6)) == 2
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Timings other than the ones this was written against
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def keyed_at(bits, marks_gaps, copies=3, reset_us=8_000.0, amplitude=1.0,
|
||||
rate=250_000.0, lead_us=3_000.0):
|
||||
"""A sensor keyed with whatever timings, one (mark, gap) pair per bit."""
|
||||
per_us = rate / 1e6
|
||||
parts = [np.zeros(int(lead_us * per_us), dtype=np.float32)]
|
||||
|
||||
def push(mark, gap):
|
||||
parts.append(np.full(int(round(mark * per_us)), amplitude,
|
||||
dtype=np.float32))
|
||||
if gap:
|
||||
parts.append(np.zeros(int(round(gap * per_us)), dtype=np.float32))
|
||||
|
||||
for _ in range(copies):
|
||||
for mark, gap in marks_gaps:
|
||||
push(mark, gap)
|
||||
push(500.0, reset_us)
|
||||
return a._to_air(np.concatenate(parts), rate, 0.0, 0.02, 0)
|
||||
|
||||
|
||||
def pwm_pairs(bits, one=408.0, zero=220.0, gap=None, syncs=4,
|
||||
sync_mark=600.0, sync_gap=600.0):
|
||||
"""Pulse-width keying: the bit is the pulse. ``gap=None`` completes the
|
||||
bit period, which is one of the two conventions; a number is a spacer,
|
||||
which is the other."""
|
||||
out = [(sync_mark, sync_gap)] * syncs
|
||||
for bit in bits:
|
||||
mark = one if bit == "1" else zero
|
||||
out.append((mark, (one + zero) - mark if gap is None else gap))
|
||||
return out
|
||||
|
||||
|
||||
def ppm_pairs(bits, mark=500.0, short=1_000.0, long=2_000.0):
|
||||
"""Pulse-position keying: the bit is the gap."""
|
||||
return [(mark, long if bit == "1" else short) for bit in bits]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name,pairs,reset", [
|
||||
# The two pulse-width conventions, at the published widths.
|
||||
("pwm, gap completes the bit", pwm_pairs, 8_000.0),
|
||||
# ...and with the pulses stretched and squeezed, because these
|
||||
# transmitters are unlocked and drift with the temperature.
|
||||
("pwm 20% slow", lambda b: [(m * 1.2, g * 1.2)
|
||||
for m, g in pwm_pairs(b)], 9_600.0),
|
||||
("pwm 15% fast", lambda b: [(m * 0.85, g * 0.85)
|
||||
for m, g in pwm_pairs(b)], 6_800.0),
|
||||
# A fixed spacer rather than a complement, at three widths.
|
||||
("pwm, 200 us spacer", lambda b: pwm_pairs(b, gap=200.0), 8_000.0),
|
||||
("pwm, 400 us spacer", lambda b: pwm_pairs(b, gap=400.0), 8_000.0),
|
||||
("pwm, 600 us spacer", lambda b: pwm_pairs(b, gap=600.0), 8_000.0),
|
||||
# Different numbers of sync pulses, since nothing here counts them.
|
||||
("pwm, no sync", lambda b: pwm_pairs(b, syncs=0), 8_000.0),
|
||||
("pwm, 8 sync pulses", lambda b: pwm_pairs(b, syncs=8), 8_000.0),
|
||||
# And the short pulse meaning one.
|
||||
("pwm inverted", lambda b: pwm_pairs(b, one=220.0, zero=408.0,
|
||||
gap=200.0), 8_000.0),
|
||||
])
|
||||
def test_a_tower_sensor_is_read_at_timings_other_than_the_expected_ones(
|
||||
name, pairs, reset):
|
||||
bits = a.tower_frame(0x1A2B, 21.5, 48, "A")
|
||||
build = pairs if callable(pairs) else (lambda b: pairs)
|
||||
iq = keyed_at(bits, build(bits), reset_us=reset)
|
||||
got = a.readings_from(iq, 250_000.0)
|
||||
assert [r.sensor for r in got] == ["1A2B"], f"{name}: heard {got}"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name,short,long,reset", [
|
||||
# The 609TXC's published gaps.
|
||||
("609 gaps", 1_000.0, 2_000.0, 10_000.0),
|
||||
# The 606TX's, which are twice as wide -- wider than any grouping tight
|
||||
# enough to keep two sensors apart, which is why the pieces of a message
|
||||
# are put back together after being sliced rather than before.
|
||||
("606 gaps", 2_000.0, 4_000.0, 8_000.0),
|
||||
("half again as wide", 3_000.0, 6_000.0, 14_000.0),
|
||||
])
|
||||
def test_a_gap_keyed_sensor_is_read_however_wide_its_gaps_are(name, short,
|
||||
long, reset):
|
||||
bits = a.frame_609(0x5C, 4.2, 80)
|
||||
iq = keyed_at(bits, ppm_pairs(bits, short=short, long=long),
|
||||
reset_us=reset)
|
||||
got = a.readings_from(iq, 250_000.0)
|
||||
assert [r.sensor for r in got] == ["5C"], f"{name}: heard {got}"
|
||||
|
||||
|
||||
def test_three_copies_run_together_are_still_three_copies():
|
||||
"""A burst too long to be one message is cut at its largest gaps.
|
||||
|
||||
The gaps inside a 606 message and the wait between its copies are only a
|
||||
factor of two apart, which is too close to tell from a ratio -- so the
|
||||
joining is allowed to be greedy and the result is divided by counting
|
||||
instead.
|
||||
"""
|
||||
bits = a.frame_606(0x93, -3.5)
|
||||
iq = keyed_at(bits, ppm_pairs(bits, short=2_000.0, long=4_000.0),
|
||||
reset_us=8_000.0)
|
||||
envelope, rate = a.baseband(iq, 250_000.0, 0.0)
|
||||
found = a.bursts(envelope, rate)
|
||||
assert len(found) == 3, [b.pulses for b in found]
|
||||
assert all(b.pulses <= a.MAX_PULSES for b in found)
|
||||
assert [r.sensor for r in a.readings_from(iq, 250_000.0)] == ["93"]
|
||||
|
||||
|
||||
def test_a_burst_no_longer_than_a_message_is_left_whole():
|
||||
burst = a.Burst(marks=(400.0,) * 40, spaces=(220.0,) * 39)
|
||||
assert a._divide([burst]) == [burst]
|
||||
|
||||
|
||||
def test_a_capture_that_is_mostly_burst_is_not_thrown_away_as_empty():
|
||||
"""The noise is read off the bottom of a block, never off the middle.
|
||||
|
||||
Taken from the median, a block that is largely signal measures its own
|
||||
burst against its own burst, finds no difference, and is discarded as
|
||||
silence. Which is what happened to any short capture: the shorter it
|
||||
was, the larger the share of it that was the thing being looked for.
|
||||
"""
|
||||
bits = a.tower_frame(0x1A2B, 21.5, 48, "A")
|
||||
# Short gaps, so the carrier is on for most of the recording: this is a
|
||||
# real timing, and it is the one that showed the fault.
|
||||
iq = keyed_at(bits, pwm_pairs(bits, gap=150.0), copies=1,
|
||||
reset_us=1_000.0, lead_us=500.0)
|
||||
envelope, rate = a.baseband(iq, 250_000.0, 0.0)
|
||||
smooth = a._smoothed(envelope, rate)
|
||||
# More than half of it is the sensor talking, which is what puts the
|
||||
# median inside the signal and the block in danger of being discarded.
|
||||
assert (smooth > smooth.max() / 2).mean() > 0.5
|
||||
assert np.median(smooth) * 1.8 > np.percentile(smooth, 99.99)
|
||||
assert [r.sensor for r in a.readings_from(iq, 250_000.0)] == ["1A2B"]
|
||||
|
||||
|
||||
def test_a_bit_drawn_as_a_much_longer_gap_does_not_end_the_burst():
|
||||
"""Where a one is three times a zero and most bits are zeroes, the middle
|
||||
gap is the short one -- so a rule keyed on the middle of the gaps cuts
|
||||
the message at every one-bit and hands back pieces of three pulses."""
|
||||
bits = a.frame_609(0x5C, 4.2, 80)
|
||||
iq = keyed_at(bits, ppm_pairs(bits, short=800.0, long=2_400.0),
|
||||
reset_us=10_000.0)
|
||||
envelope, rate = a.baseband(iq, 250_000.0, 0.0)
|
||||
found = a.bursts(envelope, rate)
|
||||
assert found and max(b.pulses for b in found) >= 40
|
||||
assert [r.sensor for r in a.readings_from(iq, 250_000.0)] == ["5C"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("one,zero,gap", [
|
||||
(408.0, 220.0, None), (408.0, 220.0, 200.0), (500.0, 250.0, 250.0),
|
||||
(300.0, 150.0, 150.0), (600.0, 300.0, 300.0), (400.0, 200.0, 400.0),
|
||||
])
|
||||
def test_the_envelope_of_pulse_widths_it_will_read(one, zero, gap):
|
||||
bits = a.tower_frame(0x1A2B, 21.5, 48, "A")
|
||||
iq = keyed_at(bits, pwm_pairs(bits, one=one, zero=zero, gap=gap))
|
||||
assert [r.sensor for r in a.readings_from(iq, 250_000.0)] == ["1A2B"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("duty", [0.05, 0.3, 0.5, 0.62, 0.75, 0.85])
|
||||
def test_the_gate_sits_between_the_quiet_and_the_loudest_at_any_duty(duty):
|
||||
"""Two ways to get this wrong, and both report a silence that was not.
|
||||
|
||||
The scatter it is built from has to be measured inside the quiet part.
|
||||
Measured across the edge between off and on -- which is where a
|
||||
percentile lands once the carrier is on for much of the block -- it
|
||||
measures the signal, and six times the signal is a gate above everything
|
||||
in the block.
|
||||
|
||||
And whatever the arithmetic comes to, a gate above the loudest thing
|
||||
there is cannot be right: it is the one setting that guarantees nothing
|
||||
is found on a second that plainly had something in it.
|
||||
"""
|
||||
rng = np.random.default_rng(4)
|
||||
n = 60_000
|
||||
envelope = np.abs(rng.standard_normal(n)
|
||||
+ 1j * rng.standard_normal(n)).astype(np.float32) * 0.02
|
||||
# The carrier keyed on for `duty` of the block, in pulses rather than
|
||||
# one lump, which is what a message looks like.
|
||||
period = 400
|
||||
for start in range(0, n - period, period):
|
||||
envelope[start:start + int(period * duty)] += 1.0
|
||||
smooth = a._smoothed(envelope, 250_000.0)
|
||||
quiet = float(np.percentile(smooth, 20))
|
||||
peak = float(np.percentile(smooth, 99.99))
|
||||
gate = a._noise_gate(smooth, quiet, peak)
|
||||
assert gate < peak, f"duty {duty}: gate {gate:.3f} is above the peak {peak:.3f}"
|
||||
assert gate > quiet, f"duty {duty}: gate {gate:.3f} is at or below the noise"
|
||||
|
||||
|
||||
def test_the_gate_still_keeps_noise_out_when_there_is_no_signal():
|
||||
"""The other half of it: a quiet band must find nothing at all."""
|
||||
rng = np.random.default_rng(11)
|
||||
for _ in range(8):
|
||||
noise = np.abs(rng.standard_normal(60_000)
|
||||
+ 1j * rng.standard_normal(60_000)).astype(np.float32)
|
||||
smooth = a._smoothed(noise, 250_000.0)
|
||||
quiet = float(np.percentile(smooth, 20))
|
||||
peak = float(np.percentile(smooth, 99.99))
|
||||
over = (smooth > a._noise_gate(smooth, quiet, peak)).mean()
|
||||
assert over < 0.01, f"{over:.1%} of pure noise cleared the gate"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue