ka9q-python 3.26.1__tar.gz → 3.27.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/CHANGELOG.md +50 -0
  2. {ka9q_python-3.26.1/ka9q_python.egg-info → ka9q_python-3.27.0}/PKG-INFO +6 -1
  3. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/README.md +5 -0
  4. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/API_REFERENCE.md +5 -3
  5. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/advanced_features_demo.py +4 -4
  6. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/cli.py +0 -2
  7. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/compat.py +1 -1
  8. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/control.py +92 -19
  9. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/status.py +25 -6
  10. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/stream.py +6 -5
  11. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/tui.py +0 -2
  12. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/types.py +11 -3
  13. {ka9q_python-3.26.1 → ka9q_python-3.27.0/ka9q_python.egg-info}/PKG-INFO +6 -1
  14. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_python.egg-info/SOURCES.txt +1 -0
  15. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_radio_compat +1 -1
  16. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/pyproject.toml +1 -1
  17. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/scripts/sync_types.py +34 -0
  18. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_ensure_channel_encoding.py +63 -0
  19. ka9q_python-3.27.0/tests/test_sweep.py +152 -0
  20. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/LICENSE +0 -0
  21. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/MANIFEST.in +0 -0
  22. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/ARCHITECTURE.md +0 -0
  23. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/CLI_GUIDE.md +0 -0
  24. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/GETTING_STARTED.md +0 -0
  25. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/INSTALLATION.md +0 -0
  26. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/MULTI_STREAM.md +0 -0
  27. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/POLL-SUPPRESSION-DESIGN.md +0 -0
  28. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/RECIPES.md +0 -0
  29. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/REQUIREMENTS.md +0 -0
  30. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/RTP_TIMING_SUPPORT.md +0 -0
  31. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/SECURITY.md +0 -0
  32. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/TESTING_GUIDE.md +0 -0
  33. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/TUI_GUIDE.md +0 -0
  34. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/README.md +0 -0
  35. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/clients.md +0 -0
  36. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/contract.md +0 -0
  37. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/control-surface.md +0 -0
  38. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/findings.md +0 -0
  39. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/idempotency.md +0 -0
  40. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/audit/2026-08-12-alignment/upstream.md +0 -0
  41. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/superpowers/plans/2026-08-12-upstream-alignment-and-client-compat.md +0 -0
  42. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/superpowers/plans/2026-08-13-audit-remediation.md +0 -0
  43. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/superpowers/plans/2026-08-13-client-side-fixes.md +0 -0
  44. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/docs/superpowers/specs/2026-08-12-upstream-alignment-and-client-compat-design.md +0 -0
  45. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/channel_cleanup_example.py +0 -0
  46. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/codar_oceanography.py +0 -0
  47. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/diagnostics/diagnose_packets.py +0 -0
  48. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/diagnostics/repro_utc_bug.py +0 -0
  49. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/discover_example.py +0 -0
  50. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/grape_integration_example.py +0 -0
  51. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/hf_band_scanner.py +0 -0
  52. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/multi_stream_smoke.py +0 -0
  53. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/rtp_recorder_example.py +0 -0
  54. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/simple_am_radio.py +0 -0
  55. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/spectrum_example.py +0 -0
  56. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/stream_example.py +0 -0
  57. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/superdarn_recorder.py +0 -0
  58. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/test_channel_operations.py +0 -0
  59. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/test_improvements.py +0 -0
  60. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/test_timing_fields.py +0 -0
  61. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/tune.py +0 -0
  62. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/examples/tune_example.py +0 -0
  63. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/__init__.py +0 -0
  64. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/_multicast.py +0 -0
  65. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/addressing.py +0 -0
  66. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/discovery.py +0 -0
  67. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/exceptions.py +0 -0
  68. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/managed_stream.py +0 -0
  69. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/monitor.py +0 -0
  70. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/multi_stream.py +0 -0
  71. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/pps_calibrator.py +0 -0
  72. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/recovery_ladder.py +0 -0
  73. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/resequencer.py +0 -0
  74. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/rtp_recorder.py +0 -0
  75. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/slot_clock.py +0 -0
  76. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/spectrum_stream.py +0 -0
  77. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/status_listener.py +0 -0
  78. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/stream_quality.py +0 -0
  79. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q/utils.py +0 -0
  80. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_python.egg-info/dependency_links.txt +0 -0
  81. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_python.egg-info/entry_points.txt +0 -0
  82. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_python.egg-info/requires.txt +0 -0
  83. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/ka9q_python.egg-info/top_level.txt +0 -0
  84. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/scripts/check_upstream_drift.py +0 -0
  85. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/scripts/gen_client_manifest.py +0 -0
  86. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/setup.cfg +0 -0
  87. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/__init__.py +0 -0
  88. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/conftest.py +0 -0
  89. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_addressing.py +0 -0
  90. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_channel_verification.py +0 -0
  91. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_client_contract.py +0 -0
  92. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_client_id_destination.py +0 -0
  93. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_compat_pin_reachability.py +0 -0
  94. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_create_split_encoding.py +0 -0
  95. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_decode_description.py +0 -0
  96. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_decode_functions.py +0 -0
  97. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_delivered_rtp_start.py +0 -0
  98. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_destination_required.py +0 -0
  99. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_encode_functions.py +0 -0
  100. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_encode_socket.py +0 -0
  101. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_filter_edges.py +0 -0
  102. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_gen_client_manifest.py +0 -0
  103. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_idempotency_integration.py +0 -0
  104. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_integration.py +0 -0
  105. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_iq_20khz_f32.py +0 -0
  106. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_keepalive_encoding.py +0 -0
  107. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_lifetime.py +0 -0
  108. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_listen_multicast.py +0 -0
  109. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_managed_stream_recovery.py +0 -0
  110. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_monitor.py +0 -0
  111. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multicast_helpers.py +0 -0
  112. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multihomed.py +0 -0
  113. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multistream_completeness.py +0 -0
  114. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multistream_gap_storm.py +0 -0
  115. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multistream_prune.py +0 -0
  116. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_multistream_restore.py +0 -0
  117. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_native_discovery.py +0 -0
  118. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_parameter_vector.py +0 -0
  119. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_parse_rtp_samples_iq.py +0 -0
  120. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_performance_fixes.py +0 -0
  121. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_poll_channel_idle.py +0 -0
  122. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_protocol_compat.py +0 -0
  123. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_recovery_ladder.py +0 -0
  124. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_remove_channel.py +0 -0
  125. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_rtp_recorder.py +0 -0
  126. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_rtp_to_wallclock_deprecated.py +0 -0
  127. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_security_features.py +0 -0
  128. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_set_demod_type.py +0 -0
  129. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_set_lock_warns.py +0 -0
  130. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_set_spectrum.py +0 -0
  131. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_slot_clock.py +0 -0
  132. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_spectrum.py +0 -0
  133. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_ssrc_dest_unit.py +0 -0
  134. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_ssrc_encoding_unit.py +0 -0
  135. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_ssrc_radiod_host_unit.py +0 -0
  136. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_status_decoder.py +0 -0
  137. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_status_listener.py +0 -0
  138. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_status_socket_drain.py +0 -0
  139. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_sync_types.py +0 -0
  140. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_ttl_warning.py +0 -0
  141. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_tune.py +0 -0
  142. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_tune_cli.py +0 -0
  143. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_tune_debug.py +0 -0
  144. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_tune_live.py +0 -0
  145. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_tune_method.py +0 -0
  146. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_upstream_drift.py +0 -0
  147. {ka9q_python-3.26.1 → ka9q_python-3.27.0}/tests/test_zero_block_detection.py +0 -0
@@ -1,5 +1,55 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.27.0 (2026-11-11)
4
+
5
+ ### Changed
6
+
7
+ - **The ka9q-radio pin moves from 401992cd (09-19) to aa52698c (11-02),
8
+ Phil's main.** `sync_types.py --apply` regenerated `types.py`. The 167
9
+ commits between them leave the wire format alone: every existing tag keeps
10
+ its number and its encoded type. Phil changed `encode_float` and
11
+ `decode_float` to take and return `float`, but a float still travels in
12
+ 4 bytes and a double in 8.
13
+ - **Phil dropped the doppler tags.** Tags 37 and 38 now read `UNUSED6` and
14
+ `UNUSED7`. `ChannelStatus.doppler` and `doppler_rate` stay, always `None`,
15
+ so code that reads them keeps running. `set_doppler()` raises and points
16
+ to `set_sweep()`. The status decoder no longer names the removed tags; it
17
+ would have raised `AttributeError` on any packet that reached that branch.
18
+
19
+ ### Added
20
+
21
+ - **Sweep (dechirp) support.** radiod's `SWEEP_RATE`, `SWEEP_DURATION`,
22
+ `SWEEP_PERIOD` and `SWEEP_START` (118-121) now come from upstream.
23
+ `RadiodControl.set_sweep()` sets them, and `ChannelStatus` reports them.
24
+ The epoch pair, `SWEEP_EPOCH_SAMPLE` and `SWEEP_EPOCH_FRAC` (217, 216),
25
+ stays in `sync_types.py`'s pending-upstream table until Phil takes the
26
+ dechirp PR and assigns final numbers.
27
+ - **`tests/client_usage_manifest.json` covers what the clients call today.**
28
+ hf-timestd, hfdl-recorder, meteor-scatter, phase-engine, psk-recorder and
29
+ wspr-recorder had come to use symbols the contract test never checked.
30
+
31
+ ## 3.26.2 (2026-11-01)
32
+
33
+ ### Fixed
34
+
35
+ - **`ensure_channel()` now waits for radiod to report the requested
36
+ encoding.** `create_channel()` sends `OUTPUT_ENCODING` as a separate
37
+ command after the create, and `ensure_channel()` returned the first status
38
+ it saw, which could predate that command. A fresh F32 channel then came
39
+ back labelled S16, and `RadiodStream` decoded 4-byte floats as 2-byte
40
+ ints: noise-like samples on the 1/32768 grid, rms about 0.58 of full
41
+ scale, with "completeness 100%". codar-sounder ran this way on AC0G-ND and
42
+ UACNJ and heard no CODAR all day; with the encoding settled, the same
43
+ channel showed the Rutgers 13 MHz radars at 32 dB. `ensure_channel()` now
44
+ re-polls until the reported encoding matches the request, within its
45
+ `timeout`. If radiod still reports another encoding at the deadline, it
46
+ logs an error and returns radiod's value, so a stream decodes what is on
47
+ the wire. Checked live on UACNJ's radiod: a new F32 channel first reported
48
+ encoding 2 and settled to 4.
49
+ - The comments that blamed radiod for "silently downgrading F32 to S16"
50
+ (`control.py`, `stream.py`) now name the stale status instead. The bee1
51
+ 2026-05-15 T6/TSL3 incident they cited was very likely the same race.
52
+
3
53
  ## 3.26.1 (2026-10-01)
4
54
 
5
55
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ka9q-python
3
- Version: 3.26.1
3
+ Version: 3.27.0
4
4
  Summary: Python interface for ka9q-radio control and monitoring
5
5
  Author-email: Michael Hauan AC0G <ac0g@hauan.org>
6
6
  License: MIT
@@ -284,6 +284,11 @@ The `--apply` mode updates three files atomically:
284
284
  2. `ka9q_radio_compat` — updated with the new commit hash
285
285
  3. `ka9q/compat.py` — updated with the new commit hash (importable)
286
286
 
287
+ Tags HamSCI defines ahead of upstream (the sweep TLVs) live in
288
+ `PENDING_UPSTREAM_STATUS_TABLE` in `scripts/sync_types.py`; `--apply` re-emits
289
+ them into `types.py`, so it stays idempotent. `--check` fails if upstream
290
+ reuses one of their numbers and warns when upstream gains the name.
291
+
287
292
  ### For Deployment Tooling
288
293
 
289
294
  `ka9q-update` (or any deployment tool) can read the pinned commit to ensure the correct `radiod` version is running:
@@ -250,6 +250,11 @@ The `--apply` mode updates three files atomically:
250
250
  2. `ka9q_radio_compat` — updated with the new commit hash
251
251
  3. `ka9q/compat.py` — updated with the new commit hash (importable)
252
252
 
253
+ Tags HamSCI defines ahead of upstream (the sweep TLVs) live in
254
+ `PENDING_UPSTREAM_STATUS_TABLE` in `scripts/sync_types.py`; `--apply` re-emits
255
+ them into `types.py`, so it stays idempotent. `--check` fails if upstream
256
+ reuses one of their numbers and warns when upstream gains the name.
257
+
253
258
  ### For Deployment Tooling
254
259
 
255
260
  `ka9q-update` (or any deployment tool) can read the pinned commit to ensure the correct `radiod` version is running:
@@ -143,7 +143,7 @@ Tuning & filter:
143
143
  - `set_sample_rate(ssrc, sample_rate)`
144
144
  - `set_shift_frequency(ssrc, shift_hz)`
145
145
  - `set_first_lo(ssrc, frequency_hz)`
146
- - `set_doppler(ssrc, doppler_hz=0.0, doppler_rate_hz_per_sec=0.0)`
146
+ - `set_sweep(ssrc, rate_hz_per_s, period_s, duration_s=None, start_s=0.0)` (replaces retired `set_doppler`, which now raises)
147
147
  - `set_filter(ssrc, low_edge=None, high_edge=None, kaiser_beta=None)`
148
148
  - `set_kaiser_beta(ssrc, beta)`
149
149
  - `set_filter2(ssrc, blocksize, kaiser_beta=None)`
@@ -335,8 +335,10 @@ grouped by category:
335
335
 
336
336
  - **Identification** — `ssrc`, `description`, `preset`, `demod_type`,
337
337
  `rtp_pt`, `command_tag`, `gps_time`, `rtp_timesnap`.
338
- - **Tuning** — `frequency`, `first_lo`, `second_lo`, `shift`,
339
- `doppler`, `doppler_rate`.
338
+ - **Tuning** — `frequency`, `first_lo`, `second_lo`, `shift`.
339
+ (`doppler` and `doppler_rate` remain but stay None: radiod dropped them.)
340
+ - **Sweep** — `sweep_rate`, `sweep_duration`, `sweep_period`, `sweep_start`,
341
+ `sweep_epoch_sample`, `sweep_epoch_frac`.
340
342
  - **Filter** — `low_edge`, `high_edge`, `kaiser_beta`,
341
343
  `filter_blocksize`, `filter_fir_length`, `filter_drops`, `noise_bw`.
342
344
  - **Squelch / AGC / gain** — `snr_squelch_enable`, `squelch_open`,
@@ -18,10 +18,10 @@ def main():
18
18
 
19
19
  print("=== Advanced RadioD Feature Demonstrations ===\n")
20
20
 
21
- # 1. Doppler tracking for satellite reception
22
- print("1. Setting Doppler shift and rate (for satellite tracking)")
23
- control.set_doppler(ssrc=ssrc, doppler_hz=-5000, doppler_rate_hz_per_sec=100)
24
- print(" ✓ Doppler: -5 kHz, rate: 100 Hz/s\n")
21
+ # 1. Linear sweep (dechirp), replaces the retired Doppler command
22
+ print("1. Setting a linear sweep (dechirp)")
23
+ control.set_sweep(ssrc=ssrc, rate_hz_per_s=-25733.913, period_s=1.0)
24
+ print(" ✓ Sweep: -25733.913 Hz/s, period 1 s\n")
25
25
 
26
26
  # 2. PLL configuration for carrier tracking
27
27
  print("2. Configuring PLL for coherent AM detection")
@@ -54,8 +54,6 @@ def _render_status_text(st: ChannelStatus) -> str:
54
54
  L.append(f" First LO: {_fmt_hz(st.first_lo)} lock={fe.lock}")
55
55
  L.append(f" Second LO: {_fmt_hz(st.second_lo)}")
56
56
  L.append(f" Shift: {_fmt_hz(st.shift)}")
57
- if st.doppler:
58
- L.append(f" Doppler: {_fmt_hz(st.doppler)} @ {st.doppler_rate} Hz/s")
59
57
  L.append(f" Filter: {_fmt_hz(st.low_edge)} .. {_fmt_hz(st.high_edge)} (β={st.kaiser_beta})")
60
58
  L.append(f" FE filter: {_fmt_hz(fe.fe_low_edge)} .. {_fmt_hz(fe.fe_high_edge)}")
61
59
  L.append("")
@@ -12,4 +12,4 @@ Usage:
12
12
  print(f"Compatible with ka9q-radio at {KA9Q_RADIO_COMMIT}")
13
13
  """
14
14
 
15
- KA9Q_RADIO_COMMIT: str = "401992cdecaa7f85b093bff053f074453c99bdf5"
15
+ KA9Q_RADIO_COMMIT: str = "aa52698cd1a8718f6adae4da4e4f96ca74eb4147"
@@ -23,7 +23,9 @@ PARAMETERS:
23
23
  import socket
24
24
  import select
25
25
  import struct
26
+ import math
26
27
  import secrets
28
+ import warnings
27
29
  import logging
28
30
  import threading
29
31
  import hashlib
@@ -910,7 +912,11 @@ class RadiodControl:
910
912
  Sends TLV-encoded commands to radiod's control socket to create
911
913
  and configure channels.
912
914
  """
913
-
915
+
916
+ # ensure_channel(): pause between status polls while waiting for radiod
917
+ # to report the requested OUTPUT_ENCODING.
918
+ _ENCODING_SETTLE_POLL_S = 0.1
919
+
914
920
  def __init__(self, status_address: str, max_commands_per_sec: int = 100,
915
921
  interface: Optional[str] = None,
916
922
  client_id: Optional[str] = None):
@@ -2072,9 +2078,40 @@ class RadiodControl:
2072
2078
  f"Channel SSRC {ssrc} not verified within {timeout}s. "
2073
2079
  f"Requested: {frequency_hz/1e6:.3f} MHz, {preset}, {sample_rate} Hz"
2074
2080
  )
2075
- # radiod may grant a different encoding (e.g. F32->S16 for some IQ
2076
- # configs); the returned ChannelInfo carries the granted value, which
2077
- # consumers use authoritatively. A rate/preset divergence is logged
2081
+ # create_channel() sends OUTPUT_ENCODING as a separate command after
2082
+ # the create, so the first status can predate it and report the
2083
+ # preset's encoding. Streams pick their decoder from
2084
+ # ChannelInfo.encoding; a stale S16 on an F32 stream decodes 4-byte
2085
+ # floats as 2-byte ints — noise-like garbage at "100% completeness".
2086
+ # Keep polling until radiod reports the requested encoding. If it
2087
+ # still differs at the deadline, return what radiod reports (the
2088
+ # stream must decode what is on the wire) and say so loudly.
2089
+ if encoding != 0 and channel.encoding != encoding:
2090
+ deadline = time.monotonic() + timeout
2091
+ stale = channel.encoding
2092
+ while time.monotonic() < deadline:
2093
+ time.sleep(self._ENCODING_SETTLE_POLL_S)
2094
+ fresh = self.poll_channel(
2095
+ ssrc, expected_freq=frequency_hz,
2096
+ timeout=max(0.1, min(1.0, deadline - time.monotonic())),
2097
+ frequency_tolerance=frequency_tolerance,
2098
+ )
2099
+ if fresh is not None:
2100
+ channel = fresh
2101
+ if channel.encoding == encoding:
2102
+ break
2103
+ if channel.encoding == encoding:
2104
+ logger.info(
2105
+ "ensure_channel: SSRC %s encoding settled %s -> %s",
2106
+ ssrc, stale, channel.encoding,
2107
+ )
2108
+ else:
2109
+ logger.error(
2110
+ "ensure_channel: SSRC %s still reports encoding %s after "
2111
+ "%.1fs (requested %s); returning radiod's value",
2112
+ ssrc, channel.encoding, timeout, encoding,
2113
+ )
2114
+ # A rate/preset divergence is logged
2078
2115
  # but not fatal — the channel exists at the requested frequency.
2079
2116
  # An ABSENT preset is not a divergence. radiod may decline to echo
2080
2117
  # PRESET at all (write-only from the nopreset branch on), and a label
@@ -2589,32 +2626,68 @@ class RadiodControl:
2589
2626
  logger.info("Metrics reset")
2590
2627
 
2591
2628
  def set_doppler(self, ssrc: int, doppler_hz: float = 0.0, doppler_rate_hz_per_sec: float = 0.0):
2629
+ """Retired: radiod dropped DOPPLER_FREQUENCY/_RATE in ka9q 64938af7.
2630
+
2631
+ Use :meth:`set_sweep`. Sends nothing.
2592
2632
  """
2593
- Set Doppler frequency shift and rate for satellite tracking
2594
-
2633
+ warnings.warn("set_doppler is retired; radiod dropped DOPPLER (ka9q 64938af7); use set_sweep",
2634
+ DeprecationWarning, stacklevel=2)
2635
+ raise RuntimeError("radiod dropped DOPPLER (ka9q 64938af7); use set_sweep")
2636
+
2637
+ def set_sweep(self, ssrc: int, rate_hz_per_s: float, period_s: float,
2638
+ duration_s: Optional[float] = None, start_s: float = 0.0) -> None:
2639
+ """
2640
+ Command a linear sweep (dechirp) on a linear-demod channel.
2641
+
2642
+ Sends all four sweep TLVs, zeros explicit, so a command always
2643
+ replaces the whole sweep. radiod checks the merged settings after
2644
+ each command and refuses (logs, leaves the channel unswept) a rate
2645
+ without a period, duration > period, or an NCO-limit violation.
2646
+
2595
2647
  Args:
2596
2648
  ssrc: SSRC of the channel
2597
- doppler_hz: Doppler frequency shift in Hz (default: 0.0)
2598
- doppler_rate_hz_per_sec: Doppler rate in Hz/sec (default: 0.0)
2599
-
2600
- Example:
2601
- >>> # Track satellite with 5 kHz Doppler shift, changing at 100 Hz/sec
2602
- >>> control.set_doppler(ssrc=12345, doppler_hz=5000, doppler_rate_hz_per_sec=100)
2649
+ rate_hz_per_s: sweep rate, Hz/s, signed (positive = up); 0 = no sweep
2650
+ period_s: sweep period in seconds (required for a nonzero rate)
2651
+ duration_s: seconds of each period that sweep (default: whole period)
2652
+ start_s: offset added to the sweep time base, seconds (default 0)
2653
+
2654
+ Raises:
2655
+ ValidationError: non-finite value; rate != 0 without
2656
+ 0 < period <= 1e6 s; duration outside [0, period]
2657
+
2658
+ Note: SWEEP_EPOCH_SAMPLE/FRAC (217/216), which radiod reports, are
2659
+ provisional until Phil assigns final numbers.
2603
2660
  """
2604
2661
  _validate_ssrc(ssrc)
2605
-
2662
+ if duration_s is None:
2663
+ duration_s = period_s
2664
+ for nm, v in (("rate", rate_hz_per_s), ("period", period_s),
2665
+ ("duration", duration_s), ("start", start_s)):
2666
+ if not isinstance(v, (int, float)) or isinstance(v, bool) or not math.isfinite(v):
2667
+ raise ValidationError(f"Sweep {nm} must be a finite number, got {v!r}")
2668
+ if rate_hz_per_s != 0 and not (0 < period_s <= 1e6):
2669
+ raise ValidationError(
2670
+ f"Sweep period must satisfy 0 < period <= 1e6 s with a nonzero rate, got {period_s}")
2671
+ if period_s < 0 or period_s > 1e6:
2672
+ raise ValidationError(f"Sweep period out of range [0, 1e6] s: {period_s}")
2673
+ if not (0 <= duration_s <= period_s):
2674
+ raise ValidationError(
2675
+ f"Sweep duration must satisfy 0 <= duration <= period ({period_s}), got {duration_s}")
2676
+
2606
2677
  cmdbuffer = bytearray()
2607
2678
  cmdbuffer.append(CMD)
2608
-
2609
- encode_double(cmdbuffer, StatusType.DOPPLER_FREQUENCY, doppler_hz)
2610
- encode_double(cmdbuffer, StatusType.DOPPLER_FREQUENCY_RATE, doppler_rate_hz_per_sec)
2679
+ encode_double(cmdbuffer, StatusType.SWEEP_RATE, float(rate_hz_per_s))
2680
+ encode_double(cmdbuffer, StatusType.SWEEP_DURATION, float(duration_s))
2681
+ encode_double(cmdbuffer, StatusType.SWEEP_PERIOD, float(period_s))
2682
+ encode_double(cmdbuffer, StatusType.SWEEP_START, float(start_s))
2611
2683
  encode_int(cmdbuffer, StatusType.OUTPUT_SSRC, ssrc)
2612
2684
  encode_int(cmdbuffer, StatusType.COMMAND_TAG, secrets.randbits(31))
2613
2685
  encode_eol(cmdbuffer)
2614
-
2615
- logger.info(f"Setting Doppler for SSRC {ssrc}: freq={doppler_hz} Hz, rate={doppler_rate_hz_per_sec} Hz/s")
2686
+
2687
+ logger.info(f"Setting sweep for SSRC {ssrc}: rate={rate_hz_per_s} Hz/s, "
2688
+ f"period={period_s} s, duration={duration_s} s, start={start_s} s")
2616
2689
  self.send_command(cmdbuffer)
2617
-
2690
+
2618
2691
  def set_pll(self, ssrc: int, enable: bool, bandwidth_hz: Optional[float] = None, square: bool = False):
2619
2692
  """
2620
2693
  Configure PLL (Phase-Locked Loop) for carrier tracking in linear modes
@@ -209,8 +209,16 @@ class ChannelStatus:
209
209
  first_lo: Optional[float] = None # FIRST_LO_FREQUENCY (also in frontend)
210
210
  second_lo: Optional[float] = None # SECOND_LO_FREQUENCY
211
211
  shift: Optional[float] = None # SHIFT_FREQUENCY
212
- doppler: Optional[float] = None # DOPPLER_FREQUENCY
213
- doppler_rate: Optional[float] = None # DOPPLER_FREQUENCY_RATE
212
+ doppler: Optional[float] = None # always None: radiod dropped DOPPLER (ka9q 64938af7)
213
+ doppler_rate: Optional[float] = None # always None: tags 37/38 are UNUSED6/7 upstream
214
+
215
+ # Sweep (dechirp); radiod reports all four on every linear channel
216
+ sweep_rate: Optional[float] = None # SWEEP_RATE (Hz/s, signed)
217
+ sweep_duration: Optional[float] = None # SWEEP_DURATION (s)
218
+ sweep_period: Optional[float] = None # SWEEP_PERIOD (s)
219
+ sweep_start: Optional[float] = None # SWEEP_START (s)
220
+ sweep_epoch_sample: Optional[int] = None # SWEEP_EPOCH_SAMPLE (signed int64)
221
+ sweep_epoch_frac: Optional[float] = None # SWEEP_EPOCH_FRAC (fraction of a sample)
214
222
 
215
223
  # Filter (primary)
216
224
  low_edge: Optional[float] = None # LOW_EDGE (Hz)
@@ -499,10 +507,21 @@ def decode_status_packet(buffer: bytes) -> Optional[ChannelStatus]:
499
507
  st.frequency = decode_double(data, optlen)
500
508
  elif t == StatusType.SHIFT_FREQUENCY:
501
509
  st.shift = decode_double(data, optlen)
502
- elif t == StatusType.DOPPLER_FREQUENCY:
503
- st.doppler = decode_double(data, optlen)
504
- elif t == StatusType.DOPPLER_FREQUENCY_RATE:
505
- st.doppler_rate = decode_double(data, optlen)
510
+ elif t == StatusType.SWEEP_RATE:
511
+ st.sweep_rate = decode_double(data, optlen)
512
+ elif t == StatusType.SWEEP_DURATION:
513
+ st.sweep_duration = decode_double(data, optlen)
514
+ elif t == StatusType.SWEEP_PERIOD:
515
+ st.sweep_period = decode_double(data, optlen)
516
+ elif t == StatusType.SWEEP_START:
517
+ st.sweep_start = decode_double(data, optlen)
518
+ elif t == StatusType.SWEEP_EPOCH_SAMPLE:
519
+ # Signed: negative early in uptime. A negative int64 always
520
+ # arrives as all 8 bytes (no leading zeros to strip).
521
+ v = decode_int64(data, optlen)
522
+ st.sweep_epoch_sample = v - (1 << 64) if v >= (1 << 63) else v
523
+ elif t == StatusType.SWEEP_EPOCH_FRAC:
524
+ st.sweep_epoch_frac = decode_double(data, optlen)
506
525
 
507
526
  # ---- Demod class / preset ----
508
527
  elif t == StatusType.DEMOD_TYPE:
@@ -129,11 +129,12 @@ def parse_rtp_samples(
129
129
  if floats is None:
130
130
  return None
131
131
  if is_iq:
132
- # radiod silently downgrades F32 → S16 for some IQ-channel
133
- # configurations (high sample rate + wide filter); confirmed on
134
- # bee1 2026-05-15 for T6/TSL3 BPSK PPS channel (encoding=4
135
- # requested, encoding=2 granted, decoded as F32LE → NaN-poisoned
136
- # input, TSL3 dark). Honor the granted encoding above.
132
+ # Decode with the encoding the channel reports. A wrong value
133
+ # here corrupts silently: the bee1 2026-05-15 T6/TSL3 "F32→S16
134
+ # downgrade" and codar-sounder's 2026-11-01 garbage IQ were both
135
+ # a stale encoding from ensure_channel (status read before the
136
+ # separate OUTPUT_ENCODING command landed), not radiod changing
137
+ # the encoding. ensure_channel now waits for it to settle.
137
138
  if len(floats) % 2 != 0:
138
139
  logger.warning(f"Odd number of samples in IQ payload: {len(floats)}")
139
140
  return None
@@ -127,8 +127,6 @@ class TuningPanel(Panel):
127
127
  f"Filter: {_fmt_hz(st.low_edge)} .. {_fmt_hz(st.high_edge)}",
128
128
  f"FE filter: {_fmt_hz(fe.fe_low_edge)} .. {_fmt_hz(fe.fe_high_edge)}",
129
129
  ]
130
- if st.doppler:
131
- lines.append(f"Doppler: {_fmt_hz(st.doppler)} @ {st.doppler_rate} Hz/s")
132
130
  return "\n".join(lines)
133
131
 
134
132
 
@@ -2,9 +2,11 @@
2
2
  ka9q-radio protocol types and constants
3
3
 
4
4
  Auto-generated by scripts/sync_types.py from ka9q-radio C headers.
5
- Validated against ka9q-radio commit: 401992cdecaa
5
+ Validated against ka9q-radio commit: aa52698cd1a8
6
6
 
7
7
  DO NOT EDIT MANUALLY — run: python scripts/sync_types.py --apply
8
+ Entries marked 'pending upstream' come from PENDING_UPSTREAM_STATUS_TABLE
9
+ in that script; --apply re-emits them.
8
10
  """
9
11
 
10
12
 
@@ -48,8 +50,8 @@ class StatusType:
48
50
  FIRST_LO_FREQUENCY = 34
49
51
  SECOND_LO_FREQUENCY = 35
50
52
  SHIFT_FREQUENCY = 36
51
- DOPPLER_FREQUENCY = 37
52
- DOPPLER_FREQUENCY_RATE = 38
53
+ UNUSED6 = 37
54
+ UNUSED7 = 38
53
55
  LOW_EDGE = 39
54
56
  HIGH_EDGE = 40
55
57
  KAISER_BETA = 41
@@ -129,6 +131,12 @@ class StatusType:
129
131
  SPECTRUM_STEP = 115 # size of byte spectrum data level step, dB
130
132
  SPECTRUM_OVERLAP = 116 # Overlap of FFT windows when averaging (0-1)
131
133
  LIFETIME = 117 # frames until channel goes away
134
+ SWEEP_RATE = 118
135
+ SWEEP_DURATION = 119
136
+ SWEEP_PERIOD = 120
137
+ SWEEP_START = 121
138
+ SWEEP_EPOCH_FRAC = 216 # fraction of an input sample after SWEEP_EPOCH_SAMPLE (double); pending upstream; Phil assigns final numbers
139
+ SWEEP_EPOCH_SAMPLE = 217 # input-counter index of a recent sweep start (SIGNED int64); pending upstream; Phil assigns final numbers
132
140
 
133
141
 
134
142
  # Command packet type
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ka9q-python
3
- Version: 3.26.1
3
+ Version: 3.27.0
4
4
  Summary: Python interface for ka9q-radio control and monitoring
5
5
  Author-email: Michael Hauan AC0G <ac0g@hauan.org>
6
6
  License: MIT
@@ -284,6 +284,11 @@ The `--apply` mode updates three files atomically:
284
284
  2. `ka9q_radio_compat` — updated with the new commit hash
285
285
  3. `ka9q/compat.py` — updated with the new commit hash (importable)
286
286
 
287
+ Tags HamSCI defines ahead of upstream (the sweep TLVs) live in
288
+ `PENDING_UPSTREAM_STATUS_TABLE` in `scripts/sync_types.py`; `--apply` re-emits
289
+ them into `types.py`, so it stays idempotent. `--check` fails if upstream
290
+ reuses one of their numbers and warns when upstream gains the name.
291
+
287
292
  ### For Deployment Tooling
288
293
 
289
294
  `ka9q-update` (or any deployment tool) can read the pinned commit to ensure the correct `radiod` version is running:
@@ -133,6 +133,7 @@ tests/test_ssrc_radiod_host_unit.py
133
133
  tests/test_status_decoder.py
134
134
  tests/test_status_listener.py
135
135
  tests/test_status_socket_drain.py
136
+ tests/test_sweep.py
136
137
  tests/test_sync_types.py
137
138
  tests/test_ttl_warning.py
138
139
  tests/test_tune.py
@@ -1,3 +1,3 @@
1
1
  # ka9q-radio commit that ka9q/types.py was last validated against
2
2
  # Updated by: scripts/sync_types.py --apply
3
- 401992cdecaa7f85b093bff053f074453c99bdf5
3
+ aa52698cd1a8718f6adae4da4e4f96ca74eb4147
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ka9q-python"
7
- version = "3.26.1"
7
+ version = "3.27.0"
8
8
  description = "Python interface for ka9q-radio control and monitoring"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -247,6 +247,8 @@ def generate_types_py(
247
247
  lines.append(f"Validated against ka9q-radio commit: {commit_hash[:12]}")
248
248
  lines.append("")
249
249
  lines.append("DO NOT EDIT MANUALLY — run: python scripts/sync_types.py --apply")
250
+ lines.append("Entries marked 'pending upstream' come from PENDING_UPSTREAM_STATUS_TABLE")
251
+ lines.append("in that script; --apply re-emits them.")
250
252
  lines.append('"""')
251
253
  lines.append("")
252
254
  lines.append("")
@@ -258,6 +260,11 @@ def generate_types_py(
258
260
  suffix = f" # {comment}" if comment else ""
259
261
  lines.append(f" {name} = {value}{suffix}")
260
262
 
263
+ upstream_names = {n for n, _, _ in status_entries}
264
+ for name, value, comment in PENDING_UPSTREAM_STATUS_TABLE:
265
+ if name not in upstream_names:
266
+ lines.append(f" {name} = {value} # {comment}; {PENDING_COMMENT}")
267
+
261
268
  lines.append("")
262
269
  lines.append("")
263
270
  lines.append("# Command packet type")
@@ -322,6 +329,20 @@ def generate_types_py(
322
329
  # ---------------------------------------------------------------------------
323
330
  # Diff / check / apply
324
331
  # ---------------------------------------------------------------------------
332
+ # StatusType tags HamSCI defines ahead of upstream ka9q-radio (the dechirp
333
+ # branch). generate_types_py() emits them into types.py so --apply is
334
+ # idempotent; _check_enum() tolerates them as EXTRA, fails if upstream reuses
335
+ # one of the numbers under another name, and warns once upstream has the name
336
+ # (then delete the entry here).
337
+ PENDING_UPSTREAM_STATUS_TABLE = [
338
+ ("SWEEP_EPOCH_FRAC", 216, "fraction of an input sample after SWEEP_EPOCH_SAMPLE (double)"),
339
+ ("SWEEP_EPOCH_SAMPLE", 217, "input-counter index of a recent sweep start (SIGNED int64)"),
340
+ ]
341
+ PENDING_COMMENT = "pending upstream; Phil assigns final numbers"
342
+ PENDING_UPSTREAM_STATUS = {n for n, _, _ in PENDING_UPSTREAM_STATUS_TABLE}
343
+ _PENDING_BY_VALUE = {v: n for n, v, _ in PENDING_UPSTREAM_STATUS_TABLE}
344
+
345
+
325
346
  def _check_enum(
326
347
  label: str,
327
348
  c_entries: List[Tuple[str, int, str]],
@@ -333,6 +354,17 @@ def _check_enum(
333
354
  alias_names = set()
334
355
  issues: List[str] = []
335
356
  c_map = {name: val for name, val, _ in c_entries}
357
+ if label == "StatusType":
358
+ for name, val, _ in c_entries:
359
+ if val in _PENDING_BY_VALUE and name != _PENDING_BY_VALUE[val]:
360
+ issues.append(
361
+ f"{label}: UPSTREAM REUSES pending value {val} "
362
+ f"({_PENDING_BY_VALUE[val]}) as {name}"
363
+ )
364
+ for name in sorted(PENDING_UPSTREAM_STATUS & set(c_map)):
365
+ print(f"warning: pending-upstream {name} now exists upstream "
366
+ f"(= {c_map[name]}); remove it from PENDING_UPSTREAM_STATUS_TABLE",
367
+ file=sys.stderr)
336
368
 
337
369
  for name, val, comment in c_entries:
338
370
  if name not in py_entries:
@@ -346,6 +378,8 @@ def _check_enum(
346
378
  for name, val in sorted(py_entries.items(), key=lambda x: x[1]):
347
379
  if name in alias_names:
348
380
  continue
381
+ if label == "StatusType" and name in PENDING_UPSTREAM_STATUS:
382
+ continue
349
383
  if name not in c_map:
350
384
  issues.append(f"{label}: EXTRA in Python {name} = {val}")
351
385
 
@@ -75,5 +75,68 @@ class TestEnsureChannelEncoding(unittest.TestCase):
75
75
  _, kwargs = self.control.create_channel.call_args
76
76
  self.assertEqual(kwargs['encoding'], Encoding.F32)
77
77
 
78
+
79
+ def _info(ssrc, encoding):
80
+ return ChannelInfo(ssrc=ssrc, preset="iq", sample_rate=16000,
81
+ frequency=14074000.0, snr=0.0,
82
+ multicast_address="239.1.1.1", port=5004,
83
+ encoding=encoding)
84
+
85
+
86
+ class TestEnsureChannelEncodingSettles(unittest.TestCase):
87
+ """The first status after create can predate OUTPUT_ENCODING.
88
+
89
+ Found 2026-11-01: codar-sounder on AC0G-ND and UACNJ got encoding S16
90
+ back for an F32 channel and decoded 4-byte floats as 2-byte ints for a
91
+ whole day. ensure_channel must wait for the requested encoding.
92
+ """
93
+
94
+ SSRC = 12345
95
+
96
+ @patch('ka9q.control.RadiodControl._connect')
97
+ def setUp(self, mock_connect):
98
+ self.control = RadiodControl("radiod.local")
99
+ self.control.create_channel = MagicMock()
100
+ self.control._ENCODING_SETTLE_POLL_S = 0.0
101
+
102
+ def _ensure(self, encoding=Encoding.F32, timeout=0.5):
103
+ with patch('ka9q.control.allocate_ssrc', return_value=self.SSRC):
104
+ return self.control.ensure_channel(
105
+ frequency_hz=14.074e6, destination="239.1.1.1",
106
+ encoding=encoding, timeout=timeout)
107
+
108
+ def test_stale_first_status_is_replaced_by_the_settled_one(self):
109
+ # probe (no channel yet), first verify (stale S16), then F32
110
+ self.control.poll_channel = MagicMock(side_effect=[
111
+ None, _info(self.SSRC, Encoding.S16BE),
112
+ _info(self.SSRC, Encoding.S16BE), _info(self.SSRC, Encoding.F32)])
113
+ result = self._ensure()
114
+ self.assertEqual(result.encoding, Encoding.F32)
115
+ self.assertEqual(self.control.poll_channel.call_count, 4)
116
+
117
+ def test_encoding_that_never_settles_returns_radiods_value_and_logs(self):
118
+ def poll(*a, **kw):
119
+ return None if poll.n == 0 else _info(self.SSRC, Encoding.S16BE)
120
+ poll.n = 0
121
+ def counting(*a, **kw):
122
+ r = poll(*a, **kw); poll.n += 1; return r
123
+ self.control.poll_channel = MagicMock(side_effect=counting)
124
+ with self.assertLogs('ka9q.control', level='ERROR') as logs:
125
+ result = self._ensure(timeout=0.2)
126
+ self.assertEqual(result.encoding, Encoding.S16BE)
127
+ self.assertTrue(any("still reports encoding" in m for m in logs.output))
128
+
129
+ def test_matching_first_status_polls_no_more(self):
130
+ self.control.poll_channel = MagicMock(side_effect=[
131
+ None, _info(self.SSRC, Encoding.F32)])
132
+ self.assertEqual(self._ensure().encoding, Encoding.F32)
133
+ self.assertEqual(self.control.poll_channel.call_count, 2)
134
+
135
+ def test_no_encoding_requested_takes_the_first_status(self):
136
+ self.control.poll_channel = MagicMock(side_effect=[
137
+ None, _info(self.SSRC, Encoding.S16BE)])
138
+ self.assertEqual(self._ensure(encoding=0).encoding, Encoding.S16BE)
139
+ self.assertEqual(self.control.poll_channel.call_count, 2)
140
+
78
141
  if __name__ == '__main__':
79
142
  unittest.main()