summaryrefslogtreecommitdiff
path: root/gr-msdd6000/src/python_test/test_tcp_fft.py
diff options
context:
space:
mode:
authorn4hy2008-07-04 01:26:58 +0000
committern4hy2008-07-04 01:26:58 +0000
commitae0ca251c8384b97ef1ba69a13c02227a57eaa54 (patch)
treeb6c309a320c12f8798878461b83b110e9a6d2578 /gr-msdd6000/src/python_test/test_tcp_fft.py
parent20615905cd0bf22772740d132be439bcf7ec4d8d (diff)
downloadgnuradio-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/test_tcp_fft.py')
-rw-r--r--gr-msdd6000/src/python_test/test_tcp_fft.py78
1 files changed, 78 insertions, 0 deletions
diff --git a/gr-msdd6000/src/python_test/test_tcp_fft.py b/gr-msdd6000/src/python_test/test_tcp_fft.py
new file mode 100644
index 000000000..b02db815d
--- /dev/null
+++ b/gr-msdd6000/src/python_test/test_tcp_fft.py
@@ -0,0 +1,78 @@
+#!/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();
+
+
+