diff options
Diffstat (limited to 'gr-msdd6000/src/python')
-rw-r--r-- | gr-msdd6000/src/python/Makefile.am | 48 | ||||
-rwxr-xr-x | gr-msdd6000/src/python/qa_msdd6000.py | 40 | ||||
-rw-r--r-- | gr-msdd6000/src/python/run_tests.in | 10 | ||||
-rwxr-xr-x | gr-msdd6000/src/python/test_tcp.py | 78 | ||||
-rwxr-xr-x | gr-msdd6000/src/python/test_udp.py | 40 |
5 files changed, 216 insertions, 0 deletions
diff --git a/gr-msdd6000/src/python/Makefile.am b/gr-msdd6000/src/python/Makefile.am new file mode 100644 index 000000000..38040eb3c --- /dev/null +++ b/gr-msdd6000/src/python/Makefile.am @@ -0,0 +1,48 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +EXAMPLE_FILES = + +EXTRA_DIST = run_tests.in \ + $(EXAMPLE_FILES) + +ourdatadir = $(exampledir)/msdd6000 +ourdata_DATA = $(EXAMPLE_FILES) + +noinst_PYTHON = \ + qa_msdd6000.py \ + test_udp.py \ + test_tcp.py + +TESTS = \ + run_tests + + +# Make example scripts with #! executable +install-data-local: install-ourdataDATA + for i in `find $(ourdatadir) -type f ! -perm 755`; do \ + if head -1 $$i | grep -q '^#!'; then \ + chmod 755 $$i; \ + echo "made executable: $$i"; \ + fi; \ + done diff --git a/gr-msdd6000/src/python/qa_msdd6000.py b/gr-msdd6000/src/python/qa_msdd6000.py new file mode 100755 index 000000000..fdcf7e83d --- /dev/null +++ b/gr-msdd6000/src/python/qa_msdd6000.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +from gnuradio import gr, gr_unittest +import msdd + +class qa_usrp (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_000_nop (self): + """Just see if we can import the module... + """ + pass + +if __name__ == '__main__': + gr_unittest.main () diff --git a/gr-msdd6000/src/python/run_tests.in b/gr-msdd6000/src/python/run_tests.in new file mode 100644 index 000000000..28e4c731c --- /dev/null +++ b/gr-msdd6000/src/python/run_tests.in @@ -0,0 +1,10 @@ +#!/bin/sh + +# 1st parameter is absolute path to component source directory +# 2nd parameter is absolute path to component build directory +# 3rd parameter is path to Python QA directory + +@top_builddir@/run_tests.sh \ + @abs_top_srcdir@/gr-msdd6000 \ + @abs_top_builddir@/gr-msdd6000 \ + @srcdir@ diff --git a/gr-msdd6000/src/python/test_tcp.py b/gr-msdd6000/src/python/test_tcp.py new file mode 100755 index 000000000..b02db815d --- /dev/null +++ b/gr-msdd6000/src/python/test_tcp.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(); + + + diff --git a/gr-msdd6000/src/python/test_udp.py b/gr-msdd6000/src/python/test_udp.py new file mode 100755 index 000000000..da5c39de3 --- /dev/null +++ b/gr-msdd6000/src/python/test_udp.py @@ -0,0 +1,40 @@ +#!/usr/bin/python + +from socket import * +import string +import time +import struct; + + +port = 10001 +host = "10.45.4.43" + +myaddr = ("10.45.1.229",10000); + +buf = 1024; + +UDPSock = socket(AF_INET,SOCK_DGRAM); +UDPSock.bind(myaddr); + +f_mhz = 2400; +f_hz = 1; +gain = 3; +samples = 512; +decim = 2; +sets = 16; + + +req_data = struct.pack("<IIIIIIIIII", 0x0001, 0x0002, f_mhz, f_hz, gain, samples, decim, sets); +data = struct.pack("<II", 0x0000, 0x0000); + + + +UDPSock.sendto(stat_data, (host,port)) + + +print "sent" + +data,addr = UDPSock.recvfrom(buf); +print "got response" + + |