~ubuntu-branches/ubuntu/precise/gnuradio/precise

« back to all changes in this revision

Viewing changes to gnuradio-examples/python/network/dial_tone_sink.py

  • Committer: Bazaar Package Importer
  • Author(s): Kamal Mostafa
  • Date: 2010-03-13 07:46:01 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20100313074601-zjsa893a87bozyh7
Tags: 3.2.2.dfsg-1ubuntu1
* Fix build for Ubuntu lucid (LP: #260406)
  - add binary package dep for libusrp0, libusrp2-0: adduser
  - debian/rules clean: remove pre-built Qt moc files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
# Copyright 2006,2007 Free Software Foundation, Inc.
 
4
 
5
# This file is part of GNU Radio
 
6
 
7
# GNU Radio is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 3, or (at your option)
 
10
# any later version.
 
11
 
12
# GNU Radio is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with GNU Radio; see the file COPYING.  If not, write to
 
19
# the Free Software Foundation, Inc., 51 Franklin Street,
 
20
# Boston, MA 02110-1301, USA.
 
21
 
22
 
 
23
from gnuradio import gr, audio
 
24
from gnuradio.eng_option import eng_option
 
25
from optparse import OptionParser
 
26
 
 
27
class dial_tone_sink(gr.top_block):
 
28
    def __init__(self, src, port, pkt_size, sample_rate):
 
29
        gr.top_block.__init__(self, "dial_tone_sink")
 
30
        udp = gr.udp_source(gr.sizeof_float, src, port, pkt_size)
 
31
        sink = audio.sink(sample_rate)
 
32
        self.connect(udp, sink)
 
33
        
 
34
if __name__ == '__main__':
 
35
    parser = OptionParser(option_class=eng_option)
 
36
    parser.add_option("", "--src-name", type="string", default="localhost",
 
37
                      help="local host name (domain name or IP address)")
 
38
    parser.add_option("", "--src-port", type="int", default=65500,
 
39
                      help="port value to listen to for connection")
 
40
    parser.add_option("", "--packet-size", type="int", default=1472,
 
41
                      help="packet size.")
 
42
    parser.add_option("-r", "--sample-rate", type="int", default=8000,
 
43
                      help="audio signal sample rate [default=%default]")
 
44
    (options, args) = parser.parse_args()
 
45
    if len(args) != 0:
 
46
        parser.print_help()
 
47
        raise SystemExit, 1
 
48
 
 
49
    # Create an instance of a hierarchical block
 
50
    top_block = dial_tone_sink(options.src_name, options.src_port,
 
51
                               options.packet_size, options.sample_rate)
 
52
    
 
53
    try:    
 
54
        # Run forever
 
55
        top_block.run()
 
56
    except KeyboardInterrupt:
 
57
        # Ctrl-C exits
 
58
        pass
 
59