From 0336db128e38bd99d69e192189a63ba6d3d3e36b Mon Sep 17 00:00:00 2001
From: Josh Blum <josh@joshknows.com>
Date: Thu, 10 Mar 2011 14:35:29 -0800
Subject: usrp1: also replaced control error prints w/ throws

---
 host/lib/usrp/usrp1/usrp1_iface.cpp | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

(limited to 'host/lib/usrp/usrp1')

diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp
index e90d66c82..0c37610ce 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.cpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.cpp
@@ -70,8 +70,7 @@ public:
                                           (unsigned char*) &swapped,
                                           sizeof(boost::uint32_t));
 
-        if (ret < 0)
-            std::cerr << "USRP: failed memory write: " << ret << std::endl;
+        if (ret < 0) throw uhd::io_error("USRP1: failed control write");
     }
 
     boost::uint32_t peek32(boost::uint32_t addr)
@@ -88,8 +87,7 @@ public:
                                           (unsigned char*) &value_out,
                                           sizeof(boost::uint32_t));
 
-        if (ret < 0)
-            std::cerr << "USRP: failed memory read: " << ret << std::endl;
+        if (ret < 0) throw uhd::io_error("USRP1: failed control read");
 
         return uhd::ntohx(value_out);
     }
@@ -193,10 +191,7 @@ public:
                                          buff,
                                          (w_len_h << 8) | (w_len_l << 0));
 
-            if (ret < 0) {
-                std::cout << "USRP: failed SPI readback transaction: "
-                          << std::dec << ret << std::endl;
-            }
+            if (ret < 0) throw uhd::io_error("USRP1: failed SPI readback transaction");
 
             boost::uint32_t val = (((boost::uint32_t)buff[0]) <<  0) |
                                   (((boost::uint32_t)buff[1]) <<  8) |
@@ -214,10 +209,7 @@ public:
                                           (w_index_h << 8) | (w_index_l << 0),
                                           buff, num_bytes);
 
-            if (ret < 0) {
-                std::cout << "USRP: failed SPI transaction: "
-                          << std::dec << ret << std::endl;
-            }
+            if (ret < 0) throw uhd::io_error("USRP1: failed SPI transaction");
 
             return 0;
         }
@@ -251,8 +243,7 @@ public:
                                                       length);
         }
 
-        if (ret < 0)
-            std::cerr << "USRP: failed firmware command: " << ret << std::endl;
+        if (ret < 0) throw uhd::io_error("USRP1: failed firmware command");
     }
 
 private:
-- 
cgit v1.2.3