summaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-06-28 11:11:04 -0700
committerJosh Blum <josh@joshknows.com>2011-06-28 11:11:04 -0700
commit4888233252d58f0df3c8773ec3268a0ed7bea1d2 (patch)
tree33daab577ff64117e647bb5d6e97397c89ff6b11 /host/lib
parent3a6187515677b277489df4ec59f9cf21f1ed62bc (diff)
downloaduhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.tar.gz
uhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.tar.bz2
uhd-4888233252d58f0df3c8773ec3268a0ed7bea1d2.zip
uhd: re-work to make the properties easier to use
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/CMakeLists.txt2
-rw-r--r--host/lib/types/sensors.cpp7
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.cpp14
-rw-r--r--host/lib/usrp/cores/rx_dsp_core_200.hpp2
-rw-r--r--host/lib/usrp/dboard_manager.cpp57
-rw-r--r--host/lib/usrp2/io_impl.cpp10
-rw-r--r--host/lib/usrp2/usrp2_impl.cpp18
7 files changed, 59 insertions, 51 deletions
diff --git a/host/lib/CMakeLists.txt b/host/lib/CMakeLists.txt
index a8f490f0a..390a75f09 100644
--- a/host/lib/CMakeLists.txt
+++ b/host/lib/CMakeLists.txt
@@ -72,7 +72,7 @@ INCLUDE_SUBDIRECTORY(types)
INCLUDE_SUBDIRECTORY(convert)
INCLUDE_SUBDIRECTORY(transport)
INCLUDE_SUBDIRECTORY(usrp)
-INCLUDE_SUBDIRECTORY(usrp2)
+#INCLUDE_SUBDIRECTORY(usrp2)
INCLUDE_SUBDIRECTORY(utils)
########################################################################
diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp
index 5e1e8691c..52a63d14c 100644
--- a/host/lib/types/sensors.cpp
+++ b/host/lib/types/sensors.cpp
@@ -22,13 +22,6 @@
using namespace uhd;
-sensor_value_t::sensor_value_t(void):
- name(""), value(""),
- unit(""), type(STRING)
-{
- /* NOP */
-}
-
sensor_value_t::sensor_value_t(
const std::string &name,
bool value,
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.cpp b/host/lib/usrp/cores/rx_dsp_core_200.cpp
index 5aa32c630..b13cc8f03 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.cpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.cpp
@@ -48,10 +48,18 @@ public:
rx_dsp_core_200_impl(
wb_iface::sptr iface,
const size_t dsp_base, const size_t ctrl_base,
- const boost::uint32_t sid
+ const boost::uint32_t sid, const bool lingering_packet
):
_iface(iface), _dsp_base(dsp_base), _ctrl_base(ctrl_base)
{
+ //This is a hack/fix for the lingering packet problem.
+ //The caller should also flush the recv transports
+ if (lingering_packet){
+ stream_cmd_t stream_cmd(stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
+ stream_cmd.num_samps = 1;
+ issue_stream_command(stream_cmd);
+ }
+
_iface->poke32(REG_RX_CTRL_CLEAR, 1); //reset
_iface->poke32(REG_RX_CTRL_NCHANNELS, 1);
_iface->poke32(REG_RX_CTRL_VRT_HDR, 0
@@ -162,6 +170,6 @@ private:
bool _continuous_streaming;
};
-rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid){
- return sptr(new rx_dsp_core_200_impl(iface, dsp_base, ctrl_base, sid));
+rx_dsp_core_200::sptr rx_dsp_core_200::make(wb_iface::sptr iface, const size_t dsp_base, const size_t ctrl_base, const boost::uint32_t sid, const bool lingering_packet){
+ return sptr(new rx_dsp_core_200_impl(iface, dsp_base, ctrl_base, sid, lingering_packet));
}
diff --git a/host/lib/usrp/cores/rx_dsp_core_200.hpp b/host/lib/usrp/cores/rx_dsp_core_200.hpp
index 6bc7c6102..c496fca76 100644
--- a/host/lib/usrp/cores/rx_dsp_core_200.hpp
+++ b/host/lib/usrp/cores/rx_dsp_core_200.hpp
@@ -32,7 +32,7 @@ public:
static sptr make(
wb_iface::sptr iface,
const size_t dsp_base, const size_t ctrl_base,
- const boost::uint32_t sid
+ const boost::uint32_t sid, const bool lingering_packet = false
);
virtual void set_nsamps_per_packet(const size_t nsamps) = 0;
diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp
index 5b9186a32..bff55009e 100644
--- a/host/lib/usrp/dboard_manager.cpp
+++ b/host/lib/usrp/dboard_manager.cpp
@@ -471,54 +471,43 @@ void dboard_manager::populate_prop_tree_from_subdev(
const property_tree::path_type &root,
wax::obj subdev
){
- tree->create(root / "name", property<std::string>(subdev[SUBDEV_PROP_NAME].as<std::string>()));
+ tree->create<std::string>(root / "name").set(subdev[SUBDEV_PROP_NAME].as<std::string>());
const prop_names_t sensor_names = subdev[SUBDEV_PROP_SENSOR_NAMES].as<prop_names_t>();
BOOST_FOREACH(const std::string &name, sensor_names){
- property<sensor_value_t> sensor_prop;
- sensor_prop.publish(boost::bind(&get_sensor, subdev, name));
- tree->create(root / "sensors" / name, sensor_prop);
+ tree->create<sensor_value_t>(root / "sensors" / name)
+ .publish(boost::bind(&get_sensor, subdev, name));
}
const prop_names_t gain_names = subdev[SUBDEV_PROP_GAIN_NAMES].as<prop_names_t>();
BOOST_FOREACH(const std::string &name, gain_names){
- property<double> gain_prop;
- gain_prop.subscribe_master(boost::bind(&get_set_gain, subdev, name, _1));
- tree->create(root / "gains" / name / "value", gain_prop);
- property<meta_range_t> gain_range_prop;
- gain_range_prop.publish(boost::bind(&get_gain_range, subdev, name));
- tree->create(root / "gains" / name / "range", gain_range_prop);
+ tree->create<double>(root / "gains" / name / "value")
+ .subscribe_master(boost::bind(&get_set_gain, subdev, name, _1));
+ tree->create<meta_range_t>(root / "gains" / name / "range")
+ .publish(boost::bind(&get_gain_range, subdev, name));
}
- property<double> freq_prop;
- freq_prop.subscribe_master(boost::bind(&get_set_freq, subdev, _1));
- tree->create(root / "freq/value", freq_prop);
+ tree->create<double>(root / "freq/value")
+ .subscribe_master(boost::bind(&get_set_freq, subdev, _1));
- property<meta_range_t> freq_range_prop;
- freq_range_prop.publish(boost::bind(&get_freq_range, subdev));
- tree->create(root / "freq/range", freq_range_prop);
+ tree->create<meta_range_t>(root / "freq/range")
+ .publish(boost::bind(&get_freq_range, subdev));
- property<std::string> ant_prop;
- ant_prop.subscribe_master(boost::bind(&get_set_ant, subdev, _1));
- tree->create(root / "antenna/value", ant_prop);
+ tree->create<std::string>(root / "antenna/value")
+ .subscribe_master(boost::bind(&get_set_ant, subdev, _1));
- property<std::vector<std::string> > ants_prop;
- ants_prop.publish(boost::bind(&get_ants, subdev));
- tree->create(root / "antenna/options", ants_prop);
+ tree->create<std::vector<std::string> >(root / "antenna/options")
+ .publish(boost::bind(&get_ants, subdev));
- property<std::string> conn_prop;
- conn_prop.publish(boost::bind(&get_conn, subdev));
- tree->create(root / "connection", conn_prop);
+ tree->create<std::string>(root / "connection")
+ .publish(boost::bind(&get_conn, subdev));
- property<bool> enb_prop;
- enb_prop.subscribe_master(boost::bind(&get_set_enb, subdev, _1));
- tree->create(root / "enabled", enb_prop);
+ tree->create<bool>(root / "enabled")
+ .subscribe_master(boost::bind(&get_set_enb, subdev, _1));
- property<bool> use_lo_off_prop;
- use_lo_off_prop.publish(boost::bind(&get_use_lo_off, subdev));
- tree->create(root / "use_lo_offset", use_lo_off_prop);
+ tree->create<bool>(root / "use_lo_offset")
+ .publish(boost::bind(&get_use_lo_off, subdev));
- property<double> bw_prop;
- bw_prop.subscribe_master(boost::bind(&get_set_bw, subdev, _1));
- tree->create(root / "bandwidth/value", bw_prop);
+ tree->create<double>(root / "bandwidth/value")
+ .subscribe_master(boost::bind(&get_set_bw, subdev, _1));
}
diff --git a/host/lib/usrp2/io_impl.cpp b/host/lib/usrp2/io_impl.cpp
index 9f0792d53..5ebb1609d 100644
--- a/host/lib/usrp2/io_impl.cpp
+++ b/host/lib/usrp2/io_impl.cpp
@@ -246,7 +246,15 @@ void usrp2_impl::io_impl::recv_pirate_loop(
**********************************************************************/
void usrp2_impl::io_init(void){
- //TODO //This is a hack/fix for the lingering packet problem.
+ //setup rx otw type
+ _rx_otw_type.width = 16;
+ _rx_otw_type.shift = 0;
+ _rx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN;
+
+ //setup tx otw type
+ _tx_otw_type.width = 16;
+ _tx_otw_type.shift = 0;
+ _tx_otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN;
//create new io impl
_io_impl = UHD_PIMPL_MAKE(io_impl, (_mboard_stuff.size()));
diff --git a/host/lib/usrp2/usrp2_impl.cpp b/host/lib/usrp2/usrp2_impl.cpp
index cbe4a7dba..a66c4cd59 100644
--- a/host/lib/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp2/usrp2_impl.cpp
@@ -341,7 +341,9 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){
////////////////////////////////////////////////////////////////
_mboard_stuff[mb].clock = usrp2_clock_ctrl::make(_mboard_stuff[mb].iface);
const double tick_rate = _mboard_stuff[mb].clock->get_master_clock_rate();
- property<double> tick_rate_prop(tick_rate);
+ property<double> tick_rate_prop;
+ tick_rate_prop.publish(boost::bind(&usrp2_clock_ctrl::get_master_clock_rate, _mboard_stuff[mb].clock));
+ tick_rate_prop.subscribe(boost::bind(&usrp2_impl::update_tick_rate, this, _1));
_tree->create(mb_path / "tick_rate", tick_rate_prop);
////////////////////////////////////////////////////////////////
@@ -428,16 +430,20 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){
//TODO lots of properties to expose here for frontends
////////////////////////////////////////////////////////////////
- // create dsp control objects
+ // create rx dsp control objects
////////////////////////////////////////////////////////////////
_mboard_stuff[mb].rx_dsps.push_back(rx_dsp_core_200::make(
- _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP0), U2_REG_SR_ADDR(SR_RX_CTRL0), USRP2_RX_SID_BASE + 0
+ _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP0), U2_REG_SR_ADDR(SR_RX_CTRL0), USRP2_RX_SID_BASE + 0, true
));
_mboard_stuff[mb].rx_dsps.push_back(rx_dsp_core_200::make(
- _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP1), U2_REG_SR_ADDR(SR_RX_CTRL1), USRP2_RX_SID_BASE + 1
+ _mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_RX_DSP1), U2_REG_SR_ADDR(SR_RX_CTRL1), USRP2_RX_SID_BASE + 1, true
));
for (size_t dspno = 0; dspno < _mboard_stuff[mb].rx_dsps.size(); dspno++){
_mboard_stuff[mb].rx_dsps[dspno]->set_tick_rate(tick_rate); //does not change on usrp2
+ //This is a hack/fix for the lingering packet problem.
+ //The dsp core starts streaming briefly... now we flush
+ _mboard_stuff[mb].dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for lingering
+ _mboard_stuff[mb].dsp_xports[dspno]->get_recv_buff(0.01).get(); //recv with timeout for expected
property_tree::path_type rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno);
property<double> host_rate_prop, freq_prop;
host_rate_prop.subscribe_master(boost::bind(&rx_dsp_core_200::set_host_rate, _mboard_stuff[mb].rx_dsps[dspno], _1));
@@ -447,6 +453,10 @@ usrp2_impl::usrp2_impl(const device_addr_t &_device_addr){
//TODO set nsamps per packet
//TODO stream command issue
}
+
+ ////////////////////////////////////////////////////////////////
+ // create tx dsp control objects
+ ////////////////////////////////////////////////////////////////
_mboard_stuff[mb].tx_dsp = tx_dsp_core_200::make(
_mboard_stuff[mb].iface, U2_REG_SR_ADDR(SR_TX_DSP), U2_REG_SR_ADDR(SR_TX_CTRL), USRP2_TX_ASYNC_SID
);