commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r10643 - gnuradio/branches/developers/eb/t348/gr-utils


From: eb
Subject: [Commit-gnuradio] r10643 - gnuradio/branches/developers/eb/t348/gr-utils/src/python
Date: Wed, 18 Mar 2009 23:37:46 -0600 (MDT)

Author: eb
Date: 2009-03-18 23:37:45 -0600 (Wed, 18 Mar 2009)
New Revision: 10643

Modified:
   gnuradio/branches/developers/eb/t348/gr-utils/src/python/usrp_siggen.py
Log:
Added -N <nsamples> option to usrp_siggen.py.  It also works correctly
if allowed to exit normally.  Seems like our problem has to do with
^C handling.


Modified: 
gnuradio/branches/developers/eb/t348/gr-utils/src/python/usrp_siggen.py
===================================================================
--- gnuradio/branches/developers/eb/t348/gr-utils/src/python/usrp_siggen.py     
2009-03-19 05:23:57 UTC (rev 10642)
+++ gnuradio/branches/developers/eb/t348/gr-utils/src/python/usrp_siggen.py     
2009-03-19 05:37:45 UTC (rev 10643)
@@ -29,7 +29,7 @@
 
 
 class my_top_block(gr.top_block):
-    def __init__ (self):
+    def __init__ (self, nsamples):
         gr.top_block.__init__(self)
         
         # controllable values
@@ -38,6 +38,7 @@
         self.waveform_ampl = 16000
         self.waveform_freq = 100.12345e3
         self.waveform_offset = 0
+        self.nsamples = nsamples
         self._instantiate_blocks ()
         self.set_waveform_type (self.waveform_type)
 
@@ -86,19 +87,30 @@
         self.noisegen = gr.noise_source_c (gr.GR_UNIFORM,
                                            self.waveform_ampl)
 
+        self.head = None
+        if self.nsamples > 0:
+            self.head = gr.head(gr.sizeof_gr_complex, int(self.nsamples))
+
         # self.file_sink = gr.file_sink (gr.sizeof_gr_complex, "siggen.dat")
 
     def _configure_graph (self, type):
         try:
             self.lock()
             self.disconnect_all ()
+
+            if self.head:
+                self.connect(self.head, self.u)
+                tail = self.head
+            else:
+                tail = self.u
+                
             if type == gr.GR_SIN_WAVE or type == gr.GR_CONST_WAVE:
-                self.connect (self.siggen, self.u)
+                self.connect (self.siggen, tail)
                 # self.connect (self.siggen, self.file_sink)
                 self.siggen.set_waveform (type)
                 self.src = self.siggen
             elif type == gr.GR_UNIFORM or type == gr.GR_GAUSSIAN:
-                self.connect (self.noisegen, self.u)
+                self.connect (self.noisegen, tail)
                 self.noisegen.set_type (type)
                 self.src = self.noisegen
             else:
@@ -156,6 +168,8 @@
                        help="set output gain to GAIN [default=%default]")
     parser.add_option ("-o", "--offset", type="eng_float", default=0,
                        help="set waveform offset to OFFSET [default=%default]")
+    parser.add_option ("-N", "--nsamples", type="eng_float", default=0,
+                       help="set number of samples to transmit [default=+inf]")
     (options, args) = parser.parse_args ()
 
     if len(args) != 0:
@@ -167,7 +181,7 @@
         parser.print_help()
         raise SystemExit
 
-    tb = my_top_block()
+    tb = my_top_block(options.nsamples)
     tb.set_interpolator (options.interp)
     tb.set_waveform_type (options.type)
     tb.set_waveform_freq (options.waveform_freq)





reply via email to

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