Skip to content

v1.5.1 — WSPR power normalization and packmsg bounds hardening

Latest

Choose a tag to compare

@NT7S NT7S released this 02 Dec 21:17
062bdb3

What's changed

WSPR power normalization (PR #45)
wspr_encode() now follows the WSJT-X wqencode convention: clamp to the 0–60 dBm range, then normalize with the nu table (power = dbm + nu[dbm % 10], nu = {0,-1,1,0,-1,2,1,0,-1,1}) instead of rounding invalid powers down through the old valid_dbm table. Verified against the Fortran reference.

Full packmsg bounds hardening
getpfx1() prefix parsing is bounds-checked with explicit lengths instead of writing a terminating NUL past the four-character char c[5] entry area — this removed a one-byte stack overflow for overlong slash-prefix inputs.

Free-text invalid characters
Characters outside the 42-symbol JT character set now map to code 0 (blank) in both the compact and full paths, matching Fortran packtext77 (if(j.lt.0) j=0).

Warning cleanup
Fixed an operator-precedence bug in the suffix parse check, made bounded snprintf precision explicit, removed unused trim_len/grid2k, and made the RS symbol-size sign comparison explicit. A -Wall -Wextra build of the changed units is now clean.

Example sketches
FT4_Beacon_UnoR4WiFi and FT8_Beacon_UnoR4WiFi now cap pre-transmission WiFi reconnect time (NTP_SYNC_MAX_MS = 5000, RECONNECT_SAFETY_MS = 1000) so a reconnect cannot overrun the NTP-aligned transmit slot.

Verification

  • Harness: 36/36 PASS in both compact and full-packmsg builds, plus full packmsg regression ALL OK (includes the new prefix-bounds cases ABCDE/FGHIJ CN84 and ABCDEF/GHIJK CN84)
  • New regression tests: invalid free-text character → code 0 (checked against an independent Python packtext77), and WSPR nu normalization cases (55→57, 39→40, 49→50, -1→0, -28→0, 61→60, 60→60) — all confirmed against wqencode.f90
  • Independent recomputation of the A! free-text vector from the Fortran semantics matches the harness vector bit for bit
  • Sketches compile on Arduino UNO R4 WiFi (full path): FT4 81,040 B / 11,580 B, FT8 80,888 B / 11,556 B; compact: FT4 77,736 B, FT8 77,592 B
  • Standard WSPR powers (0, 3, 7, 10, … 60) are fixed points of the nu table — output unchanged for them

Breaking changes

  • WSPR frames with invalid power values now differ from v1.5.0. Invalid (off-table) dBm values encode through the nu table instead of rounding down, and powers below 0 dBm now clamp to 0 (the old code allowed -30 dBm). Standard on-table powers are unchanged.
  • Free-text frames with characters outside the 42-symbol set now differ. Those characters encode as blank, matching WSJT-X; previously the library used the raw character code, so such frames did not match what WSJT-X would transmit.
  • Full packmsg hash-call <...> support remains out of scope (falls back to free text).