diff options
author | n4hy | 2008-07-04 01:26:58 +0000 |
---|---|---|
committer | n4hy | 2008-07-04 01:26:58 +0000 |
commit | ae0ca251c8384b97ef1ba69a13c02227a57eaa54 (patch) | |
tree | b6c309a320c12f8798878461b83b110e9a6d2578 /gr-msdd6000/src/python_test/udp_stream_cap.py | |
parent | 20615905cd0bf22772740d132be439bcf7ec4d8d (diff) | |
download | gnuradio-ae0ca251c8384b97ef1ba69a13c02227a57eaa54.tar.gz gnuradio-ae0ca251c8384b97ef1ba69a13c02227a57eaa54.tar.bz2 gnuradio-ae0ca251c8384b97ef1ba69a13c02227a57eaa54.zip |
cleaning up and putting much better code in. Step 1 of 2
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8778 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gr-msdd6000/src/python_test/udp_stream_cap.py')
-rw-r--r-- | gr-msdd6000/src/python_test/udp_stream_cap.py | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/gr-msdd6000/src/python_test/udp_stream_cap.py b/gr-msdd6000/src/python_test/udp_stream_cap.py new file mode 100644 index 000000000..6326f27c5 --- /dev/null +++ b/gr-msdd6000/src/python_test/udp_stream_cap.py @@ -0,0 +1,110 @@ +#!/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(); + |