mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-09-06 21:36:44 -04:00
Corrected mouse DF readout at top of SpecJT. Added AGC based on rxnoise. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/map65@413 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
104 lines
2.6 KiB
Fortran
104 lines
2.6 KiB
Fortran
!---------------------------------------------------- recvpkt
|
|
subroutine recvpkt(iarg)
|
|
|
|
! Receive timf2 packets from Linrad, stuff data into id().
|
|
! This routine runs in a background thread and will never return.
|
|
|
|
#ifdef Win32
|
|
use dflib
|
|
#endif
|
|
|
|
parameter (NSZ=2*60*96000)
|
|
real*8 d8(NSZ)
|
|
integer*1 userx_no,iusb
|
|
integer*2 nblock,nblock0
|
|
logical first
|
|
real*8 center_freq,buf8
|
|
common/plrscom/center_freq,msec,fqso,iptr,nblock,userx_no,iusb,buf8(174)
|
|
! 8 4 4 4 2 1 1 1392
|
|
include 'datcom.f90'
|
|
include 'gcom1.f90'
|
|
include 'gcom2.f90'
|
|
equivalence (id,d8)
|
|
data nblock0/0/,first/.true./,kb/1/,ntx/0/
|
|
data sqave/0.0/,u/0.001/,rxnoise/0.0/
|
|
save
|
|
|
|
! Open a socket to receive multicast data from Linrad
|
|
call setup_rsocket
|
|
nreset=-1
|
|
k=0
|
|
nsec0=-999
|
|
|
|
10 call recv_pkt(center_freq)
|
|
lost=nblock-nblock0-1
|
|
if(lost.ne.0 .and. .not.first) then
|
|
! print*,'Lost packets?',nblock,nblock0,lost,rxnoise
|
|
nlost=nlost + lost
|
|
do i=1,174*lost
|
|
k=k+1
|
|
d8(k)=0
|
|
enddo
|
|
endif
|
|
first=.false.
|
|
nblock0=nblock
|
|
|
|
if(monitoring.eq.1) then
|
|
nsec=msec/1000
|
|
if(mod(nsec,60).eq.1) nreset=1
|
|
if(mod(nsec,60).eq.0 .and. nreset.eq.1) then
|
|
! This is the start of a new minute, switch buffers
|
|
nreset=0
|
|
kb=3-kb
|
|
k=0
|
|
if(kb.eq.2) k=NSMAX
|
|
nlost=0
|
|
endif
|
|
|
|
if(kb.eq.1 .and. (k+174).gt.NSMAX) go to 20
|
|
if(kb.eq.2 .and. (k+174).gt.2*NSMAX) go to 20
|
|
|
|
if(transmitting.eq.0) then
|
|
sq=0.
|
|
do i=1,174
|
|
k=k+1
|
|
d8(k)=buf8(i)
|
|
sq=sq + float(id(1,k,1))**2 + float(id(1,k,1))**2 + &
|
|
float(id(1,k,1))**2 + float(id(1,k,1))**2
|
|
enddo
|
|
sqave=sqave + u*(sq-sqave)
|
|
rxnoise=10.0*log10(sqave) - 48.0
|
|
else
|
|
do i=1,174
|
|
k=k+1
|
|
d8(k)=0.d0
|
|
enddo
|
|
endif
|
|
if(k.lt.1 .or. k.gt.NSZ) then
|
|
print*,'Error in recvpkt: ',k,NSZ,NSMAX
|
|
stop
|
|
endif
|
|
|
|
20 if(nsec.ne.nsec0) then
|
|
mutch=nsec/3600
|
|
mutcm=mod(nsec/60,60)
|
|
mutc=100*mutch + mutcm
|
|
ns=mod(nsec,60)
|
|
! write(*,1010) mutc,ns,0.001*msec,k,rxnoise
|
|
!1010 format('UTC:',i5.4,' ns:',i3,' t:',f10.3,' k:',i8)
|
|
nsec0=nsec
|
|
ntx=ntx+transmitting
|
|
if(mod(nsec,60).eq.52) then
|
|
kbuf=kb
|
|
nutc=mutc
|
|
klost=nlost
|
|
if(ntx.lt.20) ndecoding=1
|
|
ntx=0
|
|
endif
|
|
endif
|
|
|
|
endif
|
|
go to 10
|
|
|
|
end subroutine recvpkt
|