Add utility program ft4code.

This commit is contained in:
Joe Taylor 2019-12-18 10:02:00 -05:00
parent 7d8cdd200c
commit 3397bf49b4
4 changed files with 163 additions and 3 deletions

View File

@ -479,6 +479,7 @@ set (wsjt_FSRCS
lib/ft8/genft8.f90 lib/ft8/genft8.f90
lib/genmsk_128_90.f90 lib/genmsk_128_90.f90
lib/genmsk40.f90 lib/genmsk40.f90
lib/ft4/ft4code.f90
lib/ft4/genft4.f90 lib/ft4/genft4.f90
lib/ft4/gen_ft4wave.f90 lib/ft4/gen_ft4wave.f90
lib/ft8/gen_ft8wave.f90 lib/ft8/gen_ft8wave.f90
@ -1305,6 +1306,9 @@ target_link_libraries (jt65 wsjt_fort wsjt_cxx)
add_executable (ft8code lib/ft8/ft8code.f90 wsjtx.rc) add_executable (ft8code lib/ft8/ft8code.f90 wsjtx.rc)
target_link_libraries (ft8code wsjt_fort wsjt_cxx) target_link_libraries (ft8code wsjt_fort wsjt_cxx)
add_executable (ft4code lib/ft4/ft4code.f90 wsjtx.rc)
target_link_libraries (ft4code wsjt_fort wsjt_cxx)
add_executable (ft8 lib/ft8.f90 wsjtx.rc) add_executable (ft8 lib/ft8.f90 wsjtx.rc)
target_link_libraries (ft8 wsjt_fort wsjt_cxx) target_link_libraries (ft8 wsjt_fort wsjt_cxx)

50
lib/ft4/ft4_testmsg.f90 Normal file
View File

@ -0,0 +1,50 @@
parameter (MAXTEST=75,NTEST=47)
character*37 testmsg(MAXTEST)
data testmsg(1:NTEST)/ &
"CQ K1ABC FN42", &
"K1ABC W9XYZ EN37", &
"W9XYZ K1ABC -11", &
"K1ABC W9XYZ R-09", &
"W9XYZ K1ABC RRR", &
"K1ABC W9XYZ 73", &
"K1ABC W9XYZ RR73", &
"CQ KH1/KH7Z", &
"CQ FD K1ABC FN42", &
"K1ABC W9XYZ 6A WI", &
"W9XYZ K1ABC R 2B EMA", &
"CQ TEST K1ABC/R FN42", &
"K1ABC/R W9XYZ EN37", &
"W9XYZ K1ABC/R R FN42", &
"K1ABC/R W9XYZ RR73", &
"CQ TEST K1ABC FN42", &
"K1ABC W9XYZ 579 WI", &
"W9XYZ K1ABC R 589 MA", &
"K1ABC KA0DEF 559 MO", &
"TU; KA0DEF K1ABC R 569 MA", &
"KA1ABC G3AAA 529 0013", &
"TU; G3AAA K1ABC R 559 MA", &
"CQ G4ABC/P IO91", &
"G4ABC/P PA9XYZ JO22", &
"PA9XYZ 590003 IO91NP", &
"G4ABC/P R 570007 JO22DB", &
"PA9XYZ G4ABC/P RR73", &
"CQ PJ4/K1ABC", &
"PJ4/K1ABC <W9XYZ>", &
"W9XYZ <PJ4/K1ABC> -11", &
"<PJ4/K1ABC> W9XYZ R-09", &
"<W9XYZ> PJ4/K1ABC RRR", &
"PJ4/K1ABC <W9XYZ> 73", &
"CQ W9XYZ EN37", &
"<W9XYZ> YW18FIFA", &
"<YW18FIFA> W9XYZ -11", &
"W9XYZ <YW18FIFA> R-09", &
"YW18FIFA <W9XYZ> RRR", &
"<W9XYZ> YW18FIFA 73", &
"TNX BOB 73 GL", &
"CQ YW18FIFA", &
"<YW18FIFA> KA1ABC", &
"KA1ABC <YW18FIFA> -11", &
"<YW18FIFA> KA1ABC R-17", &
"<KA1ABC> YW18FIFA RR73", &
"<YW18FIFA> KA1ABC 73", &
"123456789ABCDEF012"/

99
lib/ft4/ft4code.f90 Normal file
View File

@ -0,0 +1,99 @@
program ft4code
! Provides examples of message packing, LDPC(174,91) encoding, bit and
! symbol ordering, and other details of the FT8 protocol.
use packjt77
include 'ft4_params.f90' !Set various constants
include 'ft4_testmsg.f90'
parameter (NWAVE=NN*NSPS)
character*37 msg,msgsent
character*77 c77
character*9 comment
character bad*1,msgtype*18
integer itone(NN)
integer*1 msgbits(77),rvec(77),codeword(174)
data rvec/0,1,0,0,1,0,1,0,0,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,1,0,1,1,0, &
1,0,0,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1, &
0,1,0,1,0,1,1,0,1,1,1,1,1,0,0,0,1,0,1/
! Get command-line argument(s)
nargs=iargc()
if(nargs.ne.1 .and. nargs.ne.3) then
print*
print*,'Program ft4code: Provides examples of message packing, ', &
'LDPC(174,91) encoding,'
print*,'bit and symbol ordering, and other details of the FT4 protocol.'
print*
print*,'Usage: ft4code [-c grid] "message" # Results for specified message'
print*,' ft4code -t # Examples of all message types'
go to 999
endif
call getarg(1,msg) !Message to be transmitted
if(len(trim(msg)).eq.2 .and. msg(1:2).eq.'-t') then
nmsg=NTEST
else
call fmtmsg(msg,iz) !To upper case; collapse multiple blanks
nmsg=1
endif
write(*,1010)
1010 format(4x,'Message',31x,'Decoded',29x,'Err i3.n3'/100('-'))
do imsg=1,nmsg
if(nmsg.gt.1) msg=testmsg(imsg)
! Generate msgsent, msgbits, and itone
i3=-1
n3=-1
call pack77(msg,i3,n3,c77)
call genft4(msg,0,msgsent,msgbits,itone)
call encode174_91(msgbits,codeword)
msgtype=""
if(i3.eq.0) then
if(n3.eq.0) msgtype="Free text"
if(n3.eq.1) msgtype="DXpedition mode"
if(n3.eq.2) msgtype="EU VHF Contest"
if(n3.eq.3) msgtype="ARRL Field Day"
if(n3.eq.4) msgtype="ARRL Field Day"
if(n3.eq.5) msgtype="Telemetry"
if(n3.ge.6) msgtype="Undefined type"
endif
if(i3.eq.1) msgtype="Standard msg"
if(i3.eq.2) msgtype="EU VHF Contest"
if(i3.eq.3) msgtype="ARRL RTTY Roundup"
if(i3.eq.4) msgtype="Nonstandard calls"
if(i3.ge.5) msgtype="Undefined msg type"
if(i3.ge.1) n3=-1
bad=" "
comment=' '
if(msg.ne.msgsent) bad="*"
if(n3.ge.0) then
write(*,1020) imsg,msg,msgsent,bad,i3,n3,msgtype,comment
1020 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',i1,1x,a18,1x,a9)
else
write(*,1022) imsg,msg,msgsent,bad,i3,msgtype,comment
1022 format(i2,'.',1x,a37,1x,a37,1x,a1,2x,i1,'.',1x,1x,a18,1x,a9)
endif
enddo
if(nmsg.eq.1) then
write(*,1030) ieor(msgbits,rvec)
1030 format(/'Source-encoded message before XOR(), 77 bits: ',/77i1)
write(*,1031) msgbits
1031 format(/'Source-encoded message after XOR(), 77 bits: ',/77i1)
write(*,1032) codeword(78:91)
1032 format(/'14-bit CRC: ',/14i1)
write(*,1033) codeword(92:174)
1033 format(/'83 Parity bits: ',/83i1)
write(*,1034) 0,itone,0
1034 format(/'Channel symbols (105 tones):'/ &
'R Sync',13x,'Data',13x, &
' Sync',13x,'Data',13x, &
' Sync',13x,'Data',13x,' Sync R'/ &
i1,1x,4i1,1x,29i1,1x,4i1,1x,29i1,1x,4i1,1x,29i1,1x,4i1,i2)
endif
999 end program ft4code

View File

@ -12,7 +12,7 @@ program ft8code
character*9 comment character*9 comment
character bad*1,msgtype*18 character bad*1,msgtype*18
integer itone(NN) integer itone(NN)
integer*1 msgbits(77) integer*1 msgbits(77),codeword(174)
! Get command-line argument(s) ! Get command-line argument(s)
nargs=iargc() nargs=iargc()
@ -45,6 +45,7 @@ program ft8code
i3=-1 i3=-1
n3=-1 n3=-1
call genft8(msg,i3,n3,msgsent,msgbits,itone) call genft8(msg,i3,n3,msgsent,msgbits,itone)
call encode174_91(msgbits,codeword)
msgtype="" msgtype=""
if(i3.eq.0) then if(i3.eq.0) then
if(n3.eq.0) msgtype="Free text" if(n3.eq.0) msgtype="Free text"
@ -75,9 +76,15 @@ program ft8code
if(nmsg.eq.1) then if(nmsg.eq.1) then
write(*,1030) msgbits write(*,1030) msgbits
1030 format(/'Message bits: ',/77i1) 1030 format(/'Source-encoded message, 77 bits: ',/77i1)
write(*,1031) codeword(78:91)
1031 format(/'14-bit CRC: ',/14i1)
write(*,1032) codeword(92:174)
1032 format(/'83 Parity bits: ',/83i1)
write(*,1034) itone write(*,1034) itone
1034 format(/'Channel symbols (tones):'/79i1) 1034 format(/'Channel symbols (79 tones):'/ &
' Sync ',14x,'Data',15x,'Sync',15x,'Data',15x,'Sync'/ &
7i1,1x,29i1,1x,7i1,1x,29i1,1x,7i1)
endif endif
999 end program ft8code 999 end program ft8code