commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r9459 - usrp2/trunk/host/lib


From: jcorgan
Subject: [Commit-gnuradio] r9459 - usrp2/trunk/host/lib
Date: Sat, 30 Aug 2008 12:22:11 -0600 (MDT)

Author: jcorgan
Date: 2008-08-30 12:22:11 -0600 (Sat, 30 Aug 2008)
New Revision: 9459

Modified:
   usrp2/trunk/host/lib/usrp2.cc
   usrp2/trunk/host/lib/usrp2_impl.cc
   usrp2/trunk/host/lib/usrp2_impl.h
Log:
Improve error messages, remove unneeded code

Modified: usrp2/trunk/host/lib/usrp2.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2.cc       2008-08-30 18:09:04 UTC (rev 9458)
+++ usrp2/trunk/host/lib/usrp2.cc       2008-08-30 18:22:11 UTC (rev 9459)
@@ -126,15 +126,24 @@
       throw std::runtime_error("Invalid MAC address");
 
     props_vector_t u2s = find(ifc, naddr);
-    if (u2s.size() != 1)
-      throw std::runtime_error("Unable to find requested USRP2.");
+    int n = u2s.size();
 
+    if (n == 0) {
+      if (addr == "")
+       throw std::runtime_error("No USRPs found on interface.");
+      else
+       throw std::runtime_error("Specified USRP2 not found on interface.");
+    }
+
+    if (n > 1)
+      throw std::runtime_error("Multiple USRPs found on interface; must select 
by MAC address.");
+
     return find_existing_or_make_new(ifc, &u2s[0]);
   }
 
   // Private constructor.  Sole function is to create an impl.
   usrp2::usrp2(const std::string &ifc, props *p)
-    : d_impl(new usrp2::impl(ifc, p->addr))
+    : d_impl(new usrp2::impl(ifc, p))
   {
     // NOP
   }

Modified: usrp2/trunk/host/lib/usrp2_impl.cc
===================================================================
--- usrp2/trunk/host/lib/usrp2_impl.cc  2008-08-30 18:09:04 UTC (rev 9458)
+++ usrp2/trunk/host/lib/usrp2_impl.cc  2008-08-30 18:22:11 UTC (rev 9459)
@@ -118,17 +118,13 @@
   }
 
 
-  usrp2::impl::impl(const std::string &ifc, const std::string &addr)
+  usrp2::impl::impl(const std::string &ifc, props *p)
     : d_eth_buf(new eth_buffer()), d_pf(0), d_bg_thread(0), 
d_bg_running(false),
       d_rx_decim(0), d_rx_seqno(-1), d_tx_seqno(0), d_next_rid(0),
       d_num_rx_frames(0), d_num_rx_missing(0), d_num_rx_overruns(0), 
d_num_rx_bytes(0), 
       d_num_enqueued(0), d_enqueued_mutex(), 
d_bg_pending_cond(&d_enqueued_mutex),
       d_channel_rings(NCHANS)
   {
-    props_vector_t u2s = find(ifc, addr);
-    if (u2s.size() != 1)
-      throw std::runtime_error("Unable to find requested USRP2.");
-    
     if (!d_eth_buf->open(ifc, htons(U2_ETHERTYPE)))
       throw std::runtime_error("Unable to register USRP2 protocol");
     
@@ -136,7 +132,7 @@
     if (!d_pf || !d_eth_buf->attach_pktfilter(d_pf))
       throw std::runtime_error("Unable to attach packet filter.");
     
-    d_addr = u2s[0].addr;
+    d_addr = p->addr;
     
     if (USRP2_IMPL_DEBUG)
       std::cerr << "usrp2 constructor: using USRP2 at " << d_addr << std::endl;

Modified: usrp2/trunk/host/lib/usrp2_impl.h
===================================================================
--- usrp2/trunk/host/lib/usrp2_impl.h   2008-08-30 18:09:04 UTC (rev 9458)
+++ usrp2/trunk/host/lib/usrp2_impl.h   2008-08-30 18:22:11 UTC (rev 9459)
@@ -89,7 +89,7 @@
     data_handler::result handle_data_packet(const void *base, size_t len);
 
   public:
-    impl(const std::string &ifc, const std::string &addr);
+    impl(const std::string &ifc, props *p);
     ~impl();
     
     void bg_loop();





reply via email to

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