From 62e8f2383b340c7fae4addeaa8d44330da95a6ea Mon Sep 17 00:00:00 2001
From: Martin Braun <martin.braun@ettus.com>
Date: Fri, 12 Feb 2016 10:29:16 -0800
Subject: uhd: Loosen requirements for multi-chan ops to have timed command
 capability

---
 gr-uhd/apps/uhd_app.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

(limited to 'gr-uhd/apps/uhd_app.py')

diff --git a/gr-uhd/apps/uhd_app.py b/gr-uhd/apps/uhd_app.py
index bb4b9a78af..59bebe24ec 100644
--- a/gr-uhd/apps/uhd_app.py
+++ b/gr-uhd/apps/uhd_app.py
@@ -167,12 +167,17 @@ class UHDApp(object):
             treq = uhd.tune_request(args.freq)
         self.has_lo_sensor = 'lo_locked' in self.usrp.get_sensor_names()
         # Make sure tuning is synched:
+        command_time_set = False
         if len(self.channels) > 1:
             if args.sync == 'pps':
                 self.usrp.set_time_unknown_pps(uhd.time_spec())
             cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
-            for mb_idx in xrange(self.usrp.get_num_mboards()):
-                self.usrp.set_command_time(cmd_time, mb_idx)
+            try:
+                for mb_idx in xrange(self.usrp.get_num_mboards()):
+                    self.usrp.set_command_time(cmd_time, mb_idx)
+                command_time_set = True
+            except RuntimeError:
+                sys.stderr.write('[{prefix}] [WARNING] Failed to set command times.\n'.format(prefix=self.prefix))
         for chan in self.channels:
             self.tr = self.usrp.set_center_freq(treq, chan)
             if self.tr == None:
@@ -180,7 +185,7 @@ class UHDApp(object):
                     prefix=self.prefix, chan=chan
                 ))
                 exit(1)
-        if len(self.channels) > 1:
+        if command_time_set:
             for mb_idx in xrange(self.usrp.get_num_mboards()):
                 self.usrp.clear_command_time(mb_idx)
             self.vprint("Syncing channels...".format(prefix=self.prefix))
@@ -223,10 +228,15 @@ class UHDApp(object):
         else:
             treq = uhd.tune_request(freq)
         # Make sure tuning is synched:
+        command_time_set = False
         if len(self.channels) > 1 and not skip_sync:
             cmd_time = self.usrp.get_time_now() + uhd.time_spec(COMMAND_DELAY)
-            for mb_idx in xrange(self.usrp.get_num_mboards()):
-                self.usrp.set_command_time(cmd_time, mb_idx)
+            try:
+                for mb_idx in xrange(self.usrp.get_num_mboards()):
+                    self.usrp.set_command_time(cmd_time, mb_idx)
+                command_time_set = True
+            except RuntimeError:
+                sys.stderr.write('[{prefix}] [WARNING] Failed to set command times.\n'.format(prefix=self.prefix))
         for chan in self.channels:
             self.tr = self.usrp.set_center_freq(treq, chan)
             if self.tr == None:
@@ -234,7 +244,7 @@ class UHDApp(object):
                     prefix=self.prefix, chan=chan
                 ))
                 exit(1)
-        if len(self.channels) > 1 and not skip_sync:
+        if command_time_set:
             for mb_idx in xrange(self.usrp.get_num_mboards()):
                 self.usrp.clear_command_time(mb_idx)
             self.vprint("Syncing channels...".format(prefix=self.prefix))
-- 
cgit v1.2.3