mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-10-31 15:47:10 -04:00
Add hash test. Add phase0 loop. Implement hash test in msk144d.f90 test program. Have not yet tested short messages with hash test.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6890 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
807d5e595b
commit
b0108d59be
@ -214,7 +214,7 @@ subroutine detectmsk144(cbig,n,pchk_file,lines,nmessages,nutc)
|
||||
if( crmax .gt. cmax ) ishort=1
|
||||
|
||||
! Find 6 largest peaks
|
||||
do ipk=1,6
|
||||
do ipk=1, 6
|
||||
iloc=maxloc(abs(cc))
|
||||
ic1=iloc(1)
|
||||
iloc=maxloc(dd)
|
||||
@ -246,7 +246,7 @@ subroutine detectmsk144(cbig,n,pchk_file,lines,nmessages,nutc)
|
||||
if( ibb .le. 3 ) ibb=ibb-1
|
||||
if( ibb .gt. 3 ) ibb=ibb-7
|
||||
|
||||
do id=1,3 ! slicer dither. bb is very good - may be able to remove this.
|
||||
do id=1,1 ! slicer dither. bb is very good - may be able to remove this.
|
||||
if( id .eq. 1 ) is=0
|
||||
if( id .eq. 2 ) is=-1
|
||||
if( id .eq. 3 ) is=1
|
||||
@ -314,80 +314,86 @@ subroutine detectmsk144(cbig,n,pchk_file,lines,nmessages,nutc)
|
||||
ffin=atan2(imag(cfac),real(cfac))/(twopi*56*6*dt)
|
||||
phase0=atan2(imag(cca+ccb),real(cca+ccb))
|
||||
|
||||
! Remove phase error - want constellation rotated so that sample points lie on I/Q axes
|
||||
cfac=cmplx(cos(phase0),sin(phase0))
|
||||
c=c*conjg(cfac)
|
||||
do ipha=1,3
|
||||
if( ipha.eq.2 ) phase0=phase0+20*pi/180.0
|
||||
if( ipha.eq.3 ) phase0=phase0-20*pi/180.0
|
||||
|
||||
if( nmatchedfilter .eq. 0 ) then
|
||||
! Remove phase error - want constellation rotated so that sample points lie on I/Q axes
|
||||
cfac=cmplx(cos(phase0),sin(phase0))
|
||||
c=c*conjg(cfac)
|
||||
|
||||
if( nmatchedfilter .eq. 0 ) then
|
||||
! sample to get softsamples
|
||||
do i=1,72
|
||||
softbits(2*i-1)=imag(c(1+(i-1)*12))
|
||||
softbits(2*i)=real(c(7+(i-1)*12))
|
||||
enddo
|
||||
else
|
||||
do i=1,72
|
||||
softbits(2*i-1)=imag(c(1+(i-1)*12))
|
||||
softbits(2*i)=real(c(7+(i-1)*12))
|
||||
enddo
|
||||
else
|
||||
! matched filter -
|
||||
! how much mismatch does the RX/TX/analytic filter cause?, how rig (pair) dependent is this loss?
|
||||
softbits(1)=sum(imag(c(1:6))*pp(7:12))+sum(imag(c(864-5:864))*pp(1:6))
|
||||
softbits(2)=sum(real(c(1:12))*pp)
|
||||
do i=2,72
|
||||
softbits(2*i-1)=sum(imag(c(1+(i-1)*12-6:1+(i-1)*12+5))*pp)
|
||||
softbits(2*i)=sum(real(c(7+(i-1)*12-6:7+(i-1)*12+5))*pp)
|
||||
enddo
|
||||
endif
|
||||
softbits(1)=sum(imag(c(1:6))*pp(7:12))+sum(imag(c(864-5:864))*pp(1:6))
|
||||
softbits(2)=sum(real(c(1:12))*pp)
|
||||
do i=2,72
|
||||
softbits(2*i-1)=sum(imag(c(1+(i-1)*12-6:1+(i-1)*12+5))*pp)
|
||||
softbits(2*i)=sum(real(c(7+(i-1)*12-6:7+(i-1)*12+5))*pp)
|
||||
enddo
|
||||
endif
|
||||
|
||||
! sync word hard error weight is a good discriminator for
|
||||
! frames that have reasonable probability of decoding
|
||||
hardbits=0
|
||||
do i=1,144
|
||||
if( softbits(i) .ge. 0.0 ) then
|
||||
hardbits(i)=1
|
||||
endif
|
||||
enddo
|
||||
nbadsync1=(8-sum( (2*hardbits(1:8)-1)*s8 ) )/2
|
||||
nbadsync2=(8-sum( (2*hardbits(1+56:8+56)-1)*s8 ) )/2
|
||||
nbadsync=nbadsync1+nbadsync2
|
||||
if( nbadsync .gt. 4 ) cycle
|
||||
hardbits=0
|
||||
do i=1,144
|
||||
if( softbits(i) .ge. 0.0 ) then
|
||||
hardbits(i)=1
|
||||
endif
|
||||
enddo
|
||||
nbadsync1=(8-sum( (2*hardbits(1:8)-1)*s8 ) )/2
|
||||
nbadsync2=(8-sum( (2*hardbits(1+56:8+56)-1)*s8 ) )/2
|
||||
nbadsync=nbadsync1+nbadsync2
|
||||
if( nbadsync .gt. 4 ) cycle
|
||||
|
||||
! normalize the softsymbols before submitting to decoder
|
||||
sav=sum(softbits)/144
|
||||
s2av=sum(softbits*softbits)/144
|
||||
ssig=sqrt(s2av-sav*sav)
|
||||
softbits=softbits/ssig
|
||||
sav=sum(softbits)/144
|
||||
s2av=sum(softbits*softbits)/144
|
||||
ssig=sqrt(s2av-sav*sav)
|
||||
softbits=softbits/ssig
|
||||
|
||||
sigma=0.75
|
||||
lratio(1:48)=softbits(9:9+47)
|
||||
lratio(49:128)=softbits(65:65+80-1)
|
||||
lratio=exp(2.0*lratio/(sigma*sigma))
|
||||
sigma=0.75
|
||||
lratio(1:48)=softbits(9:9+47)
|
||||
lratio(49:128)=softbits(65:65+80-1)
|
||||
lratio=exp(2.0*lratio/(sigma*sigma))
|
||||
|
||||
unscrambledsoftbits(1:127:2)=lratio(1:64)
|
||||
unscrambledsoftbits(2:128:2)=lratio(65:128)
|
||||
unscrambledsoftbits(1:127:2)=lratio(1:64)
|
||||
unscrambledsoftbits(2:128:2)=lratio(65:128)
|
||||
|
||||
max_iterations=10
|
||||
max_dither=1
|
||||
call ldpc_decode(unscrambledsoftbits, decoded, &
|
||||
max_iterations=10
|
||||
max_dither=1
|
||||
call ldpc_decode(unscrambledsoftbits, decoded, &
|
||||
max_iterations, niterations, max_dither, ndither)
|
||||
|
||||
if( niterations .ge. 0.0 ) then
|
||||
call extractmessage144(decoded,msgreceived,nhashflag)
|
||||
if( nhashflag .gt. 0 ) then ! CRCs match, so print it
|
||||
ndupe=0
|
||||
do im=1,nmessages
|
||||
if( allmessages(im) .eq. msgreceived ) ndupe=1
|
||||
enddo
|
||||
if( ndupe .eq. 0 ) then
|
||||
nmessages=nmessages+1
|
||||
allmessages(nmessages)=msgreceived
|
||||
write(lines(nmessages),1020) nutc,nsnr,t0,nint(fest),msgreceived
|
||||
1020 format(i6.6,i4,f5.1,i5,' & ',a22)
|
||||
if( niterations .ge. 0.0 ) then
|
||||
call extractmessage144(decoded,msgreceived,nhashflag)
|
||||
if( nhashflag .gt. 0 ) then ! CRCs match, so print it
|
||||
ndupe=0
|
||||
do im=1,nmessages
|
||||
if( allmessages(im) .eq. msgreceived ) ndupe=1
|
||||
enddo
|
||||
if( ndupe .eq. 0 ) then
|
||||
nmessages=nmessages+1
|
||||
allmessages(nmessages)=msgreceived
|
||||
write(lines(nmessages),1020) nutc,nsnr,t0,nint(fest),msgreceived
|
||||
1020 format(i6.6,i4,f5.1,i5,' & ',a22)
|
||||
endif
|
||||
goto 999
|
||||
else
|
||||
msgreceived=' '
|
||||
ndither=-99 ! -99 is bad hash flag
|
||||
! write(78,1001) nutc,t0,nsnr,ic,ipk,is,idf,iav,ipha,deltaf,fest,ferr,ferr2, &
|
||||
! ffin,bba,bbp,nbadsync1,nbadsync2, &
|
||||
! phase0,niterations,ndither,msgreceived
|
||||
endif
|
||||
goto 999
|
||||
else
|
||||
msgreceived=' '
|
||||
ndither=-99 ! -99 is bad hash flag
|
||||
! write(78,1001) nutc,t0,nsnr,ic,ipk,is,idf,iav,deltaf,fest,ferr,ferr2,ffin,bba,bbp,nbadsync1,nbadsync2, &
|
||||
! phase0,niterations,ndither,msgreceived
|
||||
endif
|
||||
endif
|
||||
enddo ! phase dither
|
||||
enddo ! frame averaging loop
|
||||
enddo ! frequency dithering loop
|
||||
enddo ! sample-time dither loop
|
||||
@ -397,10 +403,11 @@ subroutine detectmsk144(cbig,n,pchk_file,lines,nmessages,nutc)
|
||||
ndither=-98
|
||||
999 continue
|
||||
if( nmessages .ge. 1 ) then
|
||||
! write(78,1001) nutc,t0,nsnr,ic,ipk,is,idf,iav,deltaf,fest,ferr,ferr2,ffin,bba,bbp,nbadsync1,nbadsync2, &
|
||||
! phase0,niterations,ndither,msgreceived
|
||||
call flush(78)
|
||||
!1001 format(i6.6,f8.2,i5,i5,i5,i5,i5,i5,f8.2,f8.2,f8.2,f8.2,f8.2,f10.2,f8.2,i5,i5,f8.2,i5,i5,2x,a22)
|
||||
! write(78,1001) nutc,t0,nsnr,ic,ipk,is,idf,iav,ipha,deltaf,fest,ferr,ferr2, &
|
||||
! ffin,bba,bbp,nbadsync1,nbadsync2, &
|
||||
! phase0,niterations,ndither,msgreceived
|
||||
! call flush(78)
|
||||
!1001 format(i6.6,f8.2,i5,i5,i5,i5,i5,i5,i5,f8.2,f8.2,f8.2,f8.2,f8.2,f10.2,f8.2,i5,i5,f8.2,i5,i5,2x,a22)
|
||||
exit
|
||||
endif
|
||||
enddo
|
||||
|
@ -99,7 +99,7 @@ subroutine detectmsk32(cbig,n,mycall,partnercall,lines,nmessages,nutc)
|
||||
|
||||
! Define the 32 likely messages
|
||||
do irpt=0,31
|
||||
hashmsg=mycall//' '//partnercall//' '//rpt(irpt)
|
||||
hashmsg=trim(mycall)//' '//trim(partnercall)//' '//rpt(irpt)
|
||||
call fmtmsg(hashmsg,iz)
|
||||
call hash(hashmsg,22,ihash)
|
||||
ihash=iand(ihash,127)
|
||||
@ -107,7 +107,7 @@ subroutine detectmsk32(cbig,n,mycall,partnercall,lines,nmessages,nutc)
|
||||
likelymessages(irpt)=ig
|
||||
! write(*,*) irpt,hashmsg,ig,ig24(ig)
|
||||
enddo
|
||||
qsocontext=.false.
|
||||
qsocontext=.true.
|
||||
|
||||
! Fill the detmet, detferr arrays
|
||||
nstepsize=48 ! 4ms steps
|
||||
@ -196,6 +196,7 @@ subroutine detectmsk32(cbig,n,mycall,partnercall,lines,nmessages,nutc)
|
||||
lines=char(0)
|
||||
|
||||
imsgbest=-99
|
||||
nbadsyncbest=99
|
||||
cdbest=1e32
|
||||
cdratbest=0.0
|
||||
|
||||
@ -414,36 +415,42 @@ subroutine detectmsk32(cbig,n,mycall,partnercall,lines,nmessages,nutc)
|
||||
nbadsyncbest = nbadsync
|
||||
if( ( ihammd(imsgbest)+nbadsyncbest .le. 4 ) .and. ( (cdratbest .gt. 100.0) .and. (cdbest .le. 0.05) ) ) goto 999
|
||||
endif
|
||||
enddo ! phase loop
|
||||
enddo ! frame averaging loop
|
||||
enddo ! frequency dithering loop
|
||||
enddo ! phase loop
|
||||
enddo ! frame averaging loop
|
||||
enddo ! frequency dithering loop
|
||||
enddo ! sample-time dither loop
|
||||
enddo ! peak loop - could be made more efficient by working harder to find good peaks
|
||||
enddo ! peak loop
|
||||
|
||||
msgreceived=' '
|
||||
! write(78,1001) nutc,t0,nsnr,ic,ipk,is,idf,iav,deltaf,fest,ferr,ferr2,ffin,bba,bbp,nbadsync, &
|
||||
! phase0,msgreceived
|
||||
! call flush(78)
|
||||
!1001 format(i6.6,f8.2,i5,i5,i5,i5,i5,i5,f8.2,f8.2,f8.2,f8.2,f8.2,f10.2,f8.2,i5,f8.2,2x,a22)
|
||||
enddo
|
||||
999 continue
|
||||
if( imsgbest .ge. 0 ) then
|
||||
if( ( ihammd(imsgbest)+nbadsyncbest .le. 4 ) .and. ( (cdratbest .gt. 50.0) .and. (cdbest .le. 0.05) ) ) then
|
||||
if( qsocontext ) then
|
||||
nrxrpt=iand(likelymessages(imsgbest),31)
|
||||
nrxhash=(likelymessages(imsgbest)-nrxrpt)/32
|
||||
imessage=likelymessages(imsgbest)
|
||||
else
|
||||
nrxrpt=iand(imsgbest,31)
|
||||
nrxhash=(imsgbest-nrxrpt)/32
|
||||
imessage=imsgbest
|
||||
endif
|
||||
nmessages=1
|
||||
write(msgreceived,'(a1,i3,a1,1x,a4)') "<",nrxhash,">",rpt(nrxrpt)
|
||||
write(lines(nmessages),1020) nutc,nsnr,t0,nint(fest),msgreceived
|
||||
1020 format(i6.6,i4,f5.1,i5,' & ',a22)
|
||||
msgreceived=' '
|
||||
if( ( ihammd(imsgbest)+nbadsyncbest .le. 4 ) .and. ( (cdratbest .gt. 50.0) .and. (cdbest .le. 0.05) ) ) then
|
||||
if( qsocontext ) then
|
||||
nrxrpt=iand(likelymessages(imsgbest),31)
|
||||
nrxhash=(likelymessages(imsgbest)-nrxrpt)/32
|
||||
imessage=likelymessages(imsgbest)
|
||||
else
|
||||
nrxrpt=iand(imsgbest,31)
|
||||
nrxhash=(imsgbest-nrxrpt)/32
|
||||
imessage=imsgbest
|
||||
endif
|
||||
|
||||
! write(*,1022) nutc,ipbest,times(ipbest),snrs(ipbest),fest,nrxrpt,nrxhash, &
|
||||
! See if this message has a hash that is expected for a message sent to mycall by partnercall
|
||||
hashmsg=trim(mycall)//' '//trim(partnercall)//' '//rpt(nrxrpt)
|
||||
call fmtmsg(hashmsg,iz)
|
||||
call hash(hashmsg,22,ihash)
|
||||
ihash=iand(ihash,127)
|
||||
if( nrxhash .eq. ihash ) then
|
||||
nmessages=1
|
||||
write(msgreceived,'(a1,a,1x,a,a1,1x,a4)') "<",trim(mycall),trim(partnercall),">",rpt(nrxrpt)
|
||||
write(lines(nmessages),1020) nutc,nsnr,t0,nint(fest),msgreceived
|
||||
1020 format(i6.6,i4,f5.1,i5,' & ',a22)
|
||||
|
||||
! write(*,1022) nutc,ipbest,times(ipbest),snrs(ipbest),fest,nrxrpt,nrxhash, &
|
||||
! rpt(nrxrpt),imessage,ig24(imessage),ihammd(imsgbest), &
|
||||
! cdbest,cdratbest,nbadsyncbest,ipkbest,idbest,idfbest,iavbest,iphabest
|
||||
endif
|
||||
|
@ -14,14 +14,16 @@ program msk144d
|
||||
type(wav_header) :: wav
|
||||
integer*2 id2(30*12000)
|
||||
character*500 infile
|
||||
character*12 mycall,hiscall
|
||||
character(len=500) optarg
|
||||
|
||||
type (option) :: long_options(2) = [ &
|
||||
option ('help',.false.,'h','Display this help message',''), &
|
||||
option ('ntrials',.true.,'n','number of trials, default TRIALS=10000','TRIALS') &
|
||||
type (option) :: long_options(3) = [ &
|
||||
option ('help',.false.,'h','Display this help message',''), &
|
||||
option ('mycall',.true.,'c','mycall',''), &
|
||||
option ('hiscall',.true.,'x','hiscall','') &
|
||||
]
|
||||
do
|
||||
call getopt('hn:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
||||
call getopt('c:hx:',long_options,c,optarg,narglen,nstat,noffset,nremain,.true.)
|
||||
if( nstat .ne. 0 ) then
|
||||
exit
|
||||
end if
|
||||
@ -30,6 +32,10 @@ program msk144d
|
||||
display_help = .true.
|
||||
case ('n')
|
||||
read (optarg(:narglen), *) ntrials
|
||||
case ('c')
|
||||
read (optarg(:narglen), *) mycall
|
||||
case ('x')
|
||||
read (optarg(:narglen), *) hiscall
|
||||
end select
|
||||
end do
|
||||
|
||||
@ -65,7 +71,7 @@ program msk144d
|
||||
read(unit=wav%lun) id2(1:npts)
|
||||
close(unit=wav%lun)
|
||||
call timer('read ',1)
|
||||
call msk144_decode(id2,npts,nutc,1,pchk_file,line)
|
||||
call msk144_decode(id2,npts,nutc,1,pchk_file,mycall,hiscall,line)
|
||||
enddo
|
||||
|
||||
call timer('msk144 ',1)
|
||||
|
Loading…
Reference in New Issue
Block a user