diff options
Diffstat (limited to 'gr-msdd6000/src/python_test')
-rw-r--r-- | gr-msdd6000/src/python_test/capture_tcp_one_set.py | 156 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/flood_udp.py | 60 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/halt.py | 40 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/newtest.py | 140 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/spectrogram.py | 87 | ||||
-rwxr-xr-x | gr-msdd6000/src/python_test/test_tcp.py | 78 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/test_tcp_fft.py | 78 | ||||
-rwxr-xr-x | gr-msdd6000/src/python_test/test_udp.py | 59 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_cap.py | 110 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_rate_test.py | 106 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py | 161 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py | 150 | ||||
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_test.py | 127 |
13 files changed, 0 insertions, 1352 deletions
diff --git a/gr-msdd6000/src/python_test/capture_tcp_one_set.py b/gr-msdd6000/src/python_test/capture_tcp_one_set.py deleted file mode 100644 index 7a106a63a..000000000 --- a/gr-msdd6000/src/python_test/capture_tcp_one_set.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -port = 10000 -host = "10.45.4.46" -#host = "10.45.4.41" -myaddr = ('',myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -#f_mhz = 2647; # roof ofdm -if(len(sys.argv)!= 3): - print "usage: %s fc_ghz decim_pow2_exponent"%(sys.argv[0]); - sys.exit(-1); - -f_mhz = float(sys.argv[1])*1000; -decim = int(sys.argv[2]); - -#f_mhz = 3500; -#f_mhz = 2600; -f_hz = 0; # offset -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65536; -#samples = 16777216; -samples = samples*4; #bytes of data we are requesting -samples=samples*2; -#decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -sets = 1; - -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -TCPSock.send(data); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; -while(TCPSock): - if(state==0): - data = TCPSock.recv(4); - [opcode] = struct.unpack("<I", data); - print "Opcode = %d"%(opcode); - if(opcode==1): - state = 1; - - elif(state==1): - data = TCPSock.recv(7*4); - args = struct.unpack("<IIIIIII", data); - print ["reply_len", "freq_mhz", "offset_hz", "gain", "sample_bytes", "decim", "sets_remain"]; - print args; - IQ_bytes = args[0] - 7*4; - state =2; - - elif(state==2): - data = TCPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -TCPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(nmags); -#plot(10*log10(nmags)); - -dlen = len(vals); -fftlen = (dlen-1024)/1024; - -fft_data = [] -for i in range(1, dlen-1025, 1024): - - t_in = []; - for ind in range(i, i+1024): - t_in.append(vals[ind]); - - #tmp = 20*log10(fftshift(fft(t_in))); - tmp = (fftshift(fft(t_in))); - - if(len(fft_data) == 0): - for ind in range(0,1024): - fft_data.append( tmp[ind] ); - else: - for ind in range(0,1024): - fft_data[ind] = fft_data[ind] + tmp[ind]; - -#fft_data = 20*log10(fftshift(fft(vals))); - - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - diff --git a/gr-msdd6000/src/python_test/flood_udp.py b/gr-msdd6000/src/python_test/flood_udp.py deleted file mode 100644 index e59208a7a..000000000 --- a/gr-msdd6000/src/python_test/flood_udp.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -my_udp_addr = ("10.45.1.229",10001); - -buf = 1024; - -#myport = random.randint(1025,65535); -#my_tcp_addr = ("10.45.1.229",myport); -#TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock.bind(my_tcp_addr); -#TCPSock.connect((msdd_host,msdd_port)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -SETS_STREAM = 0xffffffff; - -f_mhz = 2400; -f_hz = 1; -gain = 3; -samples = 512; -decim = 4; -#sets = 16; -sets = SETS_STREAM; -window = 3; -mode = 1; - - - -for first_byte in range(0,0xff): - for second_byte in range(0,0xff): - for third_byte in range(0,0xff): - data = struct.pack("!III", first_byte, second_byte,third_byte); - UDPSock.sendto(data, (msdd_host,msdd_port)) - - -# construct the 3 different request type packets -#fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -#raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -#stat_data = struct.pack("!II", 0x0000, 0x0000) - -# send appropriate udp request packet - - - - - - - - - diff --git a/gr-msdd6000/src/python_test/halt.py b/gr-msdd6000/src/python_test/halt.py deleted file mode 100644 index 0285f7817..000000000 --- a/gr-msdd6000/src/python_test/halt.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -halt_data = struct.pack("<II", 0x04, 0x00); -halt_data = struct.pack("<II", 0x04, 0x00); - -data = halt_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - -UDPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/newtest.py b/gr-msdd6000/src/python_test/newtest.py deleted file mode 100644 index 9596a0675..000000000 --- a/gr-msdd6000/src/python_test/newtest.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 100; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 12000; -samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -#raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain, samples, decim, sets); -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - -while(True): - print state; - if(state==0): - data = UDPSock.recv(4); - [opcode] = struct.unpack("<I", data); - print "Opcode = %d"%(opcode); - if(opcode==1): - - # if UDP mode and sets_stream requested, - # we do not get a header reply back, only data - if(sets == 0): - state = 1; - else: - state = 2; - - elif(state==1): - data = UDPSock.recv(7*4); - args = struct.unpack("<IIIIIII", data); - print ["reply_len", "freq_mhz", "offset_hz", "gain", "sample_bytes", "decim", "sets_remain"]; - print args; - IQ_bytes = args[0] - 7*4; - state =2; - - elif(state==2): - data = UDPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -UDPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(20*log10(nmags)); - -fft_data = 20*log10(fftshift(fft(vals))); - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - diff --git a/gr-msdd6000/src/python_test/spectrogram.py b/gr-msdd6000/src/python_test/spectrogram.py deleted file mode 100644 index 015dd9105..000000000 --- a/gr-msdd6000/src/python_test/spectrogram.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python - -fft_bins = 1024; -stride = 256; - -#filename = "output.dat"; -#decim = 4; -#Fs = (102.4/decim) * 1e6; - - -from gnuradio import gr; -from Numeric import *; -import FFT; -import numpy.fft; -from numpy import *; -from pylab import *; -import sys; - -if len(sys.argv) <2: - print "usage: %s filename <sample_rate_in_MSPS> <stride_samples>"%(sys.argv[0]); - sys.exit(-1); - -filename = sys.argv[1]; -fs = 0; -if(len(sys.argv)>2): - fs = float(sys.argv[2])*1000000; -print "opening %s.\n"%(filename); - -if(len(sys.argv)>=4): - stride = int(sys.argv[3]); - print "using stride = %d"%(stride); - -tb = gr.top_block(); -src = gr.file_source(gr.sizeof_gr_complex, filename, False) -sink = gr.vector_sink_c(); -tb.connect(src,sink); -tb.run(); - -data = sink.data(); -dataa = array(data); -datalen = len( data ); - -time_bins = (datalen - fft_bins) / stride; - -print "output vector :: fft_bins = %d, time_bins = %d\n"%(fft_bins,time_bins); - -start_idx = 0; - -b = numpy.zeros((time_bins, fft_bins), complex); -l = []; - -window = numpy.blackman(fft_bins); - -for i in range(0,time_bins): - - time_chunk = take( dataa, range(start_idx,start_idx + fft_bins), 0); - time_chunk = time_chunk * window; - fft_chunk = numpy.fft.fftshift(numpy.fft.fft(time_chunk)); - psd = 10*log10(fft_chunk * conj(fft_chunk)+0.001); - - b[i] = psd.real; - l.append( psd.real.tolist() ); - - start_idx = start_idx + stride; - -#c = array(b, 10); - -print b[0]; -c = array(b); -#l = c.tolist(); -print size(l); - -x = range(0,time_bins); -print size(x); -y = range(0,fft_bins); -print size(y); - -print size(l); - -contourf(l); -#contourf([x,y], l); -colorbar(); -show(); - -#print c[1,1]; - - diff --git a/gr-msdd6000/src/python_test/test_tcp.py b/gr-msdd6000/src/python_test/test_tcp.py deleted file mode 100755 index b02db815d..000000000 --- a/gr-msdd6000/src/python_test/test_tcp.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -myport = random.randint(1025,65535); - -port = 10000 -host = "10.45.4.43" -myaddr = ("10.45.1.229",myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock = socket(AF_INET,SOCK_DGRAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -f_mhz = 2400; -f_hz = 0; -gain = 2; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman -#samples = 0xffffffff; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -samples = 2; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -decim = 2; #0-8 -#decim = decim+16; # +16 to use 16bit instead of 32 bit -mode = 1; #0=IQ, 1=MAG, 2=MAGDB -sets = 0xffffffff; -#sets = 1; - -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -data = raw_data; - -#TCPSock.sendto(data, (host,port)) -TCPSock.send(data); - -print "sent" - - - -count = 0; -while(1): - data,addr = TCPSock.recvfrom(buf); - - print "got response" - - print "Data length: %d bytes."%(len(data)); - if(len(data)==12): - a,b,c = struct.unpack("!III",data); - print "%x,%x,%x"%(a,b,c); - - datavector = []; - - for d in data: - a = struct.unpack("<b",d); - datavector.append(a); - - print datavector; - - count = count + 1; - - if(count > 1): - sets = 3; - raw_data_2 = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); - TCPSock.send(raw_data_2); - - - -TCPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/test_tcp_fft.py b/gr-msdd6000/src/python_test/test_tcp_fft.py deleted file mode 100644 index b02db815d..000000000 --- a/gr-msdd6000/src/python_test/test_tcp_fft.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -myport = random.randint(1025,65535); - -port = 10000 -host = "10.45.4.43" -myaddr = ("10.45.1.229",myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock = socket(AF_INET,SOCK_DGRAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -f_mhz = 2400; -f_hz = 0; -gain = 2; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman -#samples = 0xffffffff; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -samples = 2; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -decim = 2; #0-8 -#decim = decim+16; # +16 to use 16bit instead of 32 bit -mode = 1; #0=IQ, 1=MAG, 2=MAGDB -sets = 0xffffffff; -#sets = 1; - -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -data = raw_data; - -#TCPSock.sendto(data, (host,port)) -TCPSock.send(data); - -print "sent" - - - -count = 0; -while(1): - data,addr = TCPSock.recvfrom(buf); - - print "got response" - - print "Data length: %d bytes."%(len(data)); - if(len(data)==12): - a,b,c = struct.unpack("!III",data); - print "%x,%x,%x"%(a,b,c); - - datavector = []; - - for d in data: - a = struct.unpack("<b",d); - datavector.append(a); - - print datavector; - - count = count + 1; - - if(count > 1): - sets = 3; - raw_data_2 = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); - TCPSock.send(raw_data_2); - - - -TCPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/test_udp.py b/gr-msdd6000/src/python_test/test_udp.py deleted file mode 100755 index fd93847e9..000000000 --- a/gr-msdd6000/src/python_test/test_udp.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -my_udp_addr = ("10.45.1.229",10001); - -buf = 1024; - -#myport = random.randint(1025,65535); -#my_tcp_addr = ("10.45.1.229",myport); -#TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock.bind(my_tcp_addr); -#TCPSock.connect((msdd_host,msdd_port)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -SETS_STREAM = 0xffffffff; - -f_mhz = 2400; -f_hz = 1; -gain = 3; -samples = 512; - -decim = 2; - -#sets = 16; -sets = SETS_STREAM; -window = 3; -mode = 1; - - -# construct the 3 different request type packets -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -# send appropriate udp request packet -UDPSock.sendto(raw_data, (msdd_host,msdd_port)) - -#TCPSock.send(raw_data); - - -print "sent request" - - -print "waiting for response" -data,addr = UDPSock.recvfrom(buf); - -print "got response" - -print data; diff --git a/gr-msdd6000/src/python_test/udp_stream_cap.py b/gr-msdd6000/src/python_test/udp_stream_cap.py deleted file mode 100644 index 6326f27c5..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_cap.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 1000; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -decim = 4; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -numbytes = 100 * 65536; - -num_rx = 0; -start = time.time(); - -d = []; -while(num_rx < numbytes): - data = UDPSock.recv(65536); - num_rx = num_rx + len(data); - d.append(data); - -mags = []; -for i in range(0, len(d)/4): - v = struct.unpack_from("<f",d, i*4); - mags.append(abs(v)); -plot(mags); -show(); - -end = time.time(); -print "recieved %d bytes in %f sec"%(numbytes, end-start); - -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(1+decim-16))); - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test.py b/gr-msdd6000/src/python_test/udp_stream_rate_test.py deleted file mode 100644 index 0b75f2372..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 1000; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) # ok -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = numtocap * numtocap; - -numbytes = 1000 * 65536; - -num_rx = 0; -start = -1; -while(num_rx < numbytes): - data = UDPSock.recv(65536); - - if(start==-1): - start = time.time(); - - num_rx = num_rx + len(data); -# print num_rx; - - -end = time.time(); -print "recieved %d bytes in %f sec"%(numbytes, end-start); - -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py b/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py deleted file mode 100644 index eef78f51b..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -from random import *; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',randint(1025,65535)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -f_mhz = 2500; - -print "fc = %d"%(f_mhz); - -f_hz = 0; -gain = 20; # attenuation -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65535*4*2; -#samples = 16384; -#samples = 16*1024*1024; -#samples = samples*4; #bytes of data we are requesting - -# decim 0-8 ( 3 - 8 ) -#decim = 5; # rate ok -decim = 8; -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -numbytes = 65536*100; -#numbytes = 65536*2; -#numbytes = 1024; - -num_rx = 0; -start = time.time(); -l = []; -arr = []; - -while(num_rx < numbytes): - data = UDPSock.recv(1024); - l.append(data); - num_rx = num_rx + len(data); - - -end = time.time(); - -# send stop command -halt_data = struct.pack(">II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - -# perform timing analysis -print "recieved %d bytes in %f sec"%(numbytes, end-start); -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - -# plot data -val_arr = []; -mag_arr = []; -mag_arr2 = []; - -print "Repacking data..." -f = open("out.dat","w"); -for li in l: - for p in range(0, len(li)/4): - [i,q] = struct.unpack_from("<hh", li, p*4); - val = complex(i,q); - mag_arr.append((val*conj(val)).real); - val_arr.append(val); - binchunk = struct.pack("<ff",float(val.real), float(val.imag) ); - f.write(binchunk); -f.close(); - - -dlen = len(val_arr)-1; -fft_data = []; -for i in range(1, dlen-1024, 1024*1024): - - t_in = []; - for ind in range(i, i+1024): - t_in.append(val_arr[ind]); - - tmp = 20*log10(fftshift(fft(t_in))); - #tmp = (fftshift(fft(t_in))); - - if(len(fft_data) == 0): - for ind in range(0,1024): - fft_data.append( tmp[ind] ); - else: - for ind in range(0,1024): - fft_data[ind] = fft_data[ind] + tmp[ind]; - - - - -print "Plotting..." -subplot(2,1,1); -plot(mag_arr); -title("T power"); -subplot(2,1,2); -plot(10*log10(fft_data)); -title("PSD"); -show(); - - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py b/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py deleted file mode 100644 index 185afc48c..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -#msdd_host = "10.45.4.43" -msdd_host = "10.45.4.45" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -f_mhz = 1500; -#f_mhz = 1000; -f_hz = 0; -gain = 80; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -# decim 0-8 ( 3 - 8 ) -#decim = 5; # rate ok -decim = 4; -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); -start = time.time(); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -#numbytes = 65536*100; -numbytes = 65536; - - - -while(True): - - data = []; - l = []; - num_rx = 0; - while(num_rx < numbytes): - data = UDPSock.recv(65536); - num_rx = num_rx + len(data); - l.append(data); - - end = time.time(); - - # send stop command - #halt_data = struct.pack("<II", 0x04, 0x00); - #UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - # perform timing analysis - print "recieved %d bytes in %f sec"%(numbytes, end-start); - bytes_per_sec = numbytes / (end-start); - samples_per_sec = bytes_per_sec / 4; - MSPS = samples_per_sec / 1000000.0; - - print "Got %f MSPS"%(MSPS); - print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - - # plot data - val_arr = []; - mag_arr = []; - - print "Repacking data..." - for li in l: - for p in range(0, len(li)/4): - [i,q] = struct.unpack_from("<hh", li, p); - val = complex(i,q); - mag_arr.append(abs(val)); - val_arr.append(val); - - - print "Calculating Time Domain Power..." - tpwr = []; - for i in val_arr: - tpwr.append( (i*conj(i)).real ); - - print "Calculating PSD..." - freqz = fft(val_arr); - - #freqz = []; - # - #for i in range(0, floor(len(val_arr)/2048)): - # tmp = val_arr(range(i,i+2048)); - # if len(freqz) == 0: - # freqz = tmp; - # - - psd = (freqz * conj(freqz)).real; - - print "Plotting..." - subplot(2,1,1); - plot(tpwr); - subplot(2,1,2); - plot(10*log10(psd)); - show(); - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_test.py b/gr-msdd6000/src/python_test/udp_stream_test.py deleted file mode 100644 index 6136d16c5..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_test.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 2500; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65535; -samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -while(True): - data = UDPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes % 200 == 0): - print IQ_bytes; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - - -UDPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(20*log10(nmags)); - -fft_data = 20*log10(fftshift(fft(vals))); - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - |