From 45031738bfc5b91f45224c3490b8054d87732a0b Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Mon, 24 Sep 2018 12:31:17 -0500 Subject: [PATCH 1/3] Fix some message-length incompatibilities involving MSK144 Sh messages. SWL mode is broken for the time being, because it relied on the old extractmessage144 routine to keep track of recent callsigns. That routine is no longer used. --- lib/msk40decodeframe.f90 | 6 ------ lib/mskrtd.f90 | 40 ++++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/msk40decodeframe.f90 b/lib/msk40decodeframe.f90 index ae75ddf95..03c9c28a3 100644 --- a/lib/msk40decodeframe.f90 +++ b/lib/msk40decodeframe.f90 @@ -115,7 +115,6 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & max_iterations=5 call bpdecode40(llr,max_iterations,decoded,niterations) - if( niterations .ge. 0.0 ) then call encode_msk40(decoded,cw) nhammd=0 @@ -133,10 +132,8 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & enddo nrxrpt=iand(imsg,15) nrxhash=(imsg-nrxrpt)/16 - if(nhammd.le.4 .and. cord .lt. 0.65 .and. & nrxhash.eq.ihash .and. nrxrpt.ge.7) then -!write(*,*) 'decodeframe 1',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma nsuccess=1 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(mycall), & trim(hiscall),">",rpt(nrxrpt) @@ -148,18 +145,15 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & nsuccess=2 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(recent_calls(i)), & trim(recent_calls(j)),">",rpt(nrxrpt) -!write(*,*) 'decodeframe 2',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma elseif( nrxhash .eq. nhasharray(j,i) ) then nsuccess=2 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(recent_calls(j)), & trim(recent_calls(i)),">",rpt(nrxrpt) -!write(*,*) 'decodeframe 3',nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma endif enddo enddo if(nsuccess.eq.0) then nsuccess=3 -!write(*,*) 'decodeframe 4',bswl,nbadsync,nhammd,cord,nrxhash,nrxrpt,ihash,xsnr,sigma,nsuccess write(msgreceived,'(a1,i4.4,a1,1x,a4)') "<",nrxhash,">",rpt(nrxrpt) endif endif diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index b249b8883..f03fa7f63 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -14,12 +14,13 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & character*4 decsym !"&" for mskspd or "^" for long averages character*37 msgreceived !Decoded message + character*22 msgrx22 !Sh messages are returned as 22chars character*37 msglast,msglastswl !Used for dupechecking character*80 line !Formatted line with UTC dB T Freq Msg character*12 mycall,hiscall character*6 mygrid character*12 recent_calls(NRECENT) - character*22 recent_shmsgs(NSHMEM) + character*37 recent_shmsgs(NSHMEM) character*512 datadir complex cdat(NFFT1) !Analytic signal @@ -64,10 +65,10 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & recent_calls(i)(1:12)=' ' enddo do i=1,nshmem - recent_shmsgs(i)(1:22)=' ' + recent_shmsgs(i)(1:37)=' ' enddo - msglast=' ' - msglastswl=' ' + msglast=' ' + msglastswl=' ' nsnrlast=-99 nsnrlastswl=-99 first=.false. @@ -77,8 +78,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & ! Dupe checking setup if(nutc00.ne.nutc0 .or. tsec.lt.tsec0) then ! reset dupe checker - msglast=' ' - msglastswl=' ' + msglast=' ' + msglastswl=' ' nsnrlast=-99 nsnrlastswl=-99 nutc00=nutc0 @@ -86,7 +87,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & tframe=float(NSPM)/12000.0 line=char(0) - msgreceived=' ' + msgreceived=' ' max_iterations=10 niterations=0 d(1:NZ)=id2 @@ -119,7 +120,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & softbits,recent_calls,nrecent) if(ndecodesuccess.eq.0 .and. (bshmsg.or.bswl)) then call msk40spd(cdat,np,ntol,mycall(1:6),hiscall(1:6),bswl,nhasharray, & - recent_calls,nrecent,ndecodesuccess,msgreceived,fc,fest,tdec,navg) + recent_calls,nrecent,ndecodesuccess,msgrx22,fc,fest,tdec,navg) + if( ndecodesuccess .ge. 1 ) msgreceived(1:22)=msgrx22 endif if( ndecodesuccess .ge. 1 ) then tdec=tsec+tdec @@ -192,7 +194,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & decsym=' & ' if( btrain ) decsym=' ^ ' - if( msgreceived(1:1).eq.'<') then + if( bshdecode ) then ncorrected=0 eyeopening=0.0 endif @@ -209,9 +211,15 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(.not. bshdecode) then call update_hasharray(recent_calls,nrecent,nhasharray) endif - write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived, & - navg,ncorrected,eyeopening,char(0) -1020 format(i6.6,i4,f5.1,i5,a4,a22,i2,i3,f5.1,a1) + if( .not.bshdecode ) then + write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived(1:22), & + navg,ncorrected,eyeopening,char(0) +1020 format(i6.6,i4,f5.1,i5,a4,a22,i2,i3,f5.1,a1) + else + write(line,1022) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived(1:22), & + navg,char(0) +1022 format(i6.6,i4,f5.1,i5,a4,a22,i2,a1) + endif elseif(bswl .and. ndecodesuccess.ge.2) then seenb4=.false. do i=1,nshmem @@ -226,8 +234,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(bflag) then msglastswl=msgreceived nsnrlastswl=nsnr - write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived, & - navg,ncorrected,eyeopening,char(0) + write(line,1022) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived, & + navg,char(0) endif endif 999 tsec0=tsec @@ -236,8 +244,8 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & end subroutine mskrtd subroutine update_recent_shmsgs(message,msgs,nsize) - character*22 msgs(nsize) - character*22 message + character*37 msgs(nsize) + character*37 message logical*1 seen seen=.false. From af1be084d49fd47da87585241b41ab02911ce1f7 Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Mon, 24 Sep 2018 15:10:57 -0500 Subject: [PATCH 2/3] Make MSK144 SWL mode work. Needs testing\! --- lib/77bit/packjt77.f90 | 24 +++++++++++++++++++++++- lib/msk144decodeframe.f90 | 3 +-- lib/msk144spd.f90 | 7 +++---- lib/msk40decodeframe.f90 | 10 +++++----- lib/msk40spd.f90 | 9 ++++----- lib/mskrtd.f90 | 21 ++++++++++----------- lib/update_hasharray.f90 | 12 ++++++------ 7 files changed, 52 insertions(+), 34 deletions(-) diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90 index dc6a6e4ac..6b1686537 100644 --- a/lib/77bit/packjt77.f90 +++ b/lib/77bit/packjt77.f90 @@ -1,10 +1,11 @@ module packjt77 ! These variables are accessible from outside via "use packjt": - parameter (MAXHASH=1000) + parameter (MAXHASH=1000,MAXRECENT=10) character*13 callsign(MAXHASH) integer ihash10(MAXHASH),ihash12(MAXHASH),ihash22(MAXHASH) integer n28a,n28b,nzhash + character*13 recent_calls(MAXRECENT) contains @@ -358,11 +359,13 @@ subroutine unpack77(c77,msg,unpk77_success) i=index(call_1,' ') if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.1) call_1(i:i+1)='/R' if(i.ge.4 .and. ipa.eq.1 .and. i3.eq.2) call_1(i:i+1)='/P' + if(i.ge.4) call add_call_to_recent_calls(call_1) endif if(index(call_2,'<').le.0) then i=index(call_2,' ') if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.1) call_2(i:i+1)='/R' if(i.ge.4 .and. ipb.eq.1 .and. i3.eq.2) call_2(i:i+1)='/P' + if(i.ge.4) call add_call_to_recent_calls(call_2) endif if(igrid4.le.MAXGRID4) then n=igrid4 @@ -1159,5 +1162,24 @@ subroutine unpacktext77(c71,c13) return end subroutine unpacktext77 +subroutine add_call_to_recent_calls(callsign) + + character*13 callsign + logical ladd +! only add if the callsign is not already on the list + ladd=.true. + do i=1,MAXRECENT-1 ! if callsign is at the end of the list add it again + if(recent_calls(i).eq.callsign) ladd=.false. + enddo + + if(ladd) then + do i=MAXRECENT,2,-1 + recent_calls(i)=recent_calls(i-1) + enddo + recent_calls(1)=callsign + endif + + return +end subroutine add_call_to_recent_calls end module packjt77 diff --git a/lib/msk144decodeframe.f90 b/lib/msk144decodeframe.f90 index c3531673f..de039aadc 100644 --- a/lib/msk144decodeframe.f90 +++ b/lib/msk144decodeframe.f90 @@ -1,9 +1,8 @@ -subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess,recent_calls,nrecent) +subroutine msk144decodeframe(c,softbits,msgreceived,nsuccess) ! use timer_module, only: timer use packjt77 parameter (NSPM=864) character*37 msgreceived - character*12 recent_calls(nrecent) character*77 c77 complex cb(42) complex cfac,cca,ccb diff --git a/lib/msk144spd.f90 b/lib/msk144spd.f90 index 92ed56162..2bc6dcfef 100644 --- a/lib/msk144spd.f90 +++ b/lib/msk144spd.f90 @@ -1,13 +1,13 @@ subroutine msk144spd(cbig,n,ntol,nsuccess,msgreceived,fc,fret,tret,navg,ct, & - softbits,recent_calls,nrecent) + softbits) ! MSK144 short-ping-decoder + use packjt77 use timer_module, only: timer parameter (NSPM=864, MAXSTEPS=100, NFFT=NSPM, MAXCAND=5, NPATTERNS=6) character*37 msgreceived - character*12 recent_calls(nrecent) complex cbig(n) complex cdat(3*NSPM) !Analytic signal complex c(NSPM) @@ -179,8 +179,7 @@ subroutine msk144spd(cbig,n,ntol,nsuccess,msgreceived,fc,fret,tret,navg,ct, & if( is.eq.2) ic0=max(1,ic0-1) if( is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) - call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess, & - recent_calls,nrecent) + call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess) if( ndecodesuccess .gt. 0 ) then tret=(nstart(icand)+NSPM/2)/fs fret=fest diff --git a/lib/msk40decodeframe.f90 b/lib/msk40decodeframe.f90 index 03c9c28a3..51c9346a8 100644 --- a/lib/msk40decodeframe.f90 +++ b/lib/msk40decodeframe.f90 @@ -1,19 +1,19 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & - recent_calls,nrecent,msgreceived,nsuccess) + msgreceived,nsuccess) ! use timer_module, only: timer + use packjt77 parameter (NSPM=240) character*4 rpt(0:15) character*6 mycall,hiscall,mycall0,hiscall0 character*22 hashmsg,msgreceived - character*12 recent_calls(nrecent) complex cb(42) complex cfac,cca complex c(NSPM) integer*1 cw(32) integer*1 decoded(16) integer s8r(8),hardbits(40) - integer nhasharray(nrecent,nrecent) + integer nhasharray(MAXRECENT,MAXRECENT) real*8 dt, fs, pi, twopi real cbi(42),cbq(42) real pp(12) @@ -139,8 +139,8 @@ subroutine msk40decodeframe(c,mycall,hiscall,xsnr,bswl,nhasharray, & trim(hiscall),">",rpt(nrxrpt) return elseif(bswl .and. nhammd.le.4 .and. cord.lt.0.65 .and. nrxrpt.ge.7 ) then - do i=1,nrecent - do j=i+1,nrecent + do i=1,MAXRECENT + do j=i+1,MAXRECENT if( nrxhash .eq. nhasharray(i,j) ) then nsuccess=2 write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(recent_calls(i)), & diff --git a/lib/msk40spd.f90 b/lib/msk40spd.f90 index c8af1a49e..337bc8cc8 100644 --- a/lib/msk40spd.f90 +++ b/lib/msk40spd.f90 @@ -1,13 +1,13 @@ -subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & - nrecent,nsuccess,msgreceived,fc,fret,tret,navg) +subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray, & + nsuccess,msgreceived,fc,fret,tret,navg) ! msk40 short-ping-decoder + use packjt77 use timer_module, only: timer parameter (NSPM=240, MAXSTEPS=150, NFFT=NSPM, MAXCAND=5, NPATTERNS=6) character*6 mycall,hiscall character*22 msgreceived - character*12 recent_calls(nrecent) complex cbig(n) complex cdat(3*NSPM) !Analytic signal complex c(NSPM) @@ -19,7 +19,6 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & integer navpatterns(3,NPATTERNS) integer navmask(3) integer nstart(MAXCAND) - integer nhasharray(nrecent,nrecent) logical ismask(NFFT) logical*1 bswl real detmet(-2:MAXSTEPS+3) @@ -181,7 +180,7 @@ subroutine msk40spd(cbig,n,ntol,mycall,hiscall,bswl,nhasharray,recent_calls, & if( is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) call msk40decodeframe(ct,mycall,hiscall,xsnr,bswl,nhasharray, & - recent_calls,nrecent,msgreceived,ndecodesuccess) + msgreceived,ndecodesuccess) if( ndecodesuccess .gt. 0 ) then !write(*,*) icand, iav, ipk, is, tret, fret, msgreceived tret=(nstart(icand)+NSPM/2)/fs diff --git a/lib/mskrtd.f90 b/lib/mskrtd.f90 index f03fa7f63..ccb1f2406 100644 --- a/lib/mskrtd.f90 +++ b/lib/mskrtd.f90 @@ -5,11 +5,12 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & ! Analysis block size = NZ = 7168 samples, t_block = 0.597333 s ! Called from hspec() at half-block increments, about 0.3 s + use packjt77 + parameter (NZ=7168) !Block size parameter (NSPM=864) !Number of samples per message frame parameter (NFFT1=8192) !FFT size for making analytic signal parameter (NPATTERNS=4) !Number of frame averaging patterns to try - parameter (NRECENT=10) !Number of recent calls to remember parameter (NSHMEM=50) !Number of recent SWL messages to remember character*4 decsym !"&" for mskspd or "^" for long averages @@ -19,7 +20,6 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & character*80 line !Formatted line with UTC dB T Freq Msg character*12 mycall,hiscall character*6 mygrid - character*12 recent_calls(NRECENT) character*37 recent_shmsgs(NSHMEM) character*512 datadir @@ -31,7 +31,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & integer iavmask(8) integer iavpatterns(8,NPATTERNS) integer npkloc(10) - integer nhasharray(NRECENT,NRECENT) + integer nhasharray(MAXRECENT,MAXRECENT) integer nsnrlast,nsnrlastswl real d(NFFT1) @@ -55,14 +55,14 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & 1,1,1,1,1,1,1,0/ data xmc/2.0,4.5,2.5,3.5/ !Used to set time at center of averaging mask save first,tsec0,nutc00,pnoise,cdat,msglast,msglastswl, & - nsnrlast,nsnrlastswl,recent_calls,nhasharray,recent_shmsgs + nsnrlast,nsnrlastswl,nhasharray,recent_shmsgs if(first) then tsec0=tsec nutc00=nutc0 pnoise=-1.0 - do i=1,nrecent - recent_calls(i)(1:12)=' ' + do i=1,MAXRECENT + recent_calls(i)(1:13)=' ' enddo do i=1,nshmem recent_shmsgs(i)(1:37)=' ' @@ -117,10 +117,10 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & ! 3 frames along with 2- and 3-frame averages. np=8*NSPM call msk144spd(cdat,np,ntol,ndecodesuccess,msgreceived,fc,fest,tdec,navg,ct, & - softbits,recent_calls,nrecent) + softbits) if(ndecodesuccess.eq.0 .and. (bshmsg.or.bswl)) then call msk40spd(cdat,np,ntol,mycall(1:6),hiscall(1:6),bswl,nhasharray, & - recent_calls,nrecent,ndecodesuccess,msgrx22,fc,fest,tdec,navg) + ndecodesuccess,msgrx22,fc,fest,tdec,navg) if( ndecodesuccess .ge. 1 ) msgreceived(1:22)=msgrx22 endif if( ndecodesuccess .ge. 1 ) then @@ -152,8 +152,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & if(is.eq.2) ic0=max(1,ic0-1) if(is.eq.3) ic0=min(NSPM,ic0+1) ct=cshift(c,ic0-1) - call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess, & - recent_calls,nrecent) + call msk144decodeframe(ct,softbits,msgreceived,ndecodesuccess) if(ndecodesuccess .gt. 0) then tdec=tsec+xmc(iavg)*tframe goto 900 @@ -209,7 +208,7 @@ subroutine mskrtd(id2,nutc0,tsec,ntol,nrxfreq,ndepth,mycall,mygrid,hiscall, & msglast=msgreceived nsnrlast=nsnr if(.not. bshdecode) then - call update_hasharray(recent_calls,nrecent,nhasharray) + call update_hasharray(nhasharray) endif if( .not.bshdecode ) then write(line,1020) nutc0,nsnr,tdec,nint(fest),decsym,msgreceived(1:22), & diff --git a/lib/update_hasharray.f90 b/lib/update_hasharray.f90 index 0f9c872e8..4ccbba51c 100644 --- a/lib/update_hasharray.f90 +++ b/lib/update_hasharray.f90 @@ -1,12 +1,12 @@ -subroutine update_hasharray(recent_calls,nrecent,nhasharray) - - character*12 recent_calls(nrecent) +subroutine update_hasharray(nhasharray) + + use packjt77 character*22 hashmsg - integer nhasharray(nrecent,nrecent) + integer nhasharray(MAXRECENT,MAXRECENT) nhasharray=-1 - do i=1,nrecent - do j=i+1,nrecent + do i=1,MAXRECENT + do j=i+1,MAXRECENT if( recent_calls(i)(1:1) .ne. ' ' .and. recent_calls(j)(1:1) .ne. ' ' ) then hashmsg=trim(recent_calls(i))//' '//trim(recent_calls(j)) call fmtmsg(hashmsg,iz) From d66724f6e9dd8fd8f1340aec9e5c0ebf45a681ac Mon Sep 17 00:00:00 2001 From: Steve Franke Date: Mon, 24 Sep 2018 15:14:19 -0500 Subject: [PATCH 3/3] Fix a comment. --- lib/77bit/packjt77.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/77bit/packjt77.f90 b/lib/77bit/packjt77.f90 index 6b1686537..073cfb6e7 100644 --- a/lib/77bit/packjt77.f90 +++ b/lib/77bit/packjt77.f90 @@ -1,6 +1,6 @@ module packjt77 -! These variables are accessible from outside via "use packjt": +! These variables are accessible from outside via "use packjt77": parameter (MAXHASH=1000,MAXRECENT=10) character*13 callsign(MAXHASH) integer ihash10(MAXHASH),ihash12(MAXHASH),ihash22(MAXHASH)