commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r6374 - in gnuradio/branches/developers/jcorgan/t162/g


From: jcorgan
Subject: [Commit-gnuradio] r6374 - in gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python: . limbo limbo/networking network
Date: Sat, 8 Sep 2007 21:42:11 -0600 (MDT)

Author: jcorgan
Date: 2007-09-08 21:42:11 -0600 (Sat, 08 Sep 2007)
New Revision: 6374

Added:
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py
   gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py
Removed:
   gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/networking/
Modified:
   
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/Makefile.am
Log:
Work in progress.

Modified: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/Makefile.am
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/Makefile.am  
    2007-09-09 03:39:52 UTC (rev 6373)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/Makefile.am  
    2007-09-09 03:42:11 UTC (rev 6374)
@@ -29,7 +29,7 @@
     digital \
     multi-antenna \
     multi_usrp \
-    networking \
+    network \
     sounder \
     usrp \
     ofdm

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking
 (from rev 6372, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/networking)

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/networking/Makefile.am)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am
                             (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/Makefile.am
     2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,23 @@
+#
+# Copyright 2006 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.
+# 
+
+EXTRA_DIST =           \
+    measurement_slave.py
\ No newline at end of file

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/networking/measurement_slave.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/limbo/networking/measurement_slave.py
    2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,241 @@
+#!/usr/bin/env python
+#
+# Copyright 2006 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.
+# 
+
+import struct
+import socket
+import asyncore
+import sys
+import optparse
+import random
+from gnuradio.eng_option import eng_option
+import gnuradio.gr.gr_threading as _threading
+
+LOOP_TIMEOUT = 0.001
+BROADCAST_ADDR = '255.255.255.255'
+
+BROADCAST_PORT = 27010   # UDP
+CONTROL_PORT   = 27011   # TCP
+
+PKT_HEADER_SIZE = 4      # 32-bit int
+
+logfile = None
+
+def unpack_header(s):
+    (len,) = struct.unpack('!i', s)
+    return (len,)
+
+def pack_header(len):
+    return struct.pack('!i', len)
+
+
+class control_port_listener(asyncore.dispatcher):
+    def __init__(self, port=CONTROL_PORT, udp_socket=None, verbose=False):
+        """
+        @param port: TCP port to listen on.
+        @type port: int
+        """
+        asyncore.dispatcher.__init__(self)
+
+        self._verbose = verbose
+        self._udp_socket = udp_socket
+
+        host = ''                       # symbolic name for localhost
+        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+        self.set_reuse_addr()
+
+        try:
+            self.bind((host, port))
+        except socket.error, err:
+            sys.stderr.write('Failed to bind to %s: %s\n' %
+                             ((host, port), os.strerror (err.args[0]),))
+            sys.exit(1)
+
+        self.listen(3)
+        
+    def handle_accept(self):
+        socket, addr = self.accept()
+        sys.stderr.write("handle_accept: %r\n" % (addr,))
+        if not(socket is None):
+            # instantiate a server
+            s = control_server(socket, addr, self._udp_socket, self._verbose)
+        
+
+class gr_dispatcher(asyncore.dispatcher):
+    def __init__(self, sock=None, map=None):
+        asyncore.dispatcher.__init__(self, sock=sock, map=map)
+
+    def read_packet(self):
+        """
+        Returns None or packet
+        """
+        s = self.recvall(PKT_HEADER_SIZE)
+        if s == '':
+            return None
+        
+        (payload_len,) = unpack_header(s)
+
+        payload_len = int(payload_len)
+        
+        if payload_len == 0:
+            payload = ''
+        else:
+            payload = self.recvall(payload_len)
+            if len(payload) != payload_len:
+                sys.stderr.write ('short recv, expected %d bytes, got %d\n' % (
+                    payload_len, len(payload)))
+                raise RuntimeError, "short recv"
+
+        return payload
+
+    def recvall(self, buffer_size):
+        result = ''
+        while len(result) < buffer_size:
+            data = self.recv(buffer_size - len(result))
+            if not data:
+                return ''
+            result += data
+        return result
+
+
+class pkt_receiver_thread(_threading.Thread):
+    def __init__(self, socket):
+        _threading.Thread.__init__(self)
+        self.setDaemon(1)
+        self.socket = socket
+        self.keep_running = True
+        self.start()
+
+    def run(self):
+        while self.keep_running:
+            pkt, sender = self.socket.recvfrom(10000)
+            if pkt:
+                if len(pkt) > 2:
+                    t = struct.unpack('!H', pkt[0:2])
+                    seqno = t[0]
+                else:
+                    seqno = -1
+                    
+                logfile.write('RCVD seqno %4d len %4d from %s\n' % (seqno, 
len(pkt), sender))
+                logfile.flush()
+
+
+class control_server(gr_dispatcher):
+    def __init__(self, socket, addr, udp_socket, verbose=False):
+        gr_dispatcher.__init__(self, sock=socket)
+        
+        self._udp_socket = udp_socket
+        self.verbose = verbose
+        self.setblocking(1)
+
+    def writable(self):
+        return False
+
+    def handle_read(self):
+        pkt = self.read_packet()
+        if pkt:
+            annotate = 'ANNOTATE'
+            if pkt.startswith(annotate):
+                logfile.write(pkt[len(annotate)+1:])
+                logfile.write('\n')
+                logfile.flush()
+            elif pkt.startswith('SEND'):
+                tokens = pkt.split()
+                if len(tokens) < 4:
+                    invalid_packet(pkt)
+                else:
+                    npkts = int(tokens[1])
+                    size = int(tokens[2])
+                    power = float(tokens[3])
+                    send_test_packets(self._udp_socket, npkts, size, power)
+            else:
+                invalid_packet(pkt)
+
+    def handle_close(self):
+        self.close()
+
+
+def invalid_packet(pkt):
+    sys.stderr.write('received unrecognized packet: %s\n' % (pkt,))
+
+
+def make_random_payload(size):
+    p = [0] * size
+    if 1:
+        for i in range(size):
+            p[i] = chr(random.randint(0, 255))
+    else:
+        for i in range(size):
+            p[i] = chr(i % 256)
+    return ''.join(p)
+
+
+def send_test_packets(udp_socket, npkts, size, power):
+    # we ignore power for now...
+    size = max(2, size)
+    payload = make_random_payload(size - 2)
+    for n in range(npkts):
+        pkt = struct.pack('!H', n) + payload
+        udp_socket.sendto(pkt, (BROADCAST_ADDR, BROADCAST_PORT))
+        #udp_socket.sendall(pkt)
+
+
+def open_udp_broadcast_socket(gr0_host_ip, port):
+    s  = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+#    s.bind((gr0_host_ip, port))
+    s.bind(('', port))
+    s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
+#    s.connect((BROADCAST_ADDR, port))
+    return s
+
+
+def main():
+    global logfile
+    
+    usage = 'usage: %prog [options] gr0-ip-addr'
+    parser = optparse.OptionParser (option_class=eng_option, usage=usage)
+    parser.add_option('-l', '--logfile', type='string', default=None,
+                      help="specify log file name [default=<stdout>]")
+    parser.add_option('-v', '--verbose', action="store_true", default=False,
+                      help="enable verbose diagnostics")
+
+    (options, args) = parser.parse_args ()
+    if len(args) != 1:
+        parser.print_help()
+        sys.exit(1)
+
+    gr0_ip_addr = args[0]
+    if options.logfile is None:
+        logfile = sys.stdout
+    else:
+        logfile = file(options.logfile, 'w')
+
+    udp_socket = open_udp_broadcast_socket(gr0_ip_addr, BROADCAST_PORT)
+    R = pkt_receiver_thread(udp_socket)
+    L = control_port_listener(CONTROL_PORT, udp_socket=udp_socket, 
verbose=options.verbose)
+    asyncore.loop(LOOP_TIMEOUT)
+
+
+if __name__ == '__main__':
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network 
(from rev 6372, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking)

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/Makefile.am)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am
                              (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/Makefile.am
      2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,30 @@
+#
+# Copyright 2007 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.
+# 
+
+EXTRA_DIST =                   \
+       audio_sink.py           \
+       audio_source.py         \
+       dial_tone_sink.py       \
+       dial_tone_source.py     \
+       vector_sink.py          \
+       vector_source.py
+
+MOSTLYCLEANFILES = *.pyc *~

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/audio_sink.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py
                            (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_sink.py
    2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2007 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, audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class audio_sink(gr.top_block):
+    def __init__(self, src, port, pkt_size, sample_rate):
+        gr.top_block.__init__(self, "audio_sink")
+        src = gr.udp_source(gr.sizeof_float, src, port, pkt_size)
+        dst = audio.sink(sample_rate)
+        self.connect(src, dst)
+        
+if __name__ == '__main__':
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--src-port", type="int", default=65500,
+                      help="port value to listen to for connection")
+    parser.add_option("", "--packet-size", type="int", default=1472,
+                      help="packet size.")
+    parser.add_option("-r", "--sample-rate", type="int", default=32000,
+                      help="audio signal sample rate [default=%default]")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+
+    # Create an instance of a hierarchical block
+    top_block = audio_sink(options.src_name, options.src_port,
+                           options.packet_size, options.sample_rate)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/audio_source.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py
                          (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/audio_source.py
  2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2007 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, audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class audio_source(gr.top_block):
+    def __init__(self, src, dst, port, pkt_size, sample_rate):
+        gr.top_block.__init__(self, "audio_source")
+        self.audio = audio.source(sample_rate)
+       self.sink = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size)
+        self.connect(self.audio, self.sink)
+
+if __name__ == '__main__':
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--dst-name", type="string", default="localhost",
+                      help="Remote host name (domain name or IP address")
+    parser.add_option("", "--dst-port", type="int", default=65500,
+                      help="port value to connect to")
+    parser.add_option("", "--packet-size", type="int", default=1472,
+                      help="packet size.")
+    parser.add_option("-r", "--sample-rate", type="int", default=32000 ,
+                      help="audio signal sample rate [default=%default]")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+
+    # Create an instance of a hierarchical block
+    top_block = audio_source(options.src_name, options.dst_name, 
options.dst_port,
+                             options.packet_size, options.sample_rate)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/dial_tone_sink.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py
                                (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_sink.py
        2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2007 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, audio
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class dial_tone_sink(gr.top_block):
+    def __init__(self, src, port, pkt_size, sample_rate):
+        gr.top_block.__init__(self, "dial_tone_sink")
+        udp = gr.udp_source(gr.sizeof_float, src, port, pkt_size)
+        sink = audio.sink(sample_rate)
+        self.connect(udp, sink)
+        
+if __name__ == '__main__':
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--src-port", type="int", default=65500,
+                      help="port value to listen to for connection")
+    parser.add_option("", "--packet-size", type="int", default=1472,
+                      help="packet size.")
+    parser.add_option("-r", "--sample-rate", type="int", default=8000,
+                      help="audio signal sample rate [default=%default]")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+
+    # Create an instance of a hierarchical block
+    top_block = dial_tone_sink(options.src_name, options.src_port,
+                               options.packet_size, options.sample_rate)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/dial_tone_source.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py
                              (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/dial_tone_source.py
      2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,70 @@
+#!/usr/bin/env python
+#
+# Copyright 2006,2007 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
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class dial_tone_source(gr.top_block):
+    def __init__(self, src, dst, port, pkt_size, sample_rate):
+        gr.top_block.__init__(self, "dial_tone_source")
+
+        amplitude = 0.3
+        src0 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 350, amplitude)
+        src1 = gr.sig_source_f (sample_rate, gr.GR_SIN_WAVE, 440, amplitude)
+        add = gr.add_ff()
+
+        # Throttle needed here to account for the other side's audio card 
sampling rate
+       thr = gr.throttle(gr.sizeof_float, sample_rate)
+       sink = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size)
+       self.connect(src0, (add, 0))
+       self.connect(src1, (add, 1))
+       self.connect(add, thr, sink)
+
+if __name__ == '__main__':
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--dst-name", type="string", default="localhost",
+                      help="Remote host name (domain name or IP address")
+    parser.add_option("", "--dst-port", type="int", default=65500,
+                      help="port value to connect to")
+    parser.add_option("", "--packet-size", type="int", default=1472,
+                      help="packet size.")
+    parser.add_option("-r", "--sample-rate", type="int", default=8000,
+                      help="audio signal sample rate [default=%default]")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+
+    # Create an instance of a hierarchical block
+    top_block = dial_tone_source(options.src_name, options.dst_name, 
options.dst_port,
+                                 options.packet_size, options.sample_rate)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/vector_sink.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py
                           (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_sink.py
   2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Copyright 2006 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
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class vector_sink(gr.top_block):
+    def __init__(self, src, port, pkt_size):
+        gr.top_block.__init__(self, "vector_sink")
+
+        udp = gr.udp_source(gr.sizeof_float, src, port, pkt_size)
+        sink = gr.file_sink(gr.sizeof_float, "received.dat")
+        self.connect(udp, sink)
+
+if __name__ == "__main__":
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--src-port", type="int", default=65500,
+                      help="port value to listen to for connection")
+    parser.add_option("", "--packet-size", type="int", default=1471,
+                      help="packet size.")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+    
+    # Create an instance of a hierarchical block
+    top_block = vector_sink(options.src_name, options.src_port, 
options.packet_size)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    

Deleted: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py

Copied: 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py
 (from rev 6373, 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/hier/networking/vector_source.py)
===================================================================
--- 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py
                         (rev 0)
+++ 
gnuradio/branches/developers/jcorgan/t162/gnuradio-examples/python/network/vector_source.py
 2007-09-09 03:42:11 UTC (rev 6374)
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+#
+# Copyright 2006 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
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+
+class vector_source(gr.top_block):
+    def __init__(self, src, dst, port, pkt_size):
+        gr.top_block.__init__(self, "vector_source")
+        data = [i*0.01 for i in range(1000)]
+        vec = gr.vector_source_f(data, True)
+        udp = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size)
+        self.connect(vec, udp)
+
+if __name__ == '__main__':
+    parser = OptionParser(option_class=eng_option)
+    parser.add_option("", "--src-name", type="string", default="localhost",
+                      help="local host name (domain name or IP address)")
+    parser.add_option("", "--dst-name", type="string", default="localhost",
+                      help="Remote host name (domain name or IP address")
+    parser.add_option("", "--dst-port", type="int", default=65500,
+                      help="port value to connect to")
+    parser.add_option("", "--packet-size", type="int", default=1471,
+                      help="packet size.")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        raise SystemExit, 1
+
+# Create an instance of a hierarchical block
+    top_block = vector_source(options.src_name, options.dst_name,
+                              options.dst_port, options.packet_size)
+    
+    try:    
+        # Run forever
+        top_block.run()
+    except KeyboardInterrupt:
+        # Ctrl-C exits
+        pass
+    





reply via email to

[Prev in Thread] Current Thread [Next in Thread]