mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-20 02:52:00 -05:00
Added "Pseudo-Linrad" test programs.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/map65@394 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
24dadb7aac
commit
b163a8a765
23
plrr.f90
Normal file
23
plrr.f90
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
program plrr
|
||||||
|
|
||||||
|
! Pseudo-Linrad "Receive" program
|
||||||
|
|
||||||
|
integer*1 userx_no,iusb
|
||||||
|
integer*2 nblock
|
||||||
|
real*8 center_freq,buf8
|
||||||
|
common/plrscom/center_freq,msec,fselect,iptr,nblock,userx_no,iusb,buf8(174)
|
||||||
|
! 8 4 4 4 2 1 1 1392
|
||||||
|
|
||||||
|
call setup_rsocket
|
||||||
|
|
||||||
|
npkt=0
|
||||||
|
|
||||||
|
10 call recv_pkt(center_freq)
|
||||||
|
npkt=npkt+1
|
||||||
|
if(mod(npkt,1000).eq.0) write(*,1010) npkt,center_freq,0.001*msec,fselect
|
||||||
|
1010 format('npkt:',i10,' f0:',f8.3,' t:',f10.3,' fselect:',f10.3)
|
||||||
|
go to 10
|
||||||
|
|
||||||
|
end program plrr
|
||||||
|
|
||||||
|
! To compile: % gfortran -o plrr plrr.f90 plrr_subs.c
|
63
plrr_subs.c
Normal file
63
plrr_subs.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define HELLO_PORT 50004
|
||||||
|
#define HELLO_GROUP "239.255.0.0"
|
||||||
|
#define MSGBUFSIZE 1416
|
||||||
|
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
void setup_rsocket_(void)
|
||||||
|
{
|
||||||
|
struct ip_mreq mreq;
|
||||||
|
u_int yes=1;
|
||||||
|
|
||||||
|
/* create what looks like an ordinary UDP socket */
|
||||||
|
if ((fd=socket(AF_INET,SOCK_DGRAM,0)) < 0) {
|
||||||
|
perror("socket");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allow multiple sockets to use the same PORT number */
|
||||||
|
if (setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes)) < 0) {
|
||||||
|
perror("Reusing ADDR failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set up destination address */
|
||||||
|
memset(&addr,0,sizeof(addr));
|
||||||
|
addr.sin_family=AF_INET;
|
||||||
|
addr.sin_addr.s_addr=htonl(INADDR_ANY); /* N.B.: differs from sender */
|
||||||
|
addr.sin_port=htons(HELLO_PORT);
|
||||||
|
|
||||||
|
/* bind to receive address */
|
||||||
|
if (bind(fd,(struct sockaddr *) &addr,sizeof(addr)) < 0) {
|
||||||
|
perror("bind");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* use setsockopt() to request that the kernel join a multicast group */
|
||||||
|
mreq.imr_multiaddr.s_addr=inet_addr(HELLO_GROUP);
|
||||||
|
mreq.imr_interface.s_addr=htonl(INADDR_ANY);
|
||||||
|
if (setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq)) < 0) {
|
||||||
|
perror("setsockopt");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void recv_pkt_(char buf[])
|
||||||
|
{
|
||||||
|
int addrlen,nbytes;
|
||||||
|
addrlen=sizeof(addr);
|
||||||
|
if ((nbytes=recvfrom(fd,buf,1416,0,
|
||||||
|
(struct sockaddr *) &addr,&addrlen)) < 0) {
|
||||||
|
perror("recvfrom");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
70
plrs.f90
Normal file
70
plrs.f90
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
program plrs
|
||||||
|
|
||||||
|
! Pseudo-Linrad "Send" program. Reads recorded Linrad data from "*.tf2"
|
||||||
|
! files, and multicasts it as Linrad would do for timf2 data.
|
||||||
|
|
||||||
|
integer RMODE
|
||||||
|
parameter(RMODE=0)
|
||||||
|
parameter (NBPP=1392,NPPR=184)
|
||||||
|
parameter (NBYTES=NBPP*NPPR,NZ=NBYTES/8)
|
||||||
|
parameter (NRECS=1979)
|
||||||
|
integer*1 userx_no,iusb
|
||||||
|
integer*2 nblock
|
||||||
|
real*8 d(NZ),buf8
|
||||||
|
integer fd
|
||||||
|
integer open,read,close
|
||||||
|
character*8 fname
|
||||||
|
real*8 center_freq,dmsec,dtmspacket
|
||||||
|
common/plrscom/center_freq,msec,fselect,iptr,nblock,userx_no,iusb,buf8(174)
|
||||||
|
! 8 4 4 4 2 1 1 1392
|
||||||
|
fname="all.tf2"//char(0)
|
||||||
|
iters=1
|
||||||
|
|
||||||
|
userx_no=0
|
||||||
|
iusb=1
|
||||||
|
center_freq=144.125d0
|
||||||
|
dtmspacket=1000.d0*NBPP/(8.d0*96000.d0)
|
||||||
|
fselect=128.0 + 1.6 + 0.220
|
||||||
|
npkt=0
|
||||||
|
|
||||||
|
call setup_ssocket !Open a socket for multicasting
|
||||||
|
|
||||||
|
do iter=1,iters
|
||||||
|
fd=open(fname,RMODE) !Open file for reading
|
||||||
|
dmsec=-dtmspacket
|
||||||
|
nsec0=time()
|
||||||
|
|
||||||
|
do irec=1,NRECS
|
||||||
|
nr=read(fd,d,NBYTES)
|
||||||
|
if(nr.ne.NBYTES) then
|
||||||
|
print*,'Error reading file all.tf2'
|
||||||
|
go to 999
|
||||||
|
endif
|
||||||
|
|
||||||
|
k=0
|
||||||
|
do ipacket=1,NPPR
|
||||||
|
dmsec=dmsec+dtmspacket
|
||||||
|
msec=nint(dmsec)
|
||||||
|
do i=1,NBPP/8
|
||||||
|
k=k+1
|
||||||
|
buf8(i)=d(k)
|
||||||
|
enddo
|
||||||
|
call send_pkt(center_freq)
|
||||||
|
npkt=npkt+1
|
||||||
|
if(mod(npkt,100).eq.0) then
|
||||||
|
nsec=time()-nsec0
|
||||||
|
nwait=msec-1000*nsec
|
||||||
|
if(mod(npkt,1000).eq.0) write(*,1010) npkt,nsec,0.001*msec,nwait
|
||||||
|
1010 format('npkt:',i10,' nsec:',i6,' t:',f10.3,' nwait:',i8)
|
||||||
|
! Pace the data at close to its real-time rate
|
||||||
|
if(nwait.gt.0) call usleep(nwait*1000)
|
||||||
|
endif
|
||||||
|
enddo
|
||||||
|
enddo
|
||||||
|
i=close(fd)
|
||||||
|
enddo
|
||||||
|
|
||||||
|
|
||||||
|
999 end program plrs
|
||||||
|
|
||||||
|
! To compile: % gfortran -o plrs plrs.f90 plrs_subs.c cutil.c
|
39
plrs_subs.c
Normal file
39
plrs_subs.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define HELLO_PORT 50004
|
||||||
|
#define HELLO_GROUP "239.255.0.0"
|
||||||
|
|
||||||
|
struct sockaddr_in addr;
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
void setup_ssocket_(void)
|
||||||
|
{
|
||||||
|
struct ip_mreq mreq;
|
||||||
|
|
||||||
|
/* create what looks like an ordinary UDP socket */
|
||||||
|
if ((fd=socket(AF_INET,SOCK_DGRAM,0)) < 0) {
|
||||||
|
perror("socket");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set up destination address */
|
||||||
|
memset(&addr,0,sizeof(addr));
|
||||||
|
addr.sin_family=AF_INET;
|
||||||
|
addr.sin_addr.s_addr=inet_addr(HELLO_GROUP);
|
||||||
|
addr.sin_port=htons(HELLO_PORT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void send_pkt_(char buf[])
|
||||||
|
{
|
||||||
|
if (sendto(fd,buf,1416,0,(struct sockaddr *) &addr,
|
||||||
|
sizeof(addr)) < 0) {
|
||||||
|
perror("sendto");
|
||||||
|
exit(1);}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user