WSJT-X/lib/jt65code.f90

102 lines
3.2 KiB
Fortran
Raw Normal View History

program JT65code
! Provides examples of message packing, bit and symbol ordering,
! Reed Solomon encoding, and other necessary details of the JT65
! protocol.
use packjt
character*22 msg,msgchk,msg0,msg1,decoded,cok*3,bad*1,msgtype*10,expected
integer dgen(12),sent(63),tmp(63),recd(12),era(51)
include 'testmsg.f90'
nargs=iargc()
if(nargs.ne.1) then
print*,'Usage: jt65code "message"'
print*,' jt65code -t'
go to 999
endif
call getarg(1,msg) !Get message from command line
msgchk=msg
call fmtmsg(msgchk,iz)
nmsg=1
if(msg(1:2).eq."-t") then
if (NTEST+5 > MAXTEST) then
write(*,*) "NTEST exceed MAXTEST"
endif
testmsg(NTEST+1)="KA1ABC WB9XYZ EN34 OOO"
testmsg(NTEST+2)="KA1ABC WB9XYZ OOO"
testmsg(NTEST+3)="RO"
testmsg(NTEST+4)="RRR"
testmsg(NTEST+5)="73"
testmsgchk(NTEST+1)="KA1ABC WB9XYZ EN34 OOO"
testmsgchk(NTEST+2)="KA1ABC WB9XYZ OOO"
testmsgchk(NTEST+3)="RO"
testmsgchk(NTEST+4)="RRR"
testmsgchk(NTEST+5)="73"
nmsg=NTEST+5
endif
write(*,1010)
1010 format(" Message Decoded Err? Type Expected"/ &
76("-"))
do imsg=1,nmsg
if(nmsg.gt.1) then
msg=testmsg(imsg)
msgchk=testmsgchk(imsg)
endif
call fmtmsg(msg,iz) !To upper, collapse mult blanks
msg0=msg !Input message
call chkmsg(msg,cok,nspecial,flip) !See if it includes "OOO" report
msg1=msg !Message without "OOO"
if(nspecial.gt.0) then !or is a shorthand message
if(nspecial.eq.2) decoded="RO"
if(nspecial.eq.3) decoded="RRR"
if(nspecial.eq.4) decoded="73"
itype=-1
msgtype="Shorthand"
go to 10
endif
Merged from trunk: ------------------------------------------------------------------------ r8060 | k1jt | 2017-09-01 13:51:42 +0100 (Fri, 01 Sep 2017) | 2 lines Add a link to G3WDG doc on using QRA64 for microwave EME. ------------------------------------------------------------------------ r8061 | k1jt | 2017-09-01 17:22:19 +0100 (Fri, 01 Sep 2017) | 1 line Fix a misspelled word. ------------------------------------------------------------------------ r8062 | bsomervi | 2017-09-01 21:10:35 +0100 (Fri, 01 Sep 2017) | 7 lines Rationalize NA contest mode Generic message packing and unpacking routines now understand antipode grid contest messages. These messages are now recognized as standard messages in message response processing and dealt with appropriately when contest mode is selected and applicable (currently FT8 and MSK144 only). ------------------------------------------------------------------------ r8063 | bsomervi | 2017-09-01 21:43:45 +0100 (Fri, 01 Sep 2017) | 1 line Fix issue compiling with Qt older than v5.7 ------------------------------------------------------------------------ r8064 | bsomervi | 2017-09-01 22:29:02 +0100 (Fri, 01 Sep 2017) | 7 lines Fix issues with type 2 compound calls in contest mode Message generation in contest mode now generates the correct Tx3 for type 2 calls. "<type-2> 73" is a free text so needed special handling in message processing. ------------------------------------------------------------------------ r8065 | bsomervi | 2017-09-01 23:22:20 +0100 (Fri, 01 Sep 2017) | 11 lines Improved message generation for type 2 calls in contest mode These attempt to ensure that a prefix is logged by the QSO partner even if the compound call holder user Tx3 to tail-end a QSO. The type 2 message generation options are largely overridden in contest mode as only a few options make sense. Key is that Tx1 may use only the base call when calling split is necessary, this requires that both Tx3 and Tx4 have the full compound call otherwise the QSO partner will never see the full call until it is possibly too late i.e. post logging. ------------------------------------------------------------------------ r8066 | bsomervi | 2017-09-02 00:28:44 +0100 (Sat, 02 Sep 2017) | 5 lines Fix erroneous auto stop critera for auto reply in FT8 We cannot assume that a "DE <dx-call> <anything>" is or is not for us so we must continue calling and risk possible QRM. Calling split avoids this issue. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8067 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-09-01 23:55:56 +00:00
call packmsg(msg1,dgen,itype,.false.) !Pack message into 12 six-bit bytes
msgtype=""
if(itype.eq.1) msgtype="Std Msg"
if(itype.eq.2) msgtype="Type 1 pfx"
if(itype.eq.3) msgtype="Type 1 sfx"
if(itype.eq.4) msgtype="Type 2 pfx"
if(itype.eq.5) msgtype="Type 2 sfx"
if(itype.eq.6) msgtype="Free text"
call rs_encode(dgen,sent) !RS encode
call interleave63(sent,1) !Interleave channel symbols
call graycode(sent,63,1,sent) !Apply Gray code
call graycode(sent,63,-1,tmp) !Remove Gray code
call interleave63(tmp,-1) !Remove interleaving
call rs_decode(tmp,era,0,recd,nerr) !Decode the message
Merged from trunk: ------------------------------------------------------------------------ r8060 | k1jt | 2017-09-01 13:51:42 +0100 (Fri, 01 Sep 2017) | 2 lines Add a link to G3WDG doc on using QRA64 for microwave EME. ------------------------------------------------------------------------ r8061 | k1jt | 2017-09-01 17:22:19 +0100 (Fri, 01 Sep 2017) | 1 line Fix a misspelled word. ------------------------------------------------------------------------ r8062 | bsomervi | 2017-09-01 21:10:35 +0100 (Fri, 01 Sep 2017) | 7 lines Rationalize NA contest mode Generic message packing and unpacking routines now understand antipode grid contest messages. These messages are now recognized as standard messages in message response processing and dealt with appropriately when contest mode is selected and applicable (currently FT8 and MSK144 only). ------------------------------------------------------------------------ r8063 | bsomervi | 2017-09-01 21:43:45 +0100 (Fri, 01 Sep 2017) | 1 line Fix issue compiling with Qt older than v5.7 ------------------------------------------------------------------------ r8064 | bsomervi | 2017-09-01 22:29:02 +0100 (Fri, 01 Sep 2017) | 7 lines Fix issues with type 2 compound calls in contest mode Message generation in contest mode now generates the correct Tx3 for type 2 calls. "<type-2> 73" is a free text so needed special handling in message processing. ------------------------------------------------------------------------ r8065 | bsomervi | 2017-09-01 23:22:20 +0100 (Fri, 01 Sep 2017) | 11 lines Improved message generation for type 2 calls in contest mode These attempt to ensure that a prefix is logged by the QSO partner even if the compound call holder user Tx3 to tail-end a QSO. The type 2 message generation options are largely overridden in contest mode as only a few options make sense. Key is that Tx1 may use only the base call when calling split is necessary, this requires that both Tx3 and Tx4 have the full compound call otherwise the QSO partner will never see the full call until it is possibly too late i.e. post logging. ------------------------------------------------------------------------ r8066 | bsomervi | 2017-09-02 00:28:44 +0100 (Sat, 02 Sep 2017) | 5 lines Fix erroneous auto stop critera for auto reply in FT8 We cannot assume that a "DE <dx-call> <anything>" is or is not for us so we must continue calling and risk possible QRM. Calling split avoids this issue. ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx-1.8@8067 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
2017-09-01 23:55:56 +00:00
call unpackmsg(recd,decoded,.false.,' ') !Unpack the user message
if(cok.eq."OOO") decoded(20:22)=cok
call fmtmsg(decoded,iz)
10 bad=" "
if(decoded.ne.msgchk) bad="*"
expected = 'EXACT'
if (msg0.ne.msgchk) expected = 'TRUNCATED'
if (nmsg.eq.1) expected = 'UNKNOWN'
write(*,1020) imsg,msg0,decoded,bad,itype,msgtype,expected
1020 format(i2,'.',1x,a22,1x,a22,1x,a1,i3,":",a10,2x,a22)
enddo
if(nmsg.eq.1 .and. nspecial.eq.0) then
write(*,1030) dgen
1030 format(/'Packed message, 6-bit symbols ',12i3) !Display packed symbols
write(*,1040) sent
1040 format(/'Information-carrying channel symbols'/(i5,20i3))
endif
999 end program JT65code