fixed issue where usrp siggen continued to transmit after program exit
authorJosh Blum <josh@joshknows.com>
Thu, 29 Oct 2009 21:28:56 +0000 (14:28 -0700)
committerJosh Blum <josh@joshknows.com>
Thu, 29 Oct 2009 21:28:56 +0000 (14:28 -0700)
gnuradio-core/src/python/gnuradio/blks2impl/generic_usrp.py
gr-utils/src/python/usrp_siggen.py
gr-utils/src/python/usrp_siggen_gui.py

index 6daa4e7a2ab6549684fcf1a480078eef68d3b9d3..82d1eca13a5cdb4458f5ae31d873f353ec68bdc8 100644 (file)
@@ -121,15 +121,6 @@ class _generic_usrp_base(object):
     def set_auto_tr(self, enable):
         if self._type == USRP1_TYPE: return self._subdev.set_auto_tr(enable)
 
-    def __del__(self):
-        #delete usrp1 specific subdev
-        if self._type == USRP1_TYPE:
-            del self._subdev
-            self._subdev = None
-        #delete the usrp device
-        del self._u
-        self._u = None
-
 ########################################################################
 # generic usrp source
 ########################################################################
index 69925fd0efe4994bab153a01f75f93a4fa29d38a..da83da770d43429457dc2316f442abb77c34cda1 100755 (executable)
@@ -305,7 +305,7 @@ def get_options():
     return (options, args)
 
 # If this script is executed, the following runs. If it is imported, the below does not run.
-if __name__ == "__main__":
+def main():
     if gr.enable_realtime_scheduling() != gr.RT_OK:
         print "Note: failed to enable realtime scheduling, continuing"
     
@@ -321,3 +321,11 @@ if __name__ == "__main__":
     tb.start()
     raw_input('Press Enter to quit: ')
     tb.stop()
+    tb.wait()
+
+# Make sure to create the top block (tb) within a function:
+# That code in main will allow tb to go out of scope on return,
+# which will call the decontructor on usrp and stop transmit.
+# Whats odd is that grc works fine with tb in the __main__,
+# perhaps its because the try/except clauses around tb.
+if __name__ == "__main__": main()
index 40848fbeee3aa0d7764de5f5d92a63731084b711..47d47bdb3def7ed0eb4159b58913b41d359cb597 100755 (executable)
@@ -284,7 +284,7 @@ class app_gui(pubsub):
         self.vbox.AddSpacer(5)
         self.vbox.AddStretchSpacer()
 
-if __name__ == "__main__":
+def main():
     try:
         # Get command line parameters
         (options, args) = usrp_siggen.get_options()
@@ -308,3 +308,10 @@ if __name__ == "__main__":
     except RuntimeError, e:
         print e
         sys.exit(1)
+
+# Make sure to create the top block (tb) within a function:
+# That code in main will allow tb to go out of scope on return,
+# which will call the decontructor on usrp and stop transmit.
+# Whats odd is that grc works fine with tb in the __main__,
+# perhaps its because the try/except clauses around tb.
+if __name__ == "__main__": main()