From 241300330cfe393a3c19b7b1bedf87c127d649db Mon Sep 17 00:00:00 2001
From: jcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Date: Thu, 10 Jul 2008 19:56:51 +0000
Subject: Add lookup by serial number.

git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8858 221aa14e-8319-0410-a670-987f0aec2ac5
---
 gr-utils/src/python/lsusrp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'gr-utils/src')

diff --git a/gr-utils/src/python/lsusrp b/gr-utils/src/python/lsusrp
index df52c608e1..d2eab33fe3 100755
--- a/gr-utils/src/python/lsusrp
+++ b/gr-utils/src/python/lsusrp
@@ -25,9 +25,14 @@ MAX_USRPS = 8
 from gnuradio import usrp
 from optparse import OptionParser
 
-def disp_usrp(which):
+def disp_usrp(which, serial=None):
     u_source = usrp.source_c(which=which)
     u_sink = usrp.sink_c(which=which)
+    u_serial = u_source.serial_number()
+    
+    if serial is not None:
+        if serial != u_serial:
+            raise ValueError
 	
     print "USRP", which, "serial number", u_source.serial_number()
     subdev_A_rx = usrp.selected_subdev(u_source, (0,0))
@@ -44,11 +49,18 @@ if __name__ == "__main__":
     parser.add_option("-w", "--which", type="int", default=None,
                       help="select which USRP (0, 1, ...) default is all found",
 		      metavar="NUM")
+    parser.add_option("-s", "--serial", default=None,
+                      help="select USRP by serial number",
+		      metavar="SER")
     (options, args) = parser.parse_args()
     if len(args) > 0:
 	print parser.print_help()
 	raise SystemExit, 1
 
+    if options.serial is not None and options.which is not None:
+       print "Use of --which or --serial is exclusive"
+       raise SystemExit, 1
+
     if options.which is not None:
 	try:	
     	    disp_usrp(options.which)
@@ -57,7 +69,7 @@ if __name__ == "__main__":
     else:
 	for n in range(MAX_USRPS):
 	    try:
-		disp_usrp(n)
+		disp_usrp(n, options.serial)
 	    except:
 		pass
 
-- 
cgit v1.2.3