11 from numpy.fft import *;
14 myport = random.randint(1025,65535);
15 filename = "output.dat";
18 msdd_host = "10.45.4.46"
22 my_udp_addr = ('',10001);
23 my_udp_addr = ('10.45.1.229 ',10001);
25 UDPSock = socket(AF_INET,SOCK_DGRAM);
26 UDPSock.bind(my_udp_addr);
33 window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman
36 samples = samples*4; #bytes of data we are requesting
38 decim = 2; #0-8 (3 => 2^3 = 8)
39 decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats
40 mode = 0; #0=IQ, 1=MAG, 2=MAGDB
45 request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields
46 print "request len = %d"%(request_len);
48 raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets);
52 UDPSock.sendto(data, (msdd_host, msdd_port));
73 IQ_bytes = 4 * numtocap;
76 data = UDPSock.recv(4);
77 [i,q] = struct.unpack("<hh", data);
82 mags.append(abs(tmp));
85 sample_count = sample_count + 1;
86 # print "sample count %d"%(sample_count)
88 IQ_bytes = IQ_bytes - 4;
89 if(IQ_bytes % 200 == 0):
92 print "got all data (total %d)"%(sample_count);
93 print "remaining: %d"%(IQ_bytes);
97 halt_data = struct.pack("<II", 0x04, 0x00);
98 UDPSock.sendto(halt_data, (msdd_host, msdd_port));
113 plot(20*log10(nmags));
115 fft_data = 20*log10(fftshift(fft(vals)));
121 f = open(filename, "w");
123 binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) );