Skip to content

Full packmsg port: fix mismatches vs WSJT-X reference (28/28) - #43

Merged
NT7S merged 6 commits into
masterfrom
feat/packmsg-split
Nov 29, 2026
Merged

NT7S merged 6 commits into
masterfrom
feat/packmsg-split

Conversation

@NT7S

@NT7S NT7S commented Nov 29, 2026

Copy link
Copy Markdown
Member

What this fixes

The full packmsg port (JTENCODE_FULL_PACKMSG) mismatched the WSJT-X Fortran reference on 16 of 28 messages (itype OK in most cases, dat/entail off). Three defects, all fixed here and verified against the Fortran reference driver:

  1. grid2deg truncated the grid to 5 chars — a 6-char input (e.g. CN84mm) lost its 6th character, so the 6th-char check and the 6th-char xminlat computation were wrong (extended reports off by ~5 in the last byte). Now copies all 6 characters.
  2. c3 fill loop wrote NUL instead of blank — blank grids (e.g. NT7S K1ABC) had c3[0] = 0, forcing free-text fallback. NUL is now mapped to blank.
  3. getpfx1 returned early on table miss — for NT7S K1ABC/X CN84 (suffix X not in the sfx table) the port kept nv2=1/k=0 and returned, skipping the compound-suffix fallback (nv2=5, 37-based k). It now falls through to the generic path, which also keeps a copy of the original callsign (the add-on branches rebuild callsign in place).

Also fixed to match the Fortran exactly: the early exits in packmsg (nv2a >= 4, text1, text2 -> free text) and the add-on grid k1 < 0 || k2 < 0 || k1*k2 != 0 check.

Verification

28/28 messages pass against the WSJT-X Fortran reference driver (itype, dat, entail — all 28 messages, including the previously-mismatched NT7S K1ABC, G0ABC M0SUP, NT7S K1ABC/X CN84, and the 5-offset extended-report cases).

Harness: 20/20 PASS plus the full packmsg regression test (now updated to the corrected reference outputs and extended with the /X suffix and gridless standard message).

Builds: Uno compact 28,438 B (88%, unchanged), Uno full-path overflows by design (documented), Uno R4 WiFi compact 72,216 B / full 77,312 B.

Note

Stacked on fix/jt4-implementation (PR #42). Do not merge without Jason's OK; PR #42 must merge first.

NT7S added 6 commits November 28, 2026 22:46
The compact free-text encoder (base-42 + freeform flag) is kept as the
default so the Uno stays lean. Defining JTENCODE_FULL_PACKMSG selects a
faithful C++ port of WSJT-X packjt.f90 (packmsg + packcall + getpfx1 +
packgrid + grid2deg + packtext + entail): type detection, CQ/QRZ/DE and
Swaziland/Guinea workarounds, 339-entry prefix and 12-entry suffix
tables, Maidenhead/report packing with the extended KA/LA report range,
and free-text fallback.

Measured on arduino:avr:uno: compact 18,088 B flash / 353 B RAM;
full path 25,804 B flash (79%) / 475 B RAM. On arduino:renesas_uno:unor4wifi:
compact 62,120 B (23%) / full 67,304 B (25%) flash.

JT65 uses the 12-byte dat block directly (no entail); JT9/JT4 use entail.
Harness passes 20/20 with both paths. README documents the option.
Verifies itype detection and the dat-byte layout for standard, CQ,
suffix, free-text, report and extended-report messages when
JTENCODE_FULL_PACKMSG is defined. Runs as part of tests/run_tests.sh.
The example sketch builds on Uno only with the compact path (the full
path overflows 32 KB: 36.3 KB vs 32,256 B). It builds with both paths
on the Uno R4 WiFi. Also note that its free-text message encodes
identically in both paths.
- Intro: mention that JT65/JT9/JT4 accept standard WSJT-X messages with
  JTENCODE_FULL_PACKMSG (callsign/grid/report, CQ/QRZ/DE prefixes, /P suffixes)
- jt65/jt9/jt4_encode doc comments: note the compact path (default) is
  Type 6 free-text and the full path accepts standard messages
- Example sketch header comment: note the standard-message capability
  when the full path is enabled
Verified bit-exact against the WSJT-X Fortran reference driver
(itype, dat, entail) after three fixes:

- grid2deg: copy all 6 grid characters (was truncating to 5, dropping
  the 6th and corrupting extended KA/LA reports)
- c3 fill loop: map NUL bytes to blanks (blank grids forced free-text
  fallback)
- getpfx1: fall through to the generic prefix/suffix path when the
  pfx/sfx tables miss, and keep a copy of the original callsign for
  the generic path (was returning early with a stale/rebuilt callsign)
- packmsg: honor the Fortran early exits (nv2a >= 4, text1, text2 ->
  free text) and the add-on grid k1<0 || k2<0 || k1*k2!=0 check

Regression test updated to the corrected reference outputs and now
also covers the /X suffix and gridless standard message.

Build verified: Uno compact (28.4 KB), Uno R4 WiFi compact (72.2 KB)
and full (77.3 KB); Uno full-path overflows by design.
@NT7S
NT7S changed the base branch from fix/jt4-implementation to master November 29, 2026 01:44
@NT7S
NT7S merged commit bc9e4e1 into master Nov 29, 2026
7 checks passed
@NT7S
NT7S deleted the feat/packmsg-split branch November 30, 2026 03:48
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.

1 participant