aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-04-25 22:05:50 -0700
committerJosh Blum <josh@joshknows.com>2010-04-25 22:05:50 -0700
commit61ec6711bb4bbae7a8a26cc631eeb88fb3e7d688 (patch)
tree12cfaf308bcbd779dd5a1254b12a6104088629cc /host/lib/usrp
parentd1d6c859f0dbae5f044519d589d5ad3fcbb8643e (diff)
downloaduhd-61ec6711bb4bbae7a8a26cc631eeb88fb3e7d688.tar.gz
uhd-61ec6711bb4bbae7a8a26cc631eeb88fb3e7d688.tar.bz2
uhd-61ec6711bb4bbae7a8a26cc631eeb88fb3e7d688.zip
Work on exceptions.
Added props exception macro to make the set/get prop switch statements easier. Made use of boost throw exception macro for throw-site information in throw assert.
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/dboard/db_basic_and_lf.cpp12
-rw-r--r--host/lib/usrp/dboard/db_rfx.cpp14
-rw-r--r--host/lib/usrp/dboard/db_xcvr2450.cpp15
-rw-r--r--host/lib/usrp/usrp2/dboard_impl.cpp10
-rw-r--r--host/lib/usrp/usrp2/dsp_impl.cpp10
-rw-r--r--host/lib/usrp/usrp2/mboard_impl.cpp8
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp3
7 files changed, 34 insertions, 38 deletions
diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp
index aad2398d8..c7b841efb 100644
--- a/host/lib/usrp/dboard/db_basic_and_lf.cpp
+++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp
@@ -153,6 +153,8 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -174,9 +176,7 @@ void basic_rx::rx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_FREQ:
return; // it wont do you much good, but you can set it
- default: throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_rx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
@@ -248,6 +248,8 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -269,8 +271,6 @@ void basic_tx::tx_set(const wax::obj &key_, const wax::obj &val){
case SUBDEV_PROP_FREQ:
return; // it wont do you much good, but you can set it
- default: throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_tx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp
index 76b2c6d7a..49ec9412c 100644
--- a/host/lib/usrp/dboard/db_rfx.cpp
+++ b/host/lib/usrp/dboard/db_rfx.cpp
@@ -396,6 +396,8 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -419,10 +421,7 @@ void rfx_xcvr::rx_set(const wax::obj &key_, const wax::obj &val){
set_rx_ant(val.as<std::string>());
return;
- default:
- throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_rx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
@@ -486,6 +485,8 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = true;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -509,9 +510,6 @@ void rfx_xcvr::tx_set(const wax::obj &key_, const wax::obj &val){
ASSERT_THROW(val.as<std::string>() == "TX/RX");
return;
- default:
- throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_tx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp
index 2c2843d3a..2052511f8 100644
--- a/host/lib/usrp/dboard/db_xcvr2450.cpp
+++ b/host/lib/usrp/dboard/db_xcvr2450.cpp
@@ -352,7 +352,8 @@ static max2829_regs_t::tx_baseband_gain_t gain_to_tx_bb_reg(float &gain){
gain = 5;
return max2829_regs_t::TX_BASEBAND_GAIN_5DB;
}
- ASSERT_THROW(false);
+ BOOST_THROW_EXCEPTION(std::runtime_error("should not get here"));
+ return max2829_regs_t::TX_BASEBAND_GAIN_0DB;
}
/*!
@@ -474,6 +475,8 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -496,9 +499,7 @@ void xcvr2450::rx_set(const wax::obj &key_, const wax::obj &val){
this->set_rx_ant(val.as<std::string>());
return;
- default: throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_rx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
@@ -564,6 +565,8 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){
case SUBDEV_PROP_USE_LO_OFFSET:
val = false;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -586,8 +589,6 @@ void xcvr2450::tx_set(const wax::obj &key_, const wax::obj &val){
this->set_tx_ant(val.as<std::string>());
return;
- default: throw std::runtime_error(str(boost::format(
- "Error: trying to set read-only property on %s subdev"
- ) % dboard_id::to_string(get_tx_id())));
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp
index 8952a9f75..043609458 100644
--- a/host/lib/usrp/usrp2/dboard_impl.cpp
+++ b/host/lib/usrp/usrp2/dboard_impl.cpp
@@ -123,8 +123,7 @@ void usrp2_impl::rx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _rx_db_eeprom.id;
return;
- //case DBOARD_PROP_CODEC:
- // throw std::runtime_error("unhandled prop in usrp2 dboard");
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -140,7 +139,7 @@ void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){
_iface->write_eeprom(I2C_ADDR_RX_DB, 0, _tx_db_eeprom.get_eeprom_bytes());
return;
- default: throw std::runtime_error("Cannot set read-only property on usrp2 dboard");
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
@@ -173,8 +172,7 @@ void usrp2_impl::tx_dboard_get(const wax::obj &key_, wax::obj &val){
val = _tx_db_eeprom.id;
return;
- //case DBOARD_PROP_CODEC:
- // throw std::runtime_error("unhandled prop in usrp2 dboard");
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -190,6 +188,6 @@ void usrp2_impl::tx_dboard_set(const wax::obj &key, const wax::obj &val){
_iface->write_eeprom(I2C_ADDR_TX_DB, 0, _tx_db_eeprom.get_eeprom_bytes());
return;
- default: throw std::runtime_error("Cannot set read-only property on usrp2 dboard");
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/usrp2/dsp_impl.cpp b/host/lib/usrp/usrp2/dsp_impl.cpp
index 204277ba7..379276f7d 100644
--- a/host/lib/usrp/usrp2/dsp_impl.cpp
+++ b/host/lib/usrp/usrp2/dsp_impl.cpp
@@ -117,6 +117,8 @@ void usrp2_impl::ddc_get(const wax::obj &key, wax::obj &val){
case DSP_PROP_HOST_RATE:
val = get_master_clock_freq()/_ddc_decim;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -139,8 +141,7 @@ void usrp2_impl::ddc_set(const wax::obj &key, const wax::obj &val){
}
return;
- default:
- throw std::runtime_error("Error: trying to set read-only property on usrp2 ddc0");
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
@@ -200,6 +201,8 @@ void usrp2_impl::duc_get(const wax::obj &key, wax::obj &val){
case DSP_PROP_HOST_RATE:
val = get_master_clock_freq()/_duc_interp;
return;
+
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -222,7 +225,6 @@ void usrp2_impl::duc_set(const wax::obj &key, const wax::obj &val){
}
return;
- default:
- throw std::runtime_error("Error: trying to set read-only property on usrp2 duc0");
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp
index f94806c9f..2c185ec53 100644
--- a/host/lib/usrp/usrp2/mboard_impl.cpp
+++ b/host/lib/usrp/usrp2/mboard_impl.cpp
@@ -248,9 +248,7 @@ void usrp2_impl::mboard_get(const wax::obj &key_, wax::obj &val){
val = _clock_config;
return;
- default:
- throw std::runtime_error("Error: trying to get write-only property on usrp2 mboard");
-
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
@@ -306,8 +304,6 @@ void usrp2_impl::mboard_set(const wax::obj &key, const wax::obj &val){
issue_ddc_stream_cmd(val.as<stream_cmd_t>());
return;
- default:
- throw std::runtime_error("Error: trying to set read-only property on usrp2 mboard");
-
+ default: UHD_THROW_PROP_READ_ONLY();
}
}
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index 0fa56c339..11ad812e1 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -202,9 +202,10 @@ void usrp2_impl::get(const wax::obj &key_, wax::obj &val){
val = size_t(_max_tx_samples_per_packet);
return;
+ default: UHD_THROW_PROP_WRITE_ONLY();
}
}
void usrp2_impl::set(const wax::obj &, const wax::obj &){
- throw std::runtime_error("Cannot set in usrp2 device");
+ UHD_THROW_PROP_READ_ONLY();
}