summaryrefslogtreecommitdiff
path: root/lib/jtty
diff options
context:
space:
mode:
Diffstat (limited to 'lib/jtty')
-rw-r--r--lib/jtty/genjtty.f9022
-rw-r--r--lib/jtty/jtty_design.md86
-rw-r--r--lib/jtty/jtty_design.txt231
-rw-r--r--lib/jtty/jtty_mdecode.f90107
-rw-r--r--lib/jtty/jtty_mod.f9013
-rw-r--r--lib/jtty/jtty_n1mm_integration.md85
-rw-r--r--lib/jtty/jtty_receive_context.f90297
-rw-r--r--lib/jtty/jtty_source_codec.f908
-rw-r--r--lib/jtty/jtty_source_encoding.txt107
-rw-r--r--lib/jtty/jtty_tx_manual_checks.md33
-rw-r--r--lib/jtty/rjtty_sub.f905
-rw-r--r--lib/jtty/sjtty.f908
-rw-r--r--lib/jtty/wava/plot_results.py57
-rw-r--r--lib/jtty/wava/tbcc_performance_curves.pngbin263436 -> 0 bytes
14 files changed, 541 insertions, 518 deletions
diff --git a/lib/jtty/genjtty.f90 b/lib/jtty/genjtty.f90
index 80be9c02..65294a15 100644
--- a/lib/jtty/genjtty.f90
+++ b/lib/jtty/genjtty.f90
@@ -8,23 +8,37 @@ subroutine genjtty(umsg,itone,nsym)
parameter (MAX_TONES=59*16) !Max number of channel symbols
character*80 umsg !User-formatted message
integer itone(MAX_TONES) !Array of tone frequencies for this message
+
+ interface
+ subroutine genjtty_profile(umsg,exchange_profile,itone,nsym,frame_starts,is_final)
+ use jtty_mod, only: MAX_FRAMES
+ character(len=80), intent(inout) :: umsg
+ integer, intent(in) :: exchange_profile
+ integer, intent(out) :: itone(59*MAX_FRAMES),nsym
+ integer, intent(out), optional :: frame_starts(MAX_FRAMES)
+ integer, intent(in), optional :: is_final
+ end subroutine genjtty_profile
+ end interface
+
call genjtty_profile(umsg,JTTY_EXCHANGE_UNKNOWN,itone,nsym)
return
end subroutine genjtty
-subroutine genjtty_profile(umsg,exchange_profile,itone,nsym)
+subroutine genjtty_profile(umsg,exchange_profile,itone,nsym,frame_starts,is_final)
use jtty_mod, only: pack_jtty,MAX_FRAMES
implicit none
character(len=80), intent(inout) :: umsg
integer, intent(in) :: exchange_profile
integer, intent(out) :: itone(59*MAX_FRAMES),nsym
+ integer, intent(out), optional :: frame_starts(MAX_FRAMES)
+ integer, intent(in), optional :: is_final
character(len=34) :: frames(MAX_FRAMES)
integer :: nframes
nsym=0
- call pack_jtty(umsg,frames,nframes,exchange_profile)
+ call pack_jtty(umsg,frames,nframes,exchange_profile,frame_starts,is_final)
if(nframes.le.0) return
call genjtty_frames(frames,nframes,itone,nsym)
end subroutine genjtty_profile
@@ -70,7 +84,7 @@ end subroutine genjtty_frames
subroutine genjtty_atoms_c(c_atoms,natoms,itone,nsym,status) bind(C,name='genjtty_atoms_c')
use iso_c_binding, only: c_char,c_int,c_null_char
- use packjt77_grammar, only: pack77_arrl_section_index
+ use packjt77_grammar, only: pack77_arrl_section_index,pack77_arrl_section_name
use jtty_mod, only: jtty_source_atom,jtty_source_atom_c,JTTY_ATOM_CALL, &
JTTY_ATOM_EXCH_NUM,JTTY_ATOM_EXCH_LOC,JTTY_ATOM_EXCH_PAIR, &
JTTY_ATOM_CONTROL,JTTY_ATOM_GRID4,jtty_call_atom,jtty_exch_num_atom, &
@@ -119,7 +133,7 @@ subroutine genjtty_atoms_c(c_atoms,natoms,itone,nsym,status) bind(C,name='genjtt
if(c_atoms(i)%subtype.ne.1) return
if(c_atoms(i)%role.lt.0 .or. c_atoms(i)%role.gt.5) return
section_index=pack77_arrl_section_index(descriptor_text)
- if(section_index.lt.1) then
+ if(section_index.lt.1 .or. descriptor_text.ne.pack77_arrl_section_name(section_index)) then
status=JTTY_ENCODE_UNKNOWN_SECTION
return
endif
diff --git a/lib/jtty/jtty_design.md b/lib/jtty/jtty_design.md
index 9448c8db..6755cb12 100644
--- a/lib/jtty/jtty_design.md
+++ b/lib/jtty/jtty_design.md
@@ -2,44 +2,29 @@
JTTY is a new digital mode designed for fast RTTY-like contest exchanges and other keyboard-to-keyboard communication on the amateur radio bands. It has an operational feel similar to standard RTTY, but far better weak-signal performance and a lower error rate. JTTY transmissions can start at any time and typically last a few seconds. Any arbitrary message can be sent using letters, digits, spaces, and punctuation. Source encoding is especially well optimized for the short, fixed-format messages generally used in RTTY-style radio contesting.
-## Frame and waveform
+This overview describes the design and gives examples of its use. The detailed protocol and source-interface rules are defined in [jtty_source_encoding.txt](jtty_source_encoding.txt). N1MM setup and macro examples are in [jtty_n1mm_integration.md](jtty_n1mm_integration.md); transmit checks are in [jtty_tx_manual_checks.md](jtty_tx_manual_checks.md).
-A transmission contains one or more 1.888-second frames. Each frame carries a 32-bit source-grammar word followed by two universal control bits: a reserved bit that is always zero and an end-of-message (EOM) bit set only on the final source atom. A 12-bit CRC extends this 34-bit payload to 46 bits. A tail-biting, rate-1/2 convolutional code with constraint length K=10 produces 92 coded bits.
+## Frame and waveform
-The waveform is Gaussian-smoothed four-tone frequency-shift keying (4-GFSK), with two coded bits per tone symbol. A frame contains a 13-symbol synchronization sequence followed by 46 coded symbols. At 12000/384 = 31.25 baud, its duration is (13+46)/31.25 = 1.888 seconds. The occupied bandwidth (99% of transmitted power) is 127 Hz.
+A transmission contains one or more 1.888-second frames. The waveform is Gaussian-smoothed four-tone frequency-shift keying (4-GFSK) at 31.25 baud. The occupied bandwidth (99% of transmitted power) is 127 Hz. Each frame carries one source atom, protected by a CRC and a tail-biting convolutional code. An end-of-message (EOM) bit marks the final atom.
-The receiver verifies FEC, CRC, the universal reserved-zero bit, and the complete source grammar. A structurally invalid source word is discarded before display, EOM handling, slot creation, or signal subtraction.
+The receiver verifies FEC, CRC, the reserved-zero bit, and the complete source grammar before using a decoded atom. An invalid atom is discarded before display, EOM handling, slot creation, or signal subtraction.
## Source contracts
JTTY separates automatic text packing from typed native actions.
-Ordinary keyboard text, `sjtty` input, externally queued strings, and untagged N1MM/MMTTY text use the literal source interface. Text is folded to uppercase, spaces are normalized, and unsupported characters become `#`. The explicit RTTY Roundup profile also canonicalizes report-prefixed serials as described below. The encoder chooses the minimum-frame combination of recognized compact atoms and five-character TEXT5 frames that preserves the resulting normalized text exactly. "Literal" identifies the text interface, not a requirement to use TEXT5 or bypass profile normalization.
+Ordinary keyboard text, `sjtty` input, externally queued strings, and untagged N1MM/MMTTY text use the literal source interface. Text is folded to uppercase, spaces are normalized, and unsupported characters become `#`. The explicit RTTY Roundup profile also canonicalizes report-prefixed serials. The encoder chooses the minimum-frame combination of recognized compact atoms and five-character TEXT5 frames that preserves the resulting normalized text exactly. "Literal" identifies the text interface, not a requirement to use TEXT5 or bypass profile normalization.
The eight shipped JTTY function-key templates use a NativeMacro contract. When a default template is selected, it is compiled to typed call and exchange atoms before placeholder expansion. Native atoms provide compact transmission and unambiguous fields for future logger integration. A customized template that does not match a native form falls back to automatic text packing after normal placeholder expansion. A recognized native template with invalid runtime data is rejected rather than silently transmitted with different semantics.
-Earlier JTTY packing minimized frames using compact calls, a generic `599 ` plus five-character format, and TEXT5. STRUCT30 replaced that generic exchange format with richer typed atoms. Restricting ordinary input to TEXT5 avoided guessing whether `05` meant a serial, zone, or check, but also lost unambiguous callsign compaction. Automatic packing retains the minimum-frame algorithm, with context-free recognition and an explicit exchange profile that can normalize serials and enable additional typed candidates.
+Restricting ordinary input to TEXT5 would avoid guessing whether `05` meant a serial, zone, or check, but would also lose unambiguous callsign compaction. Automatic packing uses a minimum-frame algorithm, with context-free recognition and an explicit exchange profile that can normalize serials and enable additional typed candidates.
## Automatic text packing
-At complete token boundaries, the packer considers the six callsign forms below, registered control phrases (including within longer messages), and these STRUCT30 forms:
-
-| Text form | Automatic atom |
-| --- | --- |
-| Canonical unsigned decimal, optionally preceded by `599` | GENERIC_NUMERIC, 0-131071, with no leading zeros except `0` |
-| `599 <location>` | GENERIC_QTH, exactly two or three base-36 characters including at least one letter |
-| Valid four-character Maidenhead locator, optionally preceded by `599` | GRID4 |
-| `<count><class> <section>` | CLASS_SECTION, count 1-32, class A-F, registered ARRL/RAC section |
-
-Every candidate must pass the existing codec validation and render exactly as its span in the normalized text. Calls must round-trip through the standard callsign codec; QTH tokens must obey the wire format's canonical length rules.
-
-The GUI captures an exchange profile from the existing special operating activity when each message is submitted: Unknown, Field Day, or RTTY Roundup. No activity means Unknown even though native macros default to serial exchanges. All profiles retain the context-free candidates above. Only RTTY Roundup adds candidates: full `599 <number>` as SERIAL and full `599 <location>` as STATE_PROVINCE, using the native exchange rules and requiring a location token to contain a letter. Bare numbers are never inferred as serials. Field Day adds no candidates because class/section syntax is already self-identifying. No new configuration or wire format is needed.
-
-Zones, checks, ages, power, license years, other specific location categories, zone/location pairs, and serial/time pairs are not inferred. Under RTTY Roundup, equally compact serial or state/province candidates take precedence over their generic equivalents through the subtype ordering below.
+Automatic packing recognizes calls, registered control phrases, generic numbers and locations, grids, and Field Day class/section exchanges at complete token boundaries. A dynamic program over character offsets selects the fewest frames under this recognition policy, rather than greedily taking the first compact form.
-A dynamic program over character offsets selects the fewest frames under this recognition policy, rather than greedily taking the first compact form. TEXT5 consumes exactly five characters except at the end; an interior short fragment cannot be padded to reach a compact candidate because that would change the text. Structured atoms supply an implicit single space when followed by another token. Equal-cost alternatives prefer a structured atom, then the longest consumed span, then atom kind/subtype/role order.
-
-Before packing, the explicit RTTY Roundup profile canonicalizes a decimal token following a complete `599` token as a serial: `599 05` becomes `599 005`, and `599 0123` becomes `599 123`. Both use one SERIAL frame. Eligible tokens contain one to six digits with value 0-131071; unsupported tokens retain their spelling and use the normal fallback. Bare digits and all text under Unknown or Field Day retain their spelling after ordinary normalization. The canonical message is returned to the GUI for display and logging. If serial normalization expands the message beyond 80 characters, submission is rejected rather than truncating it.
+The GUI captures an exchange profile from the existing special operating activity when each message is submitted: Unknown, Field Day, or RTTY Roundup. No activity means Unknown even though native macros default to serial exchanges. RTTY Roundup also recognizes report-prefixed serial and state/province exchanges and normalizes serial spelling. The detailed recognition, normalization, spacing, and tie-breaking rules are in the specification's "Automatic text packing" section.
The result need not match the theoretical minimum with perfect knowledge of exchange semantics. Under Unknown or Field Day, `599 001` and `599 05` still take two frames. An explicit codec caller can encode `599 05` as a CQ zone in one frame, but the current GUI macros do not expose that numeric kind; RTTY Roundup explicitly selects serial meaning instead.
@@ -47,64 +32,19 @@ The result need not match the theoretical minimum with perfect knowledge of exch
## Source grammar
-Bits 31-32 select one of four message types. The complete normative definition, including field ranges, enum assignments, validity rules, and golden vectors, is in [jtty_source_encoding.txt](jtty_source_encoding.txt).
-
-| `i2.n2` | Contents | Canonical rendering |
-| --- | --- | --- |
-| `0.0` | CQ call action | `CQ <call> CQ` |
-| `0.1` | CALL action | `<call>` |
-| `0.2` | TU/CQ call action | `TU <call> CQ` |
-| `0.3` | CALL/TU action | `<call> TU` |
-| `1.0` | CALL/AGN call action | `<call> AGN?` |
-| `1.1` | TU NOW/CALL action | `TU NOW <call>` |
-| `1.2`, `1.3` | Reserved | Invalid in version 1 |
-| `2` | STRUCT30 | Typed exchange, pair, time, control, or GRID4 atom |
-| `3` | TEXT5 | Five six-bit JTTY characters |
-
-STRUCT30 places a 27-bit family body before a three-bit family selector:
-
-| Family | Name | Fields, in transmitted bit order |
-| --- | --- | --- |
-| `000` | EXCH_NUM | `role1 + number_kind4 + value17 + zero5` |
-| `001` | EXCH_LOC | `role1 + location_kind4 + length1 + base36_token16 + zero5` |
-| `010` | EXCH_PAIR | `pair_schema3 + pair_data23 + zero1` |
-| `011` | EXCH_NUM_TIME | `role1 + serial14 + minute_of_day11 + zero1` |
-| `100` | MISC | `subtype4 + subtype_data23` |
-| `101` | Profiled/dense extension | Reserved |
-| `110` | Versioned extension | Reserved |
-| `111` | Guard space | Invalid |
-
-The assigned fields cover serials, zones, ages, power, checks, four-digit first-license years, generic numbers, two- or three-character locations, zone/location pairs, Field Day class/section pairs, serial/time pairs, GRID4, and 18 common control phrases. Native values render canonically: serials use at least three digits, zones and checks at least two, UTC time exactly four, and license years exactly four. A full exchange adds `599`; a field-only atom omits it. Decimal width, separator style, `5NN` spelling, and visible repetition do not consume wire bits.
-
-The former `i2=2` meaning, literal `599 ` followed by five characters, has been intentionally replaced by STRUCT30. There is no discriminator: old receivers display new STRUCT30 bits as `599` text, and some old type-2 frames are valid new STRUCT30 words with different meanings. JTTY is unreleased, so there is no legacy decoder mode. Automatic packing uses only the current grammar; unrecognized `599 ...` text remains available through TEXT5.
-
-## Native function keys
+A source atom carries a compact callsign action, a typed STRUCT30 exchange or control, or five TEXT5 characters. STRUCT30 covers numeric and location fields, paired exchanges, UTC time, grids, and common control phrases. Typed atoms have canonical renderings; formatting choices and visible repetition do not consume wire bits.
-Current native templates and control phrases match after case folding and
-whitespace normalization, before placeholders are expanded. The three
-superseded serial templates are accepted only in their exact saved-default
-form so edited variants remain literal.
+The bit layouts, field ranges, enum assignments, validity rules, and golden vectors are kept in [jtty_source_encoding.txt](jtty_source_encoding.txt).
-| Key | Template | Native meaning |
-| --- | --- | --- |
-| F1 | `CQ %M CQ` | CQ with the configured call |
-| F2 | `%H %E` | His call, then configured full exchange |
-| F3 | `%H TU CQ %M CQ` | His call/TU, then CQ with the configured call |
-| F4 | `%M` | Configured call |
-| F5 | `%H` | His call |
-| F6 | `TU NOW %Q %E` | Queued call, then configured full exchange |
-| F7 | `%H AGN?` | Request repeat from his call |
-| F8 | `%E` | Configured full exchange |
-
-Keyboard shortcuts and the clickable F1-F8 buttons select the same actions. Native atom sequences use an implicit single-space separator and set EOM only on the last atom. Consecutive queued native messages do not need an intervening TEXT5 space frame.
+## Native function keys
-`%E` parses the selected contest profile: the default is a decimal serial, FIELD_DAY is exactly `<count><class> <section>`, and RTTY is a decimal serial or canonical two- or three-character state/province. `%G` is a field-only GRID4; the exact `599 %G` template selects its full-exchange role. The exact old F2, F6, and F8 defaults using `599 %N` remain recognized during migration and are replaced only when unchanged in saved settings. Edited variants remain literal.
+Keyboard shortcuts and the clickable F1-F8 buttons select the same actions. `%E` supplies the configured contest exchange and `%G` a grid. The default templates, profile rules, and saved-template migration are defined in the specification's "Native function keys" section.
The practical native GUI and N1MM transmit subset covers Call8, serial or RTTY state/province exchanges, Field Day class/section, GRID4, and registered control phrases. Automatic text packing additionally uses GENERIC_NUMERIC and GENERIC_QTH without assigning contest-specific meanings. Other normative STRUCT30 types are decoded, validated, and rendered canonically but are not inferred from text or exposed as general-purpose macros yet.
## Tagged N1MM actions
-N1MM may explicitly request native encoding by starting TXTEXT with `[[JTTY:<ACTION>]]`. The assigned actions are `CQ`, `CALL_EXCH`, `CALL_TU_CQ`, `MYCALL`, `HISCALL`, `TU_NOW_EXCH`, `CALL_MY`, `CALL_TU_MY`, `EXCH`, `GRID`, and `CONTROL`. N1MM expands `{MYCALL}`, `!` or `{CALL}`, and `{EXCH}` before WSJT-X validates the action payload under the active profile.
+N1MM may explicitly request native encoding by starting TXTEXT with `[[JTTY:<ACTION>]]`. N1MM expands its macros before WSJT-X validates the action payload under the active profile.
Untagged N1MM text remains literal. A malformed tag, unknown action, invalid call, invalid exchange or grid, unregistered control phrase, or profile mismatch is rejected rather than transmitted as literal bracket text. The exact grammar and action payloads are in [jtty_source_encoding.txt](jtty_source_encoding.txt), with operating examples in [jtty_n1mm_integration.md](jtty_n1mm_integration.md).
diff --git a/lib/jtty/jtty_design.txt b/lib/jtty/jtty_design.txt
deleted file mode 100644
index b117e77c..00000000
--- a/lib/jtty/jtty_design.txt
+++ /dev/null
@@ -1,231 +0,0 @@
-JTTY: A possible WSJT mode for fast RTTY-like contest exchanges
-
-JTTY aims for an operational feel similar to conventional amateur RTTY,
-with much better weak-signal performance and a much lower error rate.
-Transmissions may start at any time and normally last a few seconds.
-
-FRAME AND WAVEFORM
-
-Each frame carries 32 message-grammar bits, a reserved-zero bit, and a
-universal end-of-message bit. A 12-bit CRC extends the payload to 46 bits.
-A tail-biting rate-1/2 convolutional code with constraint length K=10
-produces 92 coded bits.
-
-JTTY uses Gaussian-smoothed four-tone frequency-shift keying (4-GFSK).
-A frame has 13 synchronization symbols followed by 46 coded symbols.
-At 12000/384 = 31.25 baud, one frame lasts 1.888 seconds. Nominal
-half-power bandwidth is 125 Hz.
-
-The receiver verifies FEC, CRC, the universal reserved-zero bit, and the
-complete source grammar. An invalid source word is discarded before it can
-be displayed, mark EOM, create a receive slot, or participate in signal
-subtraction.
-
-SOURCE CONTRACTS
-
-Ordinary keyboard text, sjtty input, externally queued strings, and untagged
-N1MM/MMTTY text use the literal source interface. After uppercase and space
-normalization and replacement of unsupported characters with '#', automatic
-packing selects the minimum-frame combination of recognized compact atoms
-and TEXT5 that preserves the normalized text exactly. Explicit RTTY Roundup
-also applies serial normalization below before packing. "Literal" identifies
-the text interface, not a requirement to use TEXT5 or bypass that normalization.
-
-The eight shipped JTTY function-key templates are explicit native actions.
-Their call, profile-exchange, and grid placeholders compile to typed atoms. A
-customized template that does not match a native form uses automatic text
-packing after normal placeholder expansion. If a recognized native template
-has invalid runtime data,
-transmission is rejected instead of changing meaning through a literal
-fallback.
-
-Earlier JTTY packing minimized frames using compact calls, a generic "599 "
-plus five-character format, and TEXT5. STRUCT30 replaced that exchange format
-with richer typed atoms. Restricting ordinary input to TEXT5 avoided guessing
-whether "05" meant a serial, zone, or check, but also lost unambiguous call
-compaction. Automatic packing retains the minimum-frame algorithm with
-context-free recognition and an explicit exchange profile that can normalize
-serials and enable additional typed candidates.
-
-AUTOMATIC TEXT PACKING
-
-At complete token boundaries the packer considers:
-
- * The six call forms below, with an exact standard-call codec round trip.
- * Registered CONTROL phrases, including inside longer messages.
- * Canonical unsigned decimal 0-131071 as GENERIC_NUMERIC, field-only or
- preceded by "599 ". Leading zeros are not canonical except for "0".
- * "599 " plus a canonical two- or three-character base-36 token containing
- at least one letter, as GENERIC_QTH. The wire length rules apply.
- * Valid four-character Maidenhead GRID4, field-only or preceded by "599 ".
- * CLASS_SECTION: count 1-32, class A-F, registered ARRL/RAC section.
-
-Every candidate must pass codec pack/unpack validation and render exactly as
-its span in the normalized text. At submission the GUI captures Unknown,
-Field Day, or RTTY
-Roundup from the existing special operating activity. No activity means
-Unknown even though native macros default to serial exchanges. All profiles
-retain the context-free candidates above; Field Day adds no further candidates.
-
-Only RTTY Roundup adds full "599 <number>" SERIAL and full "599 <location>"
-STATE_PROVINCE candidates under the native exchange rules. Locations must
-contain a letter. Exact rendering after profile normalization remains
-mandatory; bare serials are never
-inferred. Zone, check, age, power, license-year, other specific location,
-zone/location, and serial/time meanings are not inferred. No new configuration
-or wire format is needed. Native actions retain their typed exchange semantics.
-
-Before packing, explicit RTTY Roundup canonicalizes a decimal token following
-a complete "599" token as a serial: "599 05" becomes "599 005", and
-"599 0123" becomes "599 123". Tokens must contain one to six digits and have
-value 0-131071. Unsupported tokens retain their spelling for normal fallback.
-Bare digits and Unknown or Field Day input retain their spelling after ordinary
-normalization. The canonical message is returned to the GUI for display and
-logging. Expansion beyond 80 characters is rejected rather than truncated.
-
-A dynamic program over source-character offsets chooses the minimum number
-of frames under this recognition policy, rather than a greedy sequence.
-TEXT5 consumes exactly five characters except at the end. Interior padding
-cannot be used to reach a compact candidate because it would change the text.
-Structured candidates consume one source space after their rendered span
-when another token follows, matching the receiver's implicit separator.
-Equal-cost choices prefer a structured atom, then the longest consumed span,
-then ascending atom kind/subtype/role.
-The subtype ordering prefers typed serial and state/province candidates over
-generic candidates of equal frame count and span under RTTY Roundup.
-
-This minimum need not equal the theoretical minimum with perfect knowledge
-of contest semantics. Examples for ordinary text under Unknown or Field Day,
-without a native action:
-
---------------------------------------------------------------------------------
-Text Frames Encoding or limitation
---------------------------------------------------------------------------------
-CQ K1ABC CQ 1 CQ call
-CQ KA1ABC CQ 1 CQ call
-WB9XYZ 1 Call
-WB9XYZ TU CQ KA1ABC CQ 2 Two call atoms
-WB9XYZ 599 123 2 Call plus generic number
-599 123 1 Generic numeric exchange
-599 MA 1 Generic QTH exchange
-599 FN42 1 Full-role GRID4
-1D EMA 1 Class/section pair
-599 001 2 Leading zeros must be preserved
-599 05 2 No numeric kind is inferred
-599 BRUCE 2 No generic five-character exchange
---------------------------------------------------------------------------------
-
-Under RTTY Roundup, "599 001" takes one frame and "K1ABC 599 001" takes two.
-"599 123" and "599 MA" use SERIAL and STATE_PROVINCE instead of generic atoms
-without changing frame counts. "599 05" and "599 0123" become "599 005" and
-"599 123", each in one frame.
-
-sjtty defaults to Unknown. Its optional leading argument
---exchange-profile=unknown|field-day|rtty-roundup applies to both the
-one-message packing invocation and the eight-argument waveform invocation.
-Invalid values are errors. Example:
-
- sjtty --exchange-profile=rtty-roundup "599 001"
-
-SOURCE GRAMMAR
-
---------------------------------------------------------------------------------
-i2.n2 Example Bits Purpose
---------------------------------------------------------------------------------
-0.0 CQ K1ABC CQ call28 + n2 CQ call action
-0.1 K1ABC call28 + n2 CALL action
-0.2 TU K1ABC CQ call28 + n2 TU/CQ action
-0.3 K1ABC TU call28 + n2 CALL/TU action
-1.0 K1ABC AGN? call28 + n2 CALL/AGN action
-1.1 TU NOW K1ABC call28 + n2 TU NOW/CALL action
-1.2 (reserved; invalid)
-1.3 (reserved; invalid)
-2 599 123 body27 + family3 STRUCT30
-3 HELLO 6 6 6 6 6 TEXT5
---------------------------------------------------------------------------------
-
-Bits 1-30 contain the form listed above and bits 31-32 contain i2. Bit 33
-is always zero. Bit 34 is one only on the final atom of a source message.
-
-STRUCT30 replaces the former i2=2 "599 " plus five-character form:
-
---------------------------------------------------------------------------------
-Family Name Body fields, in transmitted bit order
---------------------------------------------------------------------------------
-000 EXCH_NUM role1 kind4 value17 zero5
-001 EXCH_LOC role1 kind4 length1 token16 zero5
-010 EXCH_PAIR schema3 pair_data23 zero1
-011 EXCH_NUM_TIME role1 serial14 minute11 zero1
-100 MISC subtype4 subtype_data23
-101 PROFILED reserved; invalid in version 1
-110 VERSIONED reserved; invalid in version 1
-111 INVALID source-validity guard space
---------------------------------------------------------------------------------
-
-EXCH_NUM kinds 0-7 are serial, CQ zone, ITU zone, age, power, check,
-first-license year, and generic numeric. EXCH_LOC kinds 0-4 are
-state/province, ARRL/RAC section, country/prefix, generic QTH, and local
-administrative code. EXCH_PAIR schemas are ZONE_LOC3 and CLASS_SECTION.
-MISC subtypes are CONTROL and GRID4. All other IDs are invalid.
-
-Full-role fields render with a "599 " prefix; field-only fields omit it.
-Serials use at least three digits, zones and checks at least two, UTC time
-exactly four, and first-license year exactly four. Structured atoms supply
-one implicit trailing space; TEXT5 characters are appended verbatim. Final
-trailing spaces and TEXT5 padding are not displayed. Formatting choices and
-visible repetitions are not encoded in typed fields.
-
-NATIVE FUNCTION KEYS
-
---------------------------------------------------------------------------------
-Key Template Native atoms
---------------------------------------------------------------------------------
-F1 CQ %M CQ CQ(my_call)
-F2 %H %E CALL(his_call), configured full exchange
-F3 %H TU CQ %M CQ CALL_TU(his_call), CQ(my_call)
-F4 %M CALL(my_call)
-F5 %H CALL(his_call)
-F6 TU NOW %Q %E TU_NOW_CALL(queue_call), configured exchange
-F7 %H AGN? CALL_AGN(his_call)
-F8 %E configured full exchange
---------------------------------------------------------------------------------
-
-Current templates and control phrases match case-insensitively while ignoring
-whitespace differences, before placeholder expansion. Superseded serial
-templates match only in their exact saved-default form. Keyboard F1-F8
-shortcuts and clickable buttons select the same actions. EOM is set only on
-the final native atom; queued native messages do not require a TEXT5 spacing
-frame between them.
-
-%E uses the selected profile: decimal serial by default, exact
-"<count><class> <section>" for FIELD_DAY, and either decimal serial or a
-canonical two- or three-character state/province for RTTY. %G is field-only
-GRID4; the exact "599 %G" template selects full role. Exact old F2, F6, and F8
-defaults using 599 %N remain recognized during migration and are replaced only
-when unchanged in saved settings; edited variants remain literal.
-
-N1MM can opt into native encoding with a leading [[JTTY:<ACTION>]] marker in
-TXTEXT. Actions are CQ, CALL_EXCH, CALL_TU_CQ, MYCALL, HISCALL, TU_NOW_EXCH,
-CALL_MY, CALL_TU_MY, EXCH, GRID, and CONTROL. Untagged N1MM strings use the
-literal source interface with automatic text packing.
-Invalid or unknown tagged requests are rejected, not transmitted as bracket
-text. See jtty_source_encoding.txt and jtty_n1mm_integration.md for the payload
-grammar.
-
-The practical native transmit subset is Call8, serial and RTTY state/province,
-Field Day class/section, GRID4, and registered controls. Automatic text packing
-also generates GENERIC_NUMERIC and GENERIC_QTH. Other normative atoms have
-canonical receive decoding and rendering but are not inferred from text or
-exposed as general-purpose macros in this version.
-
-The complete normative source definition, field ranges, enum assignments,
-validation rules, and binary/hex vectors are in jtty_source_encoding.txt.
-
-COMPATIBILITY
-
-The old i2=2 form is intentionally incompatible with STRUCT30. There is no
-version discriminator: old receivers display new STRUCT30 bits as "599" text,
-and some old type-2 frames are valid new STRUCT30 words with different
-meanings. JTTY is unreleased, so no legacy decoder mode is retained. Automatic
-packing uses only the current grammar; unrecognized "599 ..." text remains
-available through TEXT5.
diff --git a/lib/jtty/jtty_mdecode.f90 b/lib/jtty/jtty_mdecode.f90
index 4f77d51f..8af7f3f6 100644
--- a/lib/jtty/jtty_mdecode.f90
+++ b/lib/jtty/jtty_mdecode.f90
@@ -1,6 +1,6 @@
module jtty_mdec
- use iso_fortran_env, only: int64
+ use iso_fortran_env, only: int64, real64
use iso_c_binding, only: c_ptr,c_null_ptr,c_associated,c_f_pointer, &
c_float_complex,c_size_t
use jtty_mod, only: MAX_FRAMES
@@ -13,7 +13,7 @@ module jtty_mdec
type :: decode
real :: f1 = 0.0 !Synced audio frequency
real :: xdt = 0.0 !Synced DT (0 to 0.5 s)
- real :: tsync = 0.0 !Time of sync from istart=1
+ real(real64) :: tsync = 0.0_real64
real :: snrdb = 0.0 !SNR of decoded frame
character(len=80) :: decoded = ''
logical :: trailing_sep = .false. !decoded ends with an implicit separator column
@@ -23,8 +23,9 @@ module jtty_mdec
type :: message_assembly
integer(int64) :: message_id = 0_int64
real :: f1 = 0.0
- real :: tsync = 0.0
- real :: start_tsync = 0.0
+ real(real64) :: tsync = 0.0_real64
+ real(real64) :: start_tsync = 0.0_real64
+ real :: start_snrdb = 0.0 !SNR of the message's first frame; never reassigned after
integer :: k = 0
character(len=80) :: decoded = ''
logical :: trailing_sep = .false.
@@ -32,15 +33,18 @@ module jtty_mdec
type :: frame_fingerprint
real :: f1 = 0.0
- real :: tsync = 0.0
+ real(real64) :: tsync = 0.0_real64
end type frame_fingerprint
type :: message_update
integer(int64) :: message_id = 0_int64
real :: f1 = 0.0
- real :: start_tsync = 0.0
+ real(real64) :: start_tsync = 0.0_real64
+ real(real64) :: latest_tsync = 0.0_real64
+ real :: snr = 0.0
character(len=80) :: decoded = ''
logical :: complete = .false.
+ integer :: terminal = 0
end type message_update
integer, parameter :: MAX_DECODES = 100
@@ -52,12 +56,20 @@ module jtty_mdec
real, parameter :: FRAME_HISTORY_FREQ_TOLERANCE = 3.0
real, parameter :: NEAR_SIMULTANEOUS_FREQ_TOLERANCE = 12.0
real, parameter :: CONTINUATION_TIME_TOLERANCE = 0.1
+ ! pn leaks ~SNR_LEAKAGE_K*pt of signal power; corrected ratio still asymptotes near (1-k)/k for very strong signals.
+ real, parameter :: SNR_LEAKAGE_K = 0.048
+ real, parameter :: SNR_FLOOR_DB = -17.0 ! weaker than the weakest sometimes-decodable JTTY signal
integer :: ndecodes = 0
integer :: nactive = 0
integer :: nrecent = 0
integer :: npending = 0
integer :: pending_first = 1
integer(int64) :: next_message_id = 1_int64
+ integer, parameter :: UPDATE_GROWING=0, UPDATE_COMPLETE=1
+ integer, parameter :: UPDATE_EXPIRED=2, UPDATE_RECEPTION_ENDED=3
+ integer(int64) :: sample_origin = 0_int64
+ integer(int64) :: first_search_sample = 0_int64
+ logical :: explicit_receive_context = .false.
type(message_assembly) :: active_messages(MAX_ACTIVE_MESSAGES)
type(frame_fingerprint) :: recent_frames(MAX_RECENT_FRAMES)
type(message_update), allocatable :: pending_updates(:)
@@ -68,11 +80,11 @@ module jtty_mdec
integer, parameter :: MAX_SUBTRACTED = 16
logical :: interferer_pending = .false.
real :: interferer_f1 = 0.0
- real :: interferer_tsync = 0.0
+ real(real64) :: interferer_tsync = 0.0_real64
integer :: interferer_payload(PAYLOAD_BITS) = 0
integer :: nsubtracted = 0
real :: subtracted_f1(MAX_SUBTRACTED) = 0.0
- real :: subtracted_tsync(MAX_SUBTRACTED) = 0.0
+ real(real64) :: subtracted_tsync(MAX_SUBTRACTED) = 0.0_real64
integer :: subtracted_payload(PAYLOAD_BITS,MAX_SUBTRACTED) = 0
complex, allocatable, private :: sync_chirp_weights(:),sync_chirp_kernel(:)
integer, private :: sync_chirp_samples=0,sync_chirp_first_bin=-1
@@ -90,6 +102,10 @@ module jtty_mdec
integer, parameter, private :: MIN_SYNC_FFT_ORDER=11,MAX_SYNC_FFT_ORDER=13
type(sync_fft_cache), private :: sync_fft_caches(MIN_SYNC_FFT_ORDER:MAX_SYNC_FFT_ORDER)
+ interface prune_receive_state
+ module procedure prune_receive_state_real64, prune_receive_state_real32
+ end interface
+
contains
subroutine release_sync_fft_cache(cache)
@@ -217,6 +233,12 @@ contains
sync_chirp_output_count=0
end subroutine jtty_release_fft_resources
+ pure real(real64) function sample_time(index)
+ integer, intent(in) :: index
+
+ sample_time=real(sample_origin+int(index-1,int64),real64)/12000.0_real64
+ end function sample_time
+
subroutine reset_decode_search_state()
nactive=0
nrecent=0
@@ -228,14 +250,16 @@ contains
end subroutine discard_pending_updates
pure logical function same_frame(f1_a,tsync_a,f1_b,tsync_b)
- real, intent(in) :: f1_a,tsync_a,f1_b,tsync_b
+ real, intent(in) :: f1_a,f1_b
+ real(real64), intent(in) :: tsync_a,tsync_b
same_frame=abs(f1_a-f1_b).lt.FRAME_HISTORY_FREQ_TOLERANCE .and. &
abs(tsync_a-tsync_b).lt.FRAME_HISTORY_TIME_TOLERANCE
end function same_frame
pure logical function same_recent_frame(f1_a,tsync_a,f1_b,tsync_b)
- real, intent(in) :: f1_a,tsync_a,f1_b,tsync_b
+ real, intent(in) :: f1_a,f1_b
+ real(real64), intent(in) :: tsync_a,tsync_b
same_recent_frame=abs(f1_a-f1_b).lt.NEAR_SIMULTANEOUS_FREQ_TOLERANCE .and. &
abs(tsync_a-tsync_b).lt.FRAME_HISTORY_TIME_TOLERANCE
@@ -283,11 +307,16 @@ contains
recent_frames(nrecent)%tsync=candidate%tsync
end subroutine remember_recent_frame
- subroutine queue_message_update(message,complete)
+ subroutine queue_message_update(message,complete,terminal)
type(message_assembly), intent(in) :: message
logical, intent(in) :: complete
+ integer, optional, intent(in) :: terminal
type(message_update), allocatable :: grown(:)
- integer :: i,index,new_capacity
+ integer :: i,index,new_capacity,status
+
+ status=UPDATE_GROWING
+ if(complete) status=UPDATE_COMPLETE
+ if(present(terminal)) status=terminal
do i=0,npending-1
index=pending_first+i
@@ -295,6 +324,8 @@ contains
pending_updates(index)%f1=message%f1
pending_updates(index)%decoded=message%decoded
pending_updates(index)%complete=complete
+ pending_updates(index)%latest_tsync=message%tsync
+ pending_updates(index)%terminal=status
return
endif
enddo
@@ -318,8 +349,11 @@ contains
pending_updates(index)%message_id=message%message_id
pending_updates(index)%f1=message%f1
pending_updates(index)%start_tsync=message%start_tsync
+ pending_updates(index)%latest_tsync=message%tsync
+ pending_updates(index)%snr=message%start_snrdb
pending_updates(index)%decoded=message%decoded
pending_updates(index)%complete=complete
+ pending_updates(index)%terminal=status
end subroutine queue_message_update
subroutine remove_active_message(index)
@@ -344,6 +378,7 @@ contains
message%f1=candidate%f1
message%tsync=candidate%tsync
message%start_tsync=candidate%tsync
+ message%start_snrdb=candidate%snrdb
message%decoded=candidate%decoded
if(message%decoded(1:4).eq.'599 ') &
message%decoded='~'//trim(message%decoded)
@@ -403,9 +438,10 @@ contains
accepted=.true.
end subroutine append_active_message
- subroutine prune_receive_state(forward_tsync,frame_period)
- real, intent(in) :: forward_tsync,frame_period
- real :: oldest_revisit
+ subroutine prune_receive_state_real64(forward_tsync,frame_period)
+ real(real64), intent(in) :: forward_tsync
+ real, intent(in) :: frame_period
+ real(real64) :: oldest_revisit
integer :: i,keep
oldest_revisit=forward_tsync-real(MAX_RETRO_STEPS)*frame_period/4.0
@@ -424,13 +460,19 @@ contains
if(oldest_revisit-active_messages(i)%tsync.gt. &
real(MAX_CONTINUATION_GAP)*frame_period+ &
CONTINUATION_TIME_TOLERANCE) then
- call queue_message_update(active_messages(i),.false.)
+ call queue_message_update(active_messages(i),.false.,UPDATE_EXPIRED)
call remove_active_message(i)
else
i=i+1
endif
enddo
- end subroutine prune_receive_state
+ end subroutine prune_receive_state_real64
+
+ subroutine prune_receive_state_real32(forward_tsync,frame_period)
+ real, intent(in) :: forward_tsync,frame_period
+
+ call prune_receive_state_real64(real(forward_tsync,real64),frame_period)
+ end subroutine prune_receive_state_real32
subroutine jtty_tbcc_reencode_for_subtraction(payload, tones)
integer, intent(in) :: payload(PAYLOAD_BITS)
integer, intent(out) :: tones(TOTAL_K)
@@ -474,7 +516,8 @@ contains
real, intent(in) :: frame_period
logical, intent(out) :: match,is_window_dupe
integer, intent(out) :: nframes_gap
- real :: df1,dtsync,qstep,resid,fp_resid,df_tol
+ real :: df1,df_tol
+ real(real64) :: dtsync,qstep,resid,fp_resid
integer :: nstep,nfp
df1=candidate%f1-existing%f1
@@ -546,10 +589,11 @@ contains
integer :: nsloc(2),nfz,ntz,ncand,ic,nc,nstep_search
integer :: nc0,n_ch0_ok
integer :: ja_ch0_ok(16),jb_ch0_ok(16)
- real :: f1_ch0_ok(16),tsync_ch0_ok(16)
+ real :: f1_ch0_ok(16)
+ real(real64) :: tsync_ch0_ok(16)
integer :: nsync,nsymerrs
real :: fc,fwid
- real :: fpk,pa,pt,pn
+ real :: fpk,pa,pt,pn,pn_corrected
real :: fbest,xdtbest
real :: xdt_retry
real, allocatable, save :: s0(:,:)
@@ -581,7 +625,8 @@ contains
type(decode) :: cand(MAXCAND) !Candidates for decoding
type(decode) :: dec !Current successful decode
logical :: use_interferer
- real :: use_interferer_f1, use_interferer_tsync
+ real :: use_interferer_f1
+ real(real64) :: use_interferer_tsync
integer :: use_interferer_payload(PAYLOAD_BITS)
! Capture and clear the retro-resweep interferer request (if any) as the
@@ -596,7 +641,7 @@ contains
nsync=0
- if(istart.eq.istart0 .and. .not.use_interferer) then
+ if(istart.eq.istart0 .and. .not.use_interferer .and. .not.explicit_receive_context) then
ndecodes=0
call reset_decode_search_state()
endif
@@ -666,7 +711,7 @@ contains
call jtty_tbcc_reencode_for_subtraction(use_interferer_payload, tone_symbols_chk)
tone_symbols_full(NSYNC_SYM+1:NFRAME_SYM)=tone_symbols_chk
call subtract_jtty(c0, nana, nchunk6, tone_symbols_full, NFRAME_SYM, &
- nss, use_interferer_f1, use_interferer_tsync-(istart-1)/12000.0)
+ nss, use_interferer_f1, real(use_interferer_tsync-sample_time(istart)))
endif
! Look for up to 2 sync candidates in each quarter-frame (0.424 second) by 2*FTol rectangle in
@@ -974,13 +1019,13 @@ contains
do ir=1,nactive
if(active_messages(ir)%f1.lt.fc-fwid .or. &
active_messages(ir)%f1.gt.fc+fwid) cycle
- if(abs(((istart-1)/12000.0 - active_messages(ir)%tsync) - &
+ if(abs((sample_time(istart) - active_messages(ir)%tsync) - &
nframe6/6000.0) &
.gt. 0.1) cycle
! Derive the local offset from absolute sync time because the
! assembly may have been updated from a different decode window.
xdt_retry=active_messages(ir)%tsync + nframe6/6000.0 - &
- (istart-1)/12000.0
+ sample_time(istart)
if(xdt_retry.lt.0.0) cycle
if(ncand .ge. MAXCAND) exit
ncand=ncand+1
@@ -1063,10 +1108,11 @@ contains
enddo
pn=(pa-pt)/3.0
if(pn.gt.0.) then
- snrdb=db(pt/pn)
+ ! Solve pt=S+N, pn=N+SNR_LEAKAGE_K*S for S/N
+ snrdb=max(db((pt-pn)/pn) - db(2500.0/baud), SNR_FLOOR_DB)
cand(ncand)%snrdb=snrdb
endif
- cand(ncand)%tsync=(istart-1)/12000.0 + cand(ncand)%xdt
+ cand(ncand)%tsync=sample_time(istart) + real(cand(ncand)%xdt,real64)
decoded_ok=.true.
! dupe detection
@@ -1189,12 +1235,12 @@ contains
real, intent(in) :: f0, ftol, smin
integer :: n_local, nframe, step, istart_prev, k, i
real :: f1_local(MAX_SUBTRACTED)
- real :: tsync_local(MAX_SUBTRACTED)
+ real(real64) :: tsync_local(MAX_SUBTRACTED)
integer :: payload_local(PAYLOAD_BITS,MAX_SUBTRACTED)
nframe=59*nsps
step=nframe/4
- call prune_receive_state((istart-1)/12000.0,nframe/12000.0)
+ call prune_receive_state(sample_time(istart),nframe/12000.0)
interferer_pending=.false. ! defensive: no stale interferer input
call jtty_mdecode(istart,istart0,iwave(istart),nchunk,nsps,ndebug,nfa,nfb, &
@@ -1213,6 +1259,9 @@ contains
do k=1,MAX_RETRO_STEPS
istart_prev=istart-k*step
if(istart_prev.lt.1) cycle
+ if(explicit_receive_context) then
+ if(sample_origin+int(istart_prev-1,int64).lt.first_search_sample) cycle
+ endif
interferer_pending=.true.
interferer_f1=f1_local(i)
interferer_tsync=tsync_local(i)
diff --git a/lib/jtty/jtty_mod.f90 b/lib/jtty/jtty_mod.f90
index 7ff25b5b..e043552f 100644
--- a/lib/jtty/jtty_mod.f90
+++ b/lib/jtty/jtty_mod.f90
@@ -8,7 +8,7 @@ module jtty_mod
contains
-subroutine pack_jtty(message,c32,nframes,exchange_profile)
+subroutine pack_jtty(message,c32,nframes,exchange_profile,frame_starts,is_final)
! Input: character*80 message !JTTY message, as it appears to a user
! Output: character*34 c32 !34-bit payload: 32 bits of existing
@@ -19,6 +19,10 @@ subroutine pack_jtty(message,c32,nframes,exchange_profile)
! !uses as a free extra check beyond
! !the CRC.
! integer nframes !Frames in this message (max = 16)
+! integer frame_starts(MAX_FRAMES), optional
+! !1-indexed start column of each frame's source text in the normalized message (a structured atom's span runs through its trailing separator space).
+! integer is_final, optional
+! !0/1; suppresses the "last frame of message" flag even on the final frame when 0 (absent means final, the existing behavior).
!
! Minimize frames after alphabet and exchange-profile normalization.
@@ -27,6 +31,8 @@ subroutine pack_jtty(message,c32,nframes,exchange_profile)
character*80 message,msg
character*34 c32(MAX_FRAMES)
integer, intent(in), optional :: exchange_profile
+ integer, intent(out), optional :: frame_starts(MAX_FRAMES)
+ integer, intent(in), optional :: is_final
integer, parameter :: INF=999
type(jtty_source_atom) :: choice(80),atoms(MAX_FRAMES)
integer :: dp(81),successor(80),n,ipos,inext,natoms,nframes,profile
@@ -75,9 +81,10 @@ subroutine pack_jtty(message,c32,nframes,exchange_profile)
do while(ipos.le.n)
natoms=natoms+1
atoms(natoms)=choice(ipos)
+ if(present(frame_starts)) frame_starts(natoms)=ipos
ipos=successor(ipos)
enddo
- call pack_jtty_atoms(atoms,natoms,c32,nframes,valid)
+ call pack_jtty_atoms(atoms,natoms,c32,nframes,valid,is_final)
if(.not.valid) then
c32=''
nframes=-1
@@ -238,7 +245,7 @@ contains
if(nwords.lt.2 .or. length.lt.2 .or. length.gt.3) return
call decimal_value(words(1)(1:length-1),value,numeric)
if(.not.numeric) return
- section_index=pack77_arrl_section_index(trim(words(2)))
+ section_index=pack77_arrl_section_index(words(2))
call offer(jtty_class_section_atom(value,words(1)(length:length),section_index))
end subroutine try_compact
diff --git a/lib/jtty/jtty_n1mm_integration.md b/lib/jtty/jtty_n1mm_integration.md
index 63125cc9..7b3637c6 100644
--- a/lib/jtty/jtty_n1mm_integration.md
+++ b/lib/jtty/jtty_n1mm_integration.md
@@ -4,7 +4,7 @@
N1MM Logger+ can send either literal JTTY text or an explicit native action. Ordinary TXTEXT uses automatic minimum-frame packing after text and exchange-profile normalization, combining recognized compact forms with TEXT5. Explicit typed exchanges use a leading `[[JTTY:<ACTION>]]` marker in the transmitted text. The marker is consumed by WSJT-X and is never put on the air.
-The bundled `JTTY Messages.mc` uses tagged actions for its common Run and S&P messages. This provides compact Call8 and STRUCT30 transmission without asking WSJT-X to infer meaning from visible logger text.
+The bundled [`JTTY Messages.mc`](JTTY%20Messages.mc) uses tagged actions for its common Run and S&P messages. This provides compact Call8 and STRUCT30 transmission without asking WSJT-X to infer meaning from visible logger text. The action definitions and source-interface rules are kept in [jtty_source_encoding.txt](jtty_source_encoding.txt).
## Setup
@@ -19,47 +19,23 @@ End-to-end validation with N1MM on Windows, including two-radio focus, call sele
## Literal TXTEXT
-N1MM expands logger macros before passing TXTEXT to WSJT-X. An untagged result uses the literal source interface:
+N1MM expands logger macros before passing TXTEXT to WSJT-X. An untagged result uses the literal source interface. Text is folded to uppercase, spaces are normalized, and unsupported characters become `#`. The existing special operating activity supplies a profile captured when each message is submitted. No activity selects Unknown, even though native macros default to serials.
-- lowercase letters become uppercase;
-- leading, trailing, and repeated spaces are removed;
-- unsupported characters become `#`;
-- explicit RTTY Roundup canonicalizes eligible report-prefixed decimal serials;
-- recognized calls, control phrases, generic numbers, full generic QTH exchanges, grids, and class/section pairs compete with TEXT5 for the minimum frame count;
-- every compact candidate must preserve its source text exactly after normalization.
+`CQ N9ADG CQ`, `N9ADG`, `599 123`, `599 MA`, `599 FN42`, and `1D EMA` each use one frame without a tag. RTTY Roundup also normalizes report-prefixed serials: `599 05` becomes `599 005`, and `599 0123` becomes `599 123`, each in one frame. `599 001` takes one frame in RTTY Roundup and two otherwise. The canonical message is returned to the GUI for display and logging.
-`CQ N9ADG CQ`, `N9ADG`, `599 123`, `599 MA`, `599 FN42`, and `1D EMA` each use one frame without a tag. Recognition works at token boundaries inside longer messages as well. The existing special operating activity supplies a profile captured when each message is submitted. No activity selects Unknown, even though native macros default to serials. Field Day uses the same context-free candidates as Unknown.
+The full recognition, normalization, and spacing rules are in the "Automatic text packing" section of [jtty_source_encoding.txt](jtty_source_encoding.txt). More frame-count examples are in [jtty_design.md](jtty_design.md#contest-exchange-example).
-RTTY Roundup additionally recognizes full `599 <number>` SERIAL and full `599 <location>` STATE_PROVINCE exchanges under the native rules; locations must contain a letter. Before packing, decimal tokens following a complete `599` token are normalized as serials: `599 05` becomes `599 005`, and `599 0123` becomes `599 123`, each in one frame. Eligible tokens have one to six digits and value 0-131071. Unsupported tokens keep their spelling for normal fallback. `599 001` takes one frame in RTTY Roundup and two otherwise, and `K1ABC 599 001` takes two in RTTY Roundup.
+## Writing tagged macros
-Bare digits and all Unknown or Field Day input retain their spelling after ordinary text normalization. Every compact candidate must exactly match the resulting normalized text. The canonical message is returned to the GUI for display and logging; expansion beyond 80 characters is rejected rather than truncated. Tagged exchanges retain explicit type semantics. The full recognition policy and spacing constraints are in [`jtty_design.md`](jtty_design.md).
-
-The former `i2=2` shortcut for literal `599 ` plus five characters has been replaced by STRUCT30. There is no compatibility discriminator: an old receiver displays new STRUCT30 bits as `599` text, and some old type-2 frames are valid new STRUCT30 words with a different meaning. JTTY is unreleased, so no legacy decoder mode is retained.
-
-## Tagged TXTEXT grammar
-
-Place the marker so it is the leading transmitted text. Non-transmitting N1MM
-commands may execute between `{TX}` and the marker:
+The marker must begin at the first non-space transmitted character; tag and
+action matching is case-insensitive. Non-transmitting N1MM commands may
+execute between `{TX}` and the marker:
```text
{TX}[[JTTY:<ACTION>]]<payload>{RX}
```
-N1MM expands `{MYCALL}`, `!` or `{CALL}`, and `{EXCH}`. WSJT-X removes the marker, normalizes whitespace and case in the expanded payload, and validates it under the selected action and active JTTY profile. Tag and action matching is case-insensitive, but the tag must start at the first non-space transmitted character.
-
-| Action | Expanded payload | Native sequence |
-| --- | --- | --- |
-| `CQ` | `<mycall>` | CQ with my call |
-| `CALL_EXCH` | `<hiscall> <exchange>` | His call, configured full exchange |
-| `CALL_TU_CQ` | `<hiscall> <mycall>` | His call/TU, CQ with my call |
-| `MYCALL` | `<mycall>` | My call |
-| `HISCALL` | `<hiscall>` | His call |
-| `TU_NOW_EXCH` | `<hiscall> <exchange>` | TU NOW/his call, configured full exchange |
-| `CALL_MY` | `<hiscall> <mycall>` | His call, my call |
-| `CALL_TU_MY` | `<hiscall> <mycall>` | His call/TU, my call |
-| `EXCH` | `<exchange>` | Configured full exchange |
-| `GRID` | `<grid4>` | Field-only GRID4 |
-| `CONTROL` | `<registered phrase>` | Registered control phrase |
+N1MM expands `{MYCALL}`, `!` or `{CALL}`, and `{EXCH}`. WSJT-X removes the marker and validates the expanded payload under the selected action and active JTTY profile. The complete action and payload table is in the specification's "Tagged N1MM TXTEXT" section.
Payloads contain dynamic values, not the phrases implied by an action. For
example, `CQ` receives only the callsign, `CALL_TU_CQ` receives two callsigns,
@@ -67,19 +43,13 @@ and `TU_NOW_EXCH` receives a callsign and exchange. The action supplies `CQ`,
`TU`, `TU NOW`, and canonical full-exchange report text where applicable. Do
not add a hardcoded `599` to an exchange payload.
-Profile exchange payloads are:
-
-- Default: one decimal serial in the 17-bit serial domain.
-- `FIELD_DAY`: exactly `<count><class> <section>`, with count 1-32, class A-F, and a registered ARRL/RAC section.
-- `RTTY`: either one decimal serial or one canonical two- or three-character state/province token. A three-character token may not have a leading zero because its two-character spelling would be canonical.
-
-For tagged N1MM input, `DX` is an expanded two-letter location token. The
-special `DX` and `#` meanings that select the live serial apply only to the
-local WSJT-X RTTY `%E` configuration.
+Under the RTTY profile, an exchange payload is one decimal serial or one
+canonical two- or three-character state/province token. For tagged N1MM
+input, `DX` is an expanded two-letter location token. The special `DX` and
+`#` meanings that select the live serial apply only to the local WSJT-X RTTY
+`%E` configuration.
-`GRID` accepts exactly one valid four-character Maidenhead locator. `CONTROL` accepts exactly one of the 18 registered phrases, including spaces and punctuation where shown in `jtty_source_encoding.txt`.
-
-An unknown or malformed leading JTTY marker, unsupported action, missing field, invalid call, invalid profile exchange, invalid grid, or unregistered control phrase is rejected. It never falls back to literal transmission. Untagged messages, including customized N1MM macros, use automatic text packing with the exchange profile captured at submission. A tag-shaped substring later in the text is just literal text.
+An invalid tagged request is rejected rather than transmitted as literal text. A tag-shaped substring later in the message is just literal text. Check the action's payload and profile rules in the specification when editing a macro.
An all-rejected transaction receives `OUTPUTCOMPLETE` at `XMIT OFF`. When a transaction also contains accepted or pending audio, completion waits until that audio has drained. `ABORT` clears the transaction without reporting a successful output completion.
@@ -114,27 +84,6 @@ intended station and exchange.
## Native WSJT-X function keys
-The WSJT-X JTTY editor offers the same native subset without an N1MM tag. The shipped defaults are:
-
-| Key | Template |
-| --- | --- |
-| F1 | `CQ %M CQ` |
-| F2 | `%H %E` |
-| F3 | `%H TU CQ %M CQ` |
-| F4 | `%M` |
-| F5 | `%H` |
-| F6 | `TU NOW %Q %E` |
-| F7 | `%H AGN?` |
-| F8 | `%E` |
-
-`%E` is the configured profile exchange. `%G` is a field-only GRID4, while the exact template `599 %G` selects full-role GRID4. Current templates and control phrases match before expansion after case and whitespace normalization.
-
-The exact former F2, F6, and F8 defaults (`%H 599 %N`, `TU NOW %Q 599 %N`, and `599 %N`) remain recognized during migration and are replaced by `%E` only when unchanged in saved settings. An edited old default is a customized literal template. Likewise, an unrecognized current template uses automatic text packing after normal expansion. A recognized native template with invalid runtime data is rejected rather than changing semantics through fallback.
-
-Clickable F1-F8 buttons and keyboard shortcuts select the same actions. Native sequences set EOM only on their final atom and do not add a TEXT5 spacing frame between queued messages.
-
-## Current scope
-
-The practical tagged and GUI native transmit subset includes Call8, serial and RTTY state/province exchanges, Field Day class/section, GRID4, and registered controls. Automatic text packing additionally uses GENERIC_NUMERIC and GENERIC_QTH. The full wire codec also validates and canonically renders other STRUCT30 number/location kinds, ZONE_LOC3, and EXCH_NUM_TIME. Those remaining forms are receive-only in the current operator-facing integration unless an explicit native codec caller constructs them; they are not inferred from ordinary text.
+The WSJT-X JTTY editor offers the same native subset without an N1MM tag. Its defaults and placeholder rules are in the "Native function keys" section of [jtty_source_encoding.txt](jtty_source_encoding.txt). Clickable F1-F8 buttons and keyboard shortcuts select the same actions.
-The complete wire definition is in [`jtty_source_encoding.txt`](jtty_source_encoding.txt).
+For checks covering both local function keys and N1MM transactions, see [jtty_tx_manual_checks.md](jtty_tx_manual_checks.md).
diff --git a/lib/jtty/jtty_receive_context.f90 b/lib/jtty/jtty_receive_context.f90
new file mode 100644
index 00000000..aeb43cb5
--- /dev/null
+++ b/lib/jtty/jtty_receive_context.f90
@@ -0,0 +1,297 @@
+module jtty_receive_context
+ use iso_c_binding, only: c_int, c_int16_t, c_int64_t, c_float, c_double, c_char
+ use iso_fortran_env, only: int64, real64
+ use jtty_fec, only: PAYLOAD_BITS
+ use jtty_mdec
+ implicit none
+ private
+
+ type :: receive_state
+ integer :: active_count=0, recent_count=0, pending_count=0, pending_head=1, decode_count=0
+ type(message_assembly) :: active(MAX_ACTIVE_MESSAGES)
+ type(frame_fingerprint) :: recent(MAX_RECENT_FRAMES)
+ type(message_update), allocatable :: pending(:)
+ end type receive_state
+
+ type :: receive_retro_state
+ logical :: active=.false.
+ integer :: count=0, signal=1, step=1
+ real :: frequency(MAX_SUBTRACTED)=0.0
+ real(real64) :: sync_time(MAX_SUBTRACTED)=0.0_real64
+ integer :: payload(PAYLOAD_BITS,MAX_SUBTRACTED)=0
+ end type receive_retro_state
+
+ type :: receive_context
+ logical :: allocated=.false., running=.false.
+ integer :: nsps=384
+ integer(int64) :: session_id=0, grid_origin=0, first_search=0, next_search=0
+ type(receive_state) :: state
+ type(receive_retro_state) :: retro
+ end type receive_context
+
+ integer, parameter :: MAX_CONTEXTS=8
+ type(receive_context), save :: contexts(MAX_CONTEXTS)
+
+ public :: jtty_rx_create, jtty_rx_destroy, jtty_rx_begin, jtty_rx_process
+ public :: jtty_rx_next_required_sample, jtty_rx_next_search_sample
+ public :: jtty_rx_take_updates, jtty_rx_end
+
+contains
+
+ logical function valid_handle(handle)
+ integer(c_int), intent(in) :: handle
+
+ valid_handle=.false.
+ if(handle.lt.1 .or. handle.gt.MAX_CONTEXTS) return
+ valid_handle=contexts(handle)%allocated
+ end function valid_handle
+
+ ! DSP scratch is shared; exchange only persistent reception state between whole steps.
+ subroutine exchange_state(state)
+ type(receive_state), intent(inout) :: state
+ type(message_assembly) :: active_swap(MAX_ACTIVE_MESSAGES)
+ type(frame_fingerprint) :: recent_swap(MAX_RECENT_FRAMES)
+ type(message_update), allocatable :: pending_swap(:)
+ integer :: value
+
+ active_swap=active_messages
+ active_messages=state%active
+ state%active=active_swap
+ recent_swap=recent_frames
+ recent_frames=state%recent
+ state%recent=recent_swap
+ call move_alloc(pending_updates,pending_swap)
+ call move_alloc(state%pending,pending_updates)
+ call move_alloc(pending_swap,state%pending)
+ value=nactive
+ nactive=state%active_count
+ state%active_count=value
+ value=nrecent
+ nrecent=state%recent_count
+ state%recent_count=value
+ value=npending
+ npending=state%pending_count
+ state%pending_count=value
+ value=pending_first
+ pending_first=state%pending_head
+ state%pending_head=value
+ value=ndecodes
+ ndecodes=state%decode_count
+ state%decode_count=value
+ end subroutine exchange_state
+
+ integer(c_int) function jtty_rx_create() bind(C,name='jtty_rx_create')
+ integer :: i
+
+ jtty_rx_create=0
+ do i=1,MAX_CONTEXTS
+ if(contexts(i)%allocated) cycle
+ contexts(i)=receive_context()
+ contexts(i)%allocated=.true.
+ jtty_rx_create=i
+ return
+ enddo
+ end function jtty_rx_create
+
+ subroutine jtty_rx_destroy(handle) bind(C,name='jtty_rx_destroy')
+ integer(c_int), value :: handle
+
+ if(.not.valid_handle(handle)) return
+ contexts(handle)=receive_context()
+ end subroutine jtty_rx_destroy
+
+ subroutine jtty_rx_begin(handle,session_id,grid_origin,first_search,nsps) bind(C,name='jtty_rx_begin')
+ integer(c_int), value :: handle,nsps
+ integer(c_int64_t), value :: session_id,grid_origin,first_search
+ integer(int64) :: start,step
+
+ if(.not.valid_handle(handle)) return
+ call jtty_rx_end(handle,UPDATE_RECEPTION_ENDED)
+ if(nsps.ne.240 .and. nsps.ne.320 .and. nsps.ne.384 .and. nsps.ne.480) return
+ step=int(59*nsps/4,int64)
+ start=max(first_search,grid_origin)
+ start=start+modulo(grid_origin-start,step)
+ contexts(handle)%session_id=session_id
+ contexts(handle)%grid_origin=grid_origin
+ contexts(handle)%first_search=start
+ contexts(handle)%next_search=start
+ contexts(handle)%nsps=nsps
+ contexts(handle)%state%active_count=0
+ contexts(handle)%state%recent_count=0
+ contexts(handle)%state%decode_count=0
+ contexts(handle)%retro=receive_retro_state()
+ contexts(handle)%running=.true.
+ end subroutine jtty_rx_begin
+
+ integer(c_int64_t) function jtty_rx_next_search_sample(handle) bind(C,name='jtty_rx_next_search_sample')
+ integer(c_int), value :: handle
+
+ jtty_rx_next_search_sample=-1_c_int64_t
+ if(.not.valid_handle(handle)) return
+ jtty_rx_next_search_sample=contexts(handle)%next_search
+ end function jtty_rx_next_search_sample
+
+ integer(c_int64_t) function jtty_rx_next_required_sample(handle) bind(C,name='jtty_rx_next_required_sample')
+ integer(c_int), value :: handle
+ integer(int64) :: step
+
+ jtty_rx_next_required_sample=-1_c_int64_t
+ if(.not.valid_handle(handle)) return
+ step=int(59*contexts(handle)%nsps/4,int64)
+ jtty_rx_next_required_sample=max(contexts(handle)%first_search, &
+ contexts(handle)%next_search-int(MAX_RETRO_STEPS,int64)*step)
+ end function jtty_rx_next_required_sample
+
+ integer(c_int) function jtty_rx_process(handle,pcm,count,first_sample,stop_sample,max_steps, &
+ nfa,nfb,f0,ftol) bind(C,name='jtty_rx_process')
+ integer(c_int), value :: handle,count,max_steps,nfa,nfb
+ integer(c_int16_t), intent(in) :: pcm(*)
+ integer(c_int64_t), value :: first_sample,stop_sample
+ real(c_float), value :: f0,ftol
+ integer :: nframe,nchunk,step,index,signal,retro_step
+ integer(int64) :: limit,old_origin,old_first_search,search
+ logical :: old_explicit,performed
+
+ jtty_rx_process=-1
+ if(.not.valid_handle(handle)) return
+ if(.not.contexts(handle)%running .or. count.lt.0) return
+ if(first_sample.gt.jtty_rx_next_required_sample(handle)) then
+ jtty_rx_process=-2
+ return
+ endif
+ jtty_rx_process=0
+ if(max_steps.le.0 .or. count.eq.0) return
+ nframe=59*contexts(handle)%nsps
+ nchunk=nframe+nframe/4
+ step=nframe/4
+ limit=min(stop_sample,first_sample+int(count,int64))
+ old_origin=sample_origin
+ old_first_search=first_search_sample
+ old_explicit=explicit_receive_context
+ sample_origin=first_sample
+ first_search_sample=contexts(handle)%first_search
+ explicit_receive_context=.true.
+ call exchange_state(contexts(handle)%state)
+
+ do while(jtty_rx_process.lt.max_steps)
+ performed=.false.
+ do while(contexts(handle)%retro%active .and. .not.performed)
+ signal=contexts(handle)%retro%signal
+ retro_step=contexts(handle)%retro%step
+ if(signal.gt.contexts(handle)%retro%count) then
+ contexts(handle)%retro=receive_retro_state()
+ contexts(handle)%next_search=contexts(handle)%next_search+int(step,int64)
+ exit
+ endif
+ contexts(handle)%retro%step=retro_step+1
+ if(retro_step.gt.MAX_RETRO_STEPS) then
+ contexts(handle)%retro%signal=signal+1
+ contexts(handle)%retro%step=1
+ cycle
+ endif
+ search=contexts(handle)%next_search-int(retro_step*step,int64)
+ if(search.lt.contexts(handle)%first_search) cycle
+ index=int(search-first_sample)+1
+ if(index.lt.1 .or. index+nchunk-1.gt.count) then
+ jtty_rx_process=-2
+ exit
+ endif
+ interferer_pending=.true.
+ interferer_f1=contexts(handle)%retro%frequency(signal)
+ interferer_tsync=contexts(handle)%retro%sync_time(signal)
+ interferer_payload=contexts(handle)%retro%payload(:,signal)
+ call jtty_mdecode(index,0,pcm(index),nchunk,contexts(handle)%nsps,-1, &
+ nfa,nfb,f0,ftol,4.6)
+ jtty_rx_process=jtty_rx_process+1
+ performed=.true.
+ enddo
+ if(jtty_rx_process.lt.0) exit
+ if(performed) cycle
+ if(contexts(handle)%next_search+int(nchunk,int64).gt.limit) exit
+ index=int(contexts(handle)%next_search-first_sample)+1
+ call prune_receive_state(sample_time(index),real(nframe)/12000.0)
+ interferer_pending=.false.
+ call jtty_mdecode(index,0,pcm(index),nchunk,contexts(handle)%nsps,-1, &
+ nfa,nfb,f0,ftol,4.6)
+ jtty_rx_process=jtty_rx_process+1
+ if(nsubtracted.gt.0) then
+ contexts(handle)%retro%active=.true.
+ contexts(handle)%retro%count=nsubtracted
+ contexts(handle)%retro%signal=1
+ contexts(handle)%retro%step=1
+ contexts(handle)%retro%frequency(1:nsubtracted)=subtracted_f1(1:nsubtracted)
+ contexts(handle)%retro%sync_time(1:nsubtracted)=subtracted_tsync(1:nsubtracted)
+ contexts(handle)%retro%payload(:,1:nsubtracted)=subtracted_payload(:,1:nsubtracted)
+ else
+ contexts(handle)%next_search=contexts(handle)%next_search+int(step,int64)
+ endif
+ enddo
+
+ call exchange_state(contexts(handle)%state)
+ sample_origin=old_origin
+ first_search_sample=old_first_search
+ explicit_receive_context=old_explicit
+ end function jtty_rx_process
+
+ subroutine jtty_rx_end(handle,reason) bind(C,name='jtty_rx_end')
+ integer(c_int), value :: handle,reason
+ integer :: i,terminal
+
+ if(.not.valid_handle(handle)) return
+ if(.not.contexts(handle)%running) return
+ terminal=UPDATE_RECEPTION_ENDED
+ if(reason.eq.UPDATE_EXPIRED) terminal=UPDATE_EXPIRED
+ call exchange_state(contexts(handle)%state)
+ do i=1,nactive
+ call queue_message_update(active_messages(i),.false.,terminal)
+ enddo
+ call reset_decode_search_state()
+ call exchange_state(contexts(handle)%state)
+ contexts(handle)%retro=receive_retro_state()
+ contexts(handle)%running=.false.
+ end subroutine jtty_rx_end
+
+ integer(c_int) function jtty_rx_take_updates(handle,capacity,text,ids,frequencies,starts,latest,terminals,snrs) &
+ bind(C,name='jtty_rx_take_updates')
+ integer(c_int), value :: handle,capacity
+ character(kind=c_char), intent(out) :: text(*)
+ integer(c_int64_t), intent(out) :: ids(*)
+ real(c_float), intent(out) :: frequencies(*)
+ real(c_double), intent(out) :: starts(*),latest(*)
+ integer(c_int), intent(out) :: terminals(*)
+ integer(c_int), intent(out) :: snrs(*)
+ character(len=80) :: message
+ integer :: i,j,index
+
+ jtty_rx_take_updates=0
+ if(.not.valid_handle(handle) .or. capacity.le.0) return
+ associate(state=>contexts(handle)%state)
+ jtty_rx_take_updates=min(capacity,state%pending_count)
+ do i=1,jtty_rx_take_updates
+ index=state%pending_head+i-1
+ message=display_message_text(state%pending(index)%decoded)
+ do j=1,80
+ text((i-1)*80+j)=message(j:j)
+ enddo
+ ids(i)=state%pending(index)%message_id
+ frequencies(i)=state%pending(index)%f1
+ starts(i)=state%pending(index)%start_tsync
+ latest(i)=state%pending(index)%latest_tsync
+ terminals(i)=state%pending(index)%terminal
+ snrs(i)=nint(state%pending(index)%snr)
+ enddo
+ state%pending_head=state%pending_head+jtty_rx_take_updates
+ state%pending_count=state%pending_count-jtty_rx_take_updates
+ if(state%pending_count.eq.0) then
+ state%pending_head=1
+ if(allocated(state%pending)) then
+ if(size(state%pending).gt.MAX_ACTIVE_MESSAGES) then
+ deallocate(state%pending)
+ allocate(state%pending(MAX_ACTIVE_MESSAGES))
+ endif
+ endif
+ endif
+ end associate
+ end function jtty_rx_take_updates
+
+end module jtty_receive_context
diff --git a/lib/jtty/jtty_source_codec.f90 b/lib/jtty/jtty_source_codec.f90
index e73a62ad..0a3f6193 100644
--- a/lib/jtty/jtty_source_codec.f90
+++ b/lib/jtty/jtty_source_codec.f90
@@ -388,18 +388,22 @@ type(jtty_source_atom) function jtty_text5_atom(text) result(atom)
if(n.gt.0) atom%text(1:n)=text(1:n)
end function jtty_text5_atom
-subroutine pack_jtty_atoms(atoms,natoms,frames,nframes,valid)
+subroutine pack_jtty_atoms(atoms,natoms,frames,nframes,valid,is_final)
type(jtty_source_atom), intent(in) :: atoms(:)
integer, intent(in) :: natoms
character(len=34), intent(out) :: frames(:)
integer, intent(out) :: nframes
logical, intent(out) :: valid
+ integer, intent(in), optional :: is_final !0/1; absent means final (existing behavior)
integer :: i
+ logical :: final_ok
frames=''; nframes=0
valid=natoms.ge.1 .and. natoms.le.16 .and. natoms.le.size(atoms) .and. natoms.le.size(frames)
if(.not.valid) return
+ final_ok=.true.
+ if(present(is_final)) final_ok=is_final.ne.0
do i=1,natoms
- call pack_jtty_atom(atoms(i),frames(i),i.eq.natoms,valid)
+ call pack_jtty_atom(atoms(i),frames(i),i.eq.natoms .and. final_ok,valid)
if(.not.valid) then; frames=''; return; endif
enddo
nframes=natoms
diff --git a/lib/jtty/jtty_source_encoding.txt b/lib/jtty/jtty_source_encoding.txt
index efc78c6e..7265e60f 100644
--- a/lib/jtty/jtty_source_encoding.txt
+++ b/lib/jtty/jtty_source_encoding.txt
@@ -1,5 +1,26 @@
JTTY source encoding
+This is the canonical specification for JTTY framing, source encoding, and
+source interfaces. It defines the wire grammar and the rules used by automatic
+text packing, native function keys, and tagged N1MM actions. For a design
+overview and contest examples, see jtty_design.md. N1MM setup and macro
+examples are in jtty_n1mm_integration.md.
+
+Frame and waveform
+
+A transmission contains one or more 1.888-second frames. Each frame carries
+a 34-bit payload. A 12-bit CRC extends this payload to 46 bits. A tail-biting,
+rate-1/2 convolutional code with constraint length K=10 produces 92 coded bits.
+
+The waveform is Gaussian-smoothed four-tone frequency-shift keying (4-GFSK),
+with two coded bits per tone symbol. A frame contains a 13-symbol
+synchronization sequence followed by 46 coded symbols. At 12000/384 = 31.25
+baud, its duration is (13+46)/31.25 = 1.888 seconds. Nominal half-power
+bandwidth is 125 Hz. The occupied bandwidth (99% of transmitted power) is
+127 Hz.
+
+Source bits and validity
+
Each JTTY frame conveys 34 source bits. Bits are numbered from left to right,
most significant first. Bits 1-32 are the message grammar, bit 33 is reserved
and shall be zero, and bit 34 is the universal end-of-message (EOM) flag. EOM
@@ -183,18 +204,21 @@ Canonical atom sequences
Structured atoms are rendered independently and supply one implicit trailing
space; TEXT5 characters are appended verbatim. The final trailing space or
TEXT5 padding is not part of the displayed message. The receiver truncates
-the accumulated display at 80 characters. A sender
-sets bit 33 to zero on every atom and bit 34 only on the last atom. Queuing a
-second native message does not add a TEXT5 spacing atom.
-
-Ordinary keyboard text, externally queued strings, and N1MM/MMTTY strings use
-the literal source interface. They are normalized to uppercase, leading,
-trailing, and repeated ASCII spaces are removed, and unsupported characters
-become '#'. The literal wrapper accepts an 80-character input field, so longer
-caller strings are truncated before normalization. Automatic packing minimizes
-the frame count while preserving this text exactly after any explicit RTTY
-Roundup serial normalization described below. The result is
-at most sixteen frames because TEXT5 is always available as a fallback.
+the accumulated display at 80 characters. A sender sets bit 33 to zero on
+every atom and bit 34 only on the last atom. Queuing a second native message
+does not add a TEXT5 spacing atom.
+
+Automatic text packing
+
+Ordinary keyboard text, sjtty input, externally queued strings, and untagged
+N1MM/MMTTY strings use the literal source interface. They are normalized to
+uppercase, leading, trailing, and repeated ASCII spaces are removed, and
+unsupported characters become '#'. The literal wrapper accepts an 80-character
+input field, so longer caller strings are truncated before normalization.
+Automatic packing minimizes the frame count while preserving this text exactly
+after any explicit RTTY Roundup serial normalization described below. The
+result is at most sixteen frames because TEXT5 is always available as a fallback.
+Unrecognized "599 ..." text remains available through TEXT5.
Candidates at complete token boundaries are:
@@ -210,12 +234,11 @@ Candidates at complete token boundaries are:
Every candidate must pass codec pack/unpack validation and render exactly as
its span in the normalized text. These context-free candidates remain
-available under every
-exchange profile. The GUI captures Unknown, Field Day, or RTTY Roundup from
-the existing special operating activity when a message is submitted. No
-activity means Unknown; the native macro default of SERIAL does not apply to
-automatic text recognition. Field Day adds no candidates because CLASS_SECTION
-is already self-identifying.
+available under every exchange profile. The GUI captures Unknown, Field Day,
+or RTTY Roundup from the existing special operating activity when a message is
+submitted. No activity means Unknown; the native macro default of SERIAL does
+not apply to automatic text recognition. Field Day adds no candidates because
+CLASS_SECTION is already self-identifying.
RTTY Roundup additionally considers full "599 <number>" as SERIAL and full
"599 <location>" as STATE_PROVINCE under the existing native exchange rules.
@@ -236,14 +259,15 @@ is per-message encoder context, not a new configuration or wire field.
A dynamic program over source-character offsets selects a minimum-frame
sequence of candidates and TEXT5. An interior TEXT5 atom consumes exactly five
-characters; only the final TEXT5 atom may be padded. A structured candidate
-consumes its rendering plus one source space when another token follows,
-matching the receiver's implicit separator. Equal-cost choices prefer a
-structured atom, then the longest consumed span, then ascending atom
-kind/subtype/role. Thus equally compact SERIAL and STATE_PROVINCE candidates
-win over their generic equivalents under RTTY Roundup. This minimizes frames
-under the recognition policy, not
-under hypothetical knowledge of the contest exchange's meaning.
+characters; only the final TEXT5 atom may be padded. Interior padding cannot
+be used to reach a compact candidate because it would change the text.
+A structured candidate consumes its rendering plus one source space when
+another token follows, matching the receiver's implicit separator.
+Equal-cost choices prefer a structured atom, then the longest consumed span,
+then ascending atom kind/subtype/role. Thus equally compact SERIAL and
+STATE_PROVINCE candidates win over their generic equivalents under RTTY
+Roundup. This minimizes frames under the recognition policy, not under
+hypothetical knowledge of the contest exchange's meaning.
For example, "CQ K1ABC CQ", "599 123", "599 MA", "599 FN42", and "1D EMA"
each use one frame. Under Unknown or Field Day, "599 001" and "599 05" need
@@ -259,6 +283,8 @@ sjtty defaults to Unknown. The optional leading argument
one-message packing and eight-argument waveform invocations. An invalid
profile value is an error.
+Native function keys
+
The eight shipped JTTY function-key templates are a separate NativeMacro
contract. Current templates and control phrases match after case folding and
whitespace normalization, before placeholder expansion. Superseded templates
@@ -311,9 +337,10 @@ start of the transmitted text, after the normal {TX} command:
[[JTTY:<ACTION>]]<payload>
N1MM expands {MYCALL}, ! or {CALL}, and {EXCH}; WSJT-X then parses the expanded
-payload under the selected action and active profile. The tag must begin at the
-first non-space character; tag and action matching is case-insensitive. The
-marker is transport metadata and is not transmitted. Assigned actions are:
+payload, normalizing whitespace and case, under the selected action and active
+profile. The tag must begin at the first non-space character; tag and action
+matching is case-insensitive. The marker is transport metadata and is not
+transmitted. Assigned actions are:
--------------------------------------------------------------------------------
Action Expanded payload Native meaning
@@ -336,13 +363,13 @@ rules as %E, except that tagged values are already expanded: RTTY "DX" is a
two-letter location, and the local-configuration "DX" and "#" serial sentinels
do not apply. It contains the exchange value only: the action supplies CQ, TU,
TU NOW, and canonical full-exchange report text where applicable. GRID requires
-a valid four-character Maidenhead locator. CONTROL requires one exact
+exactly one valid four-character Maidenhead locator. CONTROL requires one exact
registered phrase from the CONTROL table above. An untagged N1MM message uses
the literal source interface with automatic packing described above.
-A tag-shaped substring later in a message has no
-special meaning. An unknown or malformed leading JTTY tag, an unsupported
-action, invalid payload, or profile mismatch is rejected rather than put on
-the air as literal bracket text.
+A tag-shaped substring later in a message has no special meaning. An unknown
+or malformed leading JTTY tag, unsupported action, missing field, invalid call,
+invalid exchange or grid, unregistered control phrase, or profile mismatch is
+rejected rather than put on the air as literal bracket text.
Representative 34-bit vectors
@@ -366,15 +393,3 @@ CONTROL AGN? 0000000000000000000000000001001001 0x000000049
GRID4 field-only FN42 0001001010000110011000000001001001 0x04A198049
TEXT5 HELLO 0100010011100101010101010110001101 0x11395558D
--------------------------------------------------------------------------------
-
-Compatibility
-
-This version deliberately replaces the earlier i2=2 encoding, which meant the
-literal prefix "599 " followed by five six-bit characters. There is no version
-discriminator: an old receiver will render new STRUCT30 payload bits as
-arbitrary text following "599 ", while some old i2=2 frames happen to satisfy
-the new STRUCT30 structural rules and will be accepted with a different
-meaning by a new receiver. JTTY is unreleased, so this incompatibility is
-intentional and no legacy decoder mode is retained. Automatic text packing
-uses only the current grammar; unrecognized "599 ..." text remains available
-through TEXT5.
diff --git a/lib/jtty/jtty_tx_manual_checks.md b/lib/jtty/jtty_tx_manual_checks.md
index bcb4ff44..f8eb992a 100644
--- a/lib/jtty/jtty_tx_manual_checks.md
+++ b/lib/jtty/jtty_tx_manual_checks.md
@@ -3,9 +3,36 @@
These checks cover MainWindow, PTT, and backend behavior that is outside the
FIFO unit-test boundary.
+- Free entry: Enter queues the whole message. Text longer than the encoder's
+ 80-character capacity is split at spaces where possible; longer words are
+ split across messages. Each segment has its own end marker, and the receiver
+ displays separate messages. The exchange profile and transmit frequency are
+ captured when the message is submitted.
+- Pending text: the existing Send button shows `Send (3 left)` while segments
+ remain, including the segment currently playing. Its tooltip shows the
+ pending text. Yellow transmit text appears when the audio source starts
+ serving each segment; it does not confirm reception. Completion waits for
+ the backend's final audio drain.
+- Status bar: long `Tx:` and `Last Tx:` messages use an ellipsis to leave room
+ for the other indicators. Hover to read the complete message.
+- Drafts: typing while transmitting starts a new draft; Enter appends it after
+ existing text. Halt Tx or Esc cancels all unfinished submissions and leaves the
+ new draft alone. Cancellation is reported in the Send tooltip;
+ partial transmission may already have occurred. No cancelled text is restored
+ to the input, and nothing is retained across application exit.
+- Long entry: send enough text to exceed 60 seconds of encoded audio. Verify
+ continuous playback, ordered segments, and reception of the final suffix.
+ Repeat with an exactly 80-character segment appended during playback.
+- Cancellation: stop before PTT rises and during playback, then send a fresh
+ long message. Verify that cancelled text never resumes, deferred text never
+ appears yellow, and the new message starts normally. Repeat with Esc, a mode
+ change, and an audio/backend failure. Check that newer draft edits survive.
+- Normalization: enter unsupported characters after character 80. Verify the
+ substitution notice in the Send tooltip and canonical pending text, with no
+ omitted suffix.
- Soundcard: send one JTTY message and verify the full tail plays before PTT drops.
- Soundcard: queue two or three messages rapidly and verify playback is contiguous with PTT held.
-- Soundcard: press Stop during playback and verify queued audio is abandoned before PTT drops.
+- Soundcard: press Halt Tx during playback and verify queued audio is abandoned before PTT drops.
- Soundcard: press Esc before PTT comes up and during playback and verify clean aborts.
- Soundcard: send again after a natural drain and verify a fresh transmit session starts.
- TCI, where available: repeat the same checks and watch for backend enqueue failure warnings.
@@ -33,8 +60,8 @@ FIFO unit-test boundary.
frame, with the canonical text shown and logged. Verify bare `001` retains
its spelling and is not inferred as SERIAL. Verify unsupported serial
tokens (over six digits or above 131071) retain their spelling. Verify a
- message whose serial normalization expands beyond 80 characters is rejected
- rather than truncated. Submit a message, change activity
+ message whose serial normalization expands beyond 80 characters is split
+ without omitting the remainder. Submit a message, change activity
before it plays, and verify the submitted message retains its captured
profile. Repeat through untagged N1MM/MMTTY and customized macro fallback.
- sjtty: compare default and leading `--exchange-profile=rtty-roundup` with
diff --git a/lib/jtty/rjtty_sub.f90 b/lib/jtty/rjtty_sub.f90
index 333d38b4..2ab3ab25 100644
--- a/lib/jtty/rjtty_sub.f90
+++ b/lib/jtty/rjtty_sub.f90
@@ -54,7 +54,7 @@ subroutine rjtty_core(iwave,kz,nsps,nfa,nfb,f0,ftol,istart0,istop)
999 return
end subroutine rjtty_core
-subroutine jtty_get_updates(text_blocks,message_ids,frequencies,start_tsync,eom,count)
+subroutine jtty_get_updates(text_blocks,message_ids,frequencies,start_tsync,eom,snr,count)
use iso_fortran_env, only: int64
use jtty_mdec
@@ -65,6 +65,7 @@ subroutine jtty_get_updates(text_blocks,message_ids,frequencies,start_tsync,eom,
real, intent(out) :: frequencies(BATCH_SIZE)
real, intent(out) :: start_tsync(BATCH_SIZE)
logical*1, intent(out) :: eom(BATCH_SIZE)
+ integer, intent(out) :: snr(BATCH_SIZE)
integer, intent(out) :: count
character(len=MESSAGE_LENGTH) :: msg
integer :: i,index,offset
@@ -74,6 +75,7 @@ subroutine jtty_get_updates(text_blocks,message_ids,frequencies,start_tsync,eom,
frequencies=0.0
start_tsync=0.0
eom=.false.
+ snr=0
count=min(npending,BATCH_SIZE)
do i=1,count
@@ -85,6 +87,7 @@ subroutine jtty_get_updates(text_blocks,message_ids,frequencies,start_tsync,eom,
frequencies(i)=pending_updates(index)%f1
start_tsync(i)=pending_updates(index)%start_tsync
eom(i)=pending_updates(index)%complete
+ snr(i)=nint(pending_updates(index)%snr)
enddo
! Pending membership is the delivery guarantee; remove records only after copying them out.
diff --git a/lib/jtty/sjtty.f90 b/lib/jtty/sjtty.f90
index 16d4324a..4c4fd75a 100644
--- a/lib/jtty/sjtty.f90
+++ b/lib/jtty/sjtty.f90
@@ -21,6 +21,7 @@ program sjtty
character*80 umsg !User-formatted message
character(len=80) :: profile_option
integer :: exchange_profile,arg_offset
+ integer :: ihr,imin,isec,ihhmmss !For clock-like (not raw sequential) output filenames
character*40 fname !Output file name
character*34 c32(16)
complex, allocatable :: cwave(:) !Complex generated waveform (12000 Hz)
@@ -238,7 +239,12 @@ program sjtty
iwave(1:iz)=nint(wave(1:iz))
! call jtty_spec(iwave,iz)
h=default_header(12000,iz)
- write(fname,1102) ifile
+ ! Format the file counter as elapsed HHMMSS, not a raw sequential integer, so WSJT-X's disk-playback time label parses it (file 60 -> "_000100", not the invalid "_000060").
+ ihr=mod(ifile/3600,24)
+ imin=mod(ifile,3600)/60
+ isec=mod(ifile,60)
+ ihhmmss=10000*ihr + 100*imin + isec
+ write(fname,1102) ihhmmss
1102 format('000000_',i6.6,'.wav')
open(10,file=fname,status='replace',access='stream')
write(10) h,iwave(1:iz) !Save to *.wav file
diff --git a/lib/jtty/wava/plot_results.py b/lib/jtty/wava/plot_results.py
deleted file mode 100644
index 0ef97628..00000000
--- a/lib/jtty/wava/plot_results.py
+++ /dev/null
@@ -1,57 +0,0 @@
-
-import pandas as pd
-import matplotlib.pyplot as plt
-
-# Read data logged from the Fortran testbench suite
-try:
- df = pd.read_csv('simulation_results.csv')
-except FileNotFoundError:
- print("Error: 'simulation_results.csv' not found. Execute the Fortran simulation program first.")
- exit()
-
-# Strip whitespace from columns to avoid parsing mismatches
-df['channel'] = df['channel'].str.strip()
-
-# Initialize Figure with high resolution DPI properties
-fig, ax1 = plt.subplots(figsize=(10, 6), dpi=120)
-
-# Set up Primary Axis: Frame Correct-Decode Probability P(Correct)
-ax1.set_xlabel('SNR in 2500 Hz Reference Bandwidth [dB]', fontsize=11, fontweight='bold')
-ax1.set_ylabel('P(Correct Decode)', color='navy', fontsize=11, fontweight='bold')
-ax1.set_xlim(0, -20) # Invert axis view to scan standard drop off descending to -20 dB
-ax1.set_ylim(-0.05, 1.05)
-ax1.grid(True, which='both', linestyle='--', alpha=0.5)
-
-# Set up Secondary Axis on the right side for 100 * UER (%)
-ax2 = ax1.twinx()
-ax2.set_ylabel('Undetected Error Rate: 100 * UER [%]', color='crimson', fontsize=11, fontweight='bold')
-ax2.set_ylim(-0.1, 5.0) # Standard percentage visualization window
-
-# Isolate channel tracking configurations
-awgn_data = df[df['channel'] == 'AWGN'].sort_values(by='snr_db', ascending=False)
-rayleigh_data = df[df['channel'] == 'RAYLEIGH'].sort_values(by='snr_db', ascending=False)
-
-# Plot Primary Curves - P(Correct)
-line1 = ax1.plot(awgn_data['snr_db'], awgn_data['p_correct'],
- 'o-', color='navy', linewidth=2.0, label='AWGN: P(Correct)')
-line2 = ax1.plot(rayleigh_data['snr_db'], rayleigh_data['p_correct'],
- 's-', color='royalblue', linewidth=1.8, label='Rayleigh: P(Correct)')
-
-# Plot Secondary Curves - 100 * UER (%)
-line3 = ax2.plot(awgn_data['snr_db'], awgn_data['uer_pct'],
- '^--', color='crimson', linewidth=1.5, label='AWGN: 100*UER')
-line4 = ax2.plot(rayleigh_data['snr_db'], rayleigh_data['uer_pct'],
- 'v--', color='orange', linewidth=1.5, label='Rayleigh: 100*UER')
-
-# Align Legend structures coherently across shared dual axis space
-lines = line1 + line2 + line3 + line4
-labels = [l.get_label() for l in lines]
-ax1.legend(lines, labels, loc='center left', frameon=True, shadow=True)
-
-plt.title('TBCC (92,46) Noncoherent 4-FSK Performance Profile\nConstraint Length K=11, List Size L=8, Rate=1/2',
- fontsize=12, fontweight='bold', pad=15)
-
-plt.tight_layout()
-plt.savefig('tbcc_performance_curves.png', dpi=300)
-print("Plot successfully rendered and saved as 'tbcc_performance_curves.png'")
-plt.show()
diff --git a/lib/jtty/wava/tbcc_performance_curves.png b/lib/jtty/wava/tbcc_performance_curves.png
deleted file mode 100644
index 88d63b07..00000000
--- a/lib/jtty/wava/tbcc_performance_curves.png
+++ /dev/null
Binary files differ