From ad31ba63c1005221550fce77488b6080ba166cfe Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Feb 2011 17:31:59 -0800 Subject: usrp: added sensors props to mboard and subdev (removed stupid = 'char' thing) --- host/include/uhd/types/ref_vector.hpp | 2 +- host/include/uhd/usrp/codec_props.hpp | 12 +++++----- host/include/uhd/usrp/dboard_props.hpp | 16 +++++++------- host/include/uhd/usrp/device_props.hpp | 8 +++---- host/include/uhd/usrp/dsp_props.hpp | 14 ++++++------ host/include/uhd/usrp/mboard_props.hpp | 40 ++++++++++++++++++---------------- host/include/uhd/usrp/subdev_props.hpp | 32 ++++++++++++++------------- 7 files changed, 64 insertions(+), 60 deletions(-) (limited to 'host') diff --git a/host/include/uhd/types/ref_vector.hpp b/host/include/uhd/types/ref_vector.hpp index 0ae301647..2928cb150 100644 --- a/host/include/uhd/types/ref_vector.hpp +++ b/host/include/uhd/types/ref_vector.hpp @@ -43,7 +43,7 @@ public: /*! * Create a reference vector from a std::vector container. * Therefore: rv[n] == vec[n] and rv.size() == vec.size() - * \param range a const reference to an std::vector + * \param vec a const reference to an std::vector */ template ref_vector(const Vector &vec): _ptr(T()), _mem(_mem_t(&vec.front())), _size(vec.size()) diff --git a/host/include/uhd/usrp/codec_props.hpp b/host/include/uhd/usrp/codec_props.hpp index 5d0a2913c..b0a79e3f6 100644 --- a/host/include/uhd/usrp/codec_props.hpp +++ b/host/include/uhd/usrp/codec_props.hpp @@ -28,12 +28,12 @@ namespace uhd{ namespace usrp{ * Other properties can be discovered through the others prop. */ enum codec_prop_t{ - CODEC_PROP_NAME = 'n', //ro, std::string - CODEC_PROP_OTHERS = 'o', //ro, prop_names_t - CODEC_PROP_GAIN_I = 'i', //rw, double - CODEC_PROP_GAIN_Q = 'q', //rw, double - CODEC_PROP_GAIN_RANGE = 'r', //ro, gain_range_t - CODEC_PROP_GAIN_NAMES = 'G' //ro, prop_names_t + CODEC_PROP_NAME, //ro, std::string + CODEC_PROP_OTHERS, //ro, prop_names_t + CODEC_PROP_GAIN_I, //rw, double + CODEC_PROP_GAIN_Q , //rw, double + CODEC_PROP_GAIN_RANGE, //ro, gain_range_t + CODEC_PROP_GAIN_NAMES //ro, prop_names_t }; diff --git a/host/include/uhd/usrp/dboard_props.hpp b/host/include/uhd/usrp/dboard_props.hpp index aab6c31ce..32ec1c1bf 100644 --- a/host/include/uhd/usrp/dboard_props.hpp +++ b/host/include/uhd/usrp/dboard_props.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -28,13 +28,13 @@ namespace uhd{ namespace usrp{ * A dboard is considered to be unidirectional (RX or TX). */ enum dboard_prop_t{ - DBOARD_PROP_NAME = 'n', //ro, std::string - DBOARD_PROP_SUBDEV = 's', //ro, wax::obj - DBOARD_PROP_SUBDEV_NAMES = 'S', //ro, prop_names_t - DBOARD_PROP_DBOARD_ID = 'i', //rw, dboard_id_t - DBOARD_PROP_DBOARD_IFACE = 'f', //ro, dboard_iface::sptr - DBOARD_PROP_CODEC = 'c', //ro, wax::obj - DBOARD_PROP_GAIN_GROUP = 'g' //ro, gain_group + DBOARD_PROP_NAME, //ro, std::string + DBOARD_PROP_SUBDEV, //ro, wax::obj + DBOARD_PROP_SUBDEV_NAMES, //ro, prop_names_t + DBOARD_PROP_DBOARD_ID, //rw, dboard_id_t + DBOARD_PROP_DBOARD_IFACE, //ro, dboard_iface::sptr + DBOARD_PROP_CODEC, //ro, wax::obj + DBOARD_PROP_GAIN_GROUP //ro, gain_group }; }} //namespace diff --git a/host/include/uhd/usrp/device_props.hpp b/host/include/uhd/usrp/device_props.hpp index 346eec179..3c8f7e225 100644 --- a/host/include/uhd/usrp/device_props.hpp +++ b/host/include/uhd/usrp/device_props.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -29,9 +29,9 @@ namespace uhd{ namespace usrp{ * will be present in the interface for configuration. */ enum device_prop_t{ - DEVICE_PROP_NAME = 'n', //ro, std::string - DEVICE_PROP_MBOARD = 'm', //ro, wax::obj - DEVICE_PROP_MBOARD_NAMES = 'M' //ro, prop_names_t + DEVICE_PROP_NAME, //ro, std::string + DEVICE_PROP_MBOARD, //ro, wax::obj + DEVICE_PROP_MBOARD_NAMES, //ro, prop_names_t }; }} //namespace diff --git a/host/include/uhd/usrp/dsp_props.hpp b/host/include/uhd/usrp/dsp_props.hpp index 54ea5666b..3e1690317 100644 --- a/host/include/uhd/usrp/dsp_props.hpp +++ b/host/include/uhd/usrp/dsp_props.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -37,12 +37,12 @@ namespace uhd{ namespace usrp{ * Set the shift property and read it back to get actual shift. */ enum dsp_prop_t{ - DSP_PROP_NAME = 'n', //ro, std::string - DSP_PROP_OTHERS = 'o', //ro, prop_names_t - DSP_PROP_FREQ_SHIFT = 'f', //rw, double Hz - DSP_PROP_FREQ_SHIFT_NAMES = 'F', //ro, prop_names_t - DSP_PROP_CODEC_RATE = 'c', //ro, double Sps - DSP_PROP_HOST_RATE = 'h' //rw, double Sps + DSP_PROP_NAME, //ro, std::string + DSP_PROP_OTHERS, //ro, prop_names_t + DSP_PROP_FREQ_SHIFT, //rw, double Hz + DSP_PROP_FREQ_SHIFT_NAMES, //ro, prop_names_t + DSP_PROP_CODEC_RATE, //ro, double Sps + DSP_PROP_HOST_RATE //rw, double Sps }; }} //namespace diff --git a/host/include/uhd/usrp/mboard_props.hpp b/host/include/uhd/usrp/mboard_props.hpp index d04ad012c..559c96ecb 100644 --- a/host/include/uhd/usrp/mboard_props.hpp +++ b/host/include/uhd/usrp/mboard_props.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -29,24 +29,26 @@ namespace uhd{ namespace usrp{ * and discovered though the others property. */ enum mboard_prop_t{ - MBOARD_PROP_NAME = 'n', //ro, std::string - MBOARD_PROP_OTHERS = 'o', //ro, prop_names_t - MBOARD_PROP_CLOCK_RATE = 'c', //rw, double - MBOARD_PROP_RX_DSP = 'd', //ro, wax::obj - MBOARD_PROP_RX_DSP_NAMES = 'D', //ro, prop_names_t - MBOARD_PROP_TX_DSP = 'u', //ro, wax::obj - MBOARD_PROP_TX_DSP_NAMES = 'U', //ro, prop_names_t - MBOARD_PROP_RX_DBOARD = 'e', //ro, wax::obj - MBOARD_PROP_RX_DBOARD_NAMES = 'E', //ro, prop_names_t - MBOARD_PROP_TX_DBOARD = 'v', //ro, wax::obj - MBOARD_PROP_TX_DBOARD_NAMES = 'V', //ro, prop_names_t - MBOARD_PROP_RX_SUBDEV_SPEC = 'r', //rw, subdev_spec_t - MBOARD_PROP_TX_SUBDEV_SPEC = 'R', //rw, subdev_spec_t - MBOARD_PROP_CLOCK_CONFIG = 'C', //rw, clock_config_t - MBOARD_PROP_TIME_NOW = 't', //rw, time_spec_t - MBOARD_PROP_TIME_PPS = 'T', //wo, time_spec_t - MBOARD_PROP_STREAM_CMD = 's', //wo, stream_cmd_t - MBOARD_PROP_EEPROM_MAP = 'M' //wr, mboard_eeprom_t::sptr + MBOARD_PROP_NAME, //ro, std::string + MBOARD_PROP_OTHERS, //ro, prop_names_t + MBOARD_PROP_SENSOR, //ro, sensor_value_t + MBOARD_PROP_SENSOR_NAMES, //ro, prop_names_t + MBOARD_PROP_CLOCK_RATE, //rw, double + MBOARD_PROP_RX_DSP, //ro, wax::obj + MBOARD_PROP_RX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DSP, //ro, wax::obj + MBOARD_PROP_TX_DSP_NAMES, //ro, prop_names_t + MBOARD_PROP_RX_DBOARD, //ro, wax::obj + MBOARD_PROP_RX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_TX_DBOARD, //ro, wax::obj + MBOARD_PROP_TX_DBOARD_NAMES, //ro, prop_names_t + MBOARD_PROP_RX_SUBDEV_SPEC, //rw, subdev_spec_t + MBOARD_PROP_TX_SUBDEV_SPEC, //rw, subdev_spec_t + MBOARD_PROP_CLOCK_CONFIG, //rw, clock_config_t + MBOARD_PROP_TIME_NOW, //rw, time_spec_t + MBOARD_PROP_TIME_PPS, //wo, time_spec_t + MBOARD_PROP_STREAM_CMD, //wo, stream_cmd_t + MBOARD_PROP_EEPROM_MAP //wr, mboard_eeprom_t::sptr }; }} //namespace diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp index 8d05f4c27..87628fadc 100644 --- a/host/include/uhd/usrp/subdev_props.hpp +++ b/host/include/uhd/usrp/subdev_props.hpp @@ -42,21 +42,23 @@ namespace uhd{ namespace usrp{ * Possible device subdev properties */ enum subdev_prop_t{ - SUBDEV_PROP_NAME = 'n', //ro, std::string - SUBDEV_PROP_OTHERS = 'o', //ro, prop_names_t - SUBDEV_PROP_GAIN = 'g', //rw, double - SUBDEV_PROP_GAIN_RANGE = 'r', //ro, gain_range_t - SUBDEV_PROP_GAIN_NAMES = 'G', //ro, prop_names_t - SUBDEV_PROP_FREQ = 'f', //rw, double - SUBDEV_PROP_FREQ_RANGE = 'F', //ro, freq_range_t - SUBDEV_PROP_ANTENNA = 'a', //rw, std::string - SUBDEV_PROP_ANTENNA_NAMES = 'A', //ro, prop_names_t - SUBDEV_PROP_LO_LOCKED = 'L', //ro, bool - SUBDEV_PROP_CONNECTION = 'c', //ro, subdev_conn_t - SUBDEV_PROP_ENABLED = 'e', //rw, bool - SUBDEV_PROP_USE_LO_OFFSET = 'l', //ro, bool - SUBDEV_PROP_RSSI = 'R', //ro, double - SUBDEV_PROP_BANDWIDTH = 'B' //rw, double + SUBDEV_PROP_NAME, //ro, std::string + SUBDEV_PROP_OTHERS, //ro, prop_names_t + SUBDEV_PROP_SENSOR, //ro, sensor_value_t + SUBDEV_PROP_SENSOR_NAMES, //ro, prop_names_t + SUBDEV_PROP_GAIN, //rw, double + SUBDEV_PROP_GAIN_RANGE, //ro, gain_range_t + SUBDEV_PROP_GAIN_NAMES, //ro, prop_names_t + SUBDEV_PROP_FREQ, //rw, double + SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t + SUBDEV_PROP_ANTENNA, //rw, std::string + SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t + SUBDEV_PROP_LO_LOCKED, //ro, bool //TODO deprecate for sensors + SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t + SUBDEV_PROP_ENABLED, //rw, bool + SUBDEV_PROP_USE_LO_OFFSET, //ro, bool + SUBDEV_PROP_RSSI, //ro, double //TODO deprecate for sensors + SUBDEV_PROP_BANDWIDTH //rw, double }; }} //namespace -- cgit v1.2.3 From e4b45cca1b99d92baab061d36b6c0ceaebdfe5b7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Feb 2011 18:07:24 -0800 Subject: usrp: added get sensors api to multi usrp for rx/tx subdevs and mboard --- host/include/uhd/usrp/multi_usrp.hpp | 46 ++++++++++++++++++++++++++++++++++++ host/lib/usrp/multi_usrp.cpp | 24 +++++++++++++++++++ 2 files changed, 70 insertions(+) (limited to 'host') diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 60b757f50..28c1860d6 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -231,6 +232,21 @@ public: */ virtual size_t get_num_mboards(void) = 0; + /*! + * Get a motherboard sensor value. + * \param name the name of the sensor + * \param mboard the motherboard index 0 to M-1 + * \return a sensor value object + */ + virtual sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard = 0) = 0; + + /*! + * Get a list of possible motherboard sensor names. + * \param mboard the motherboard index 0 to M-1 + * \return a vector of sensor names + */ + virtual std::vector get_mboard_sensor_names(size_t mboard = 0) = 0; + /******************************************************************* * RX methods ******************************************************************/ @@ -410,6 +426,21 @@ public: */ virtual dboard_iface::sptr get_rx_dboard_iface(size_t chan = 0) = 0; + /*! + * Get an RX subdevice sensor value. + * \param name the name of the sensor + * \param chan the channel index 0 to N-1 + * \return a sensor value object + */ + virtual sensor_value_t get_rx_sensor(const std::string &name, size_t chan = 0) = 0; + + /*! + * Get a list of possible RX subdevice sensor names. + * \param chan the channel index 0 to N-1 + * \return a vector of sensor names + */ + virtual std::vector get_rx_sensor_names(size_t chan = 0) = 0; + /******************************************************************* * TX methods ******************************************************************/ @@ -580,6 +611,21 @@ public: * \return the dboard interface sptr */ virtual dboard_iface::sptr get_tx_dboard_iface(size_t chan = 0) = 0; + + /*! + * Get an TX subdevice sensor value. + * \param name the name of the sensor + * \param chan the channel index 0 to N-1 + * \return a sensor value object + */ + virtual sensor_value_t get_tx_sensor(const std::string &name, size_t chan = 0) = 0; + + /*! + * Get a list of possible TX subdevice sensor names. + * \param chan the channel index 0 to N-1 + * \return a vector of sensor names + */ + virtual std::vector get_tx_sensor_names(size_t chan = 0) = 0; }; }} diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 4bdb2bf2e..e4e70b594 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -214,6 +214,14 @@ public: return (*_dev)[DEVICE_PROP_MBOARD_NAMES].as().size(); } + sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){ + return _mboard(mboard)[named_prop_t(MBOARD_PROP_SENSOR, name)].as(); + } + + std::vector get_mboard_sensor_names(size_t mboard){ + return _mboard(mboard)[MBOARD_PROP_SENSOR_NAMES].as(); + } + /******************************************************************* * RX methods ******************************************************************/ @@ -312,6 +320,14 @@ public: return _rx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as(); } + sensor_value_t get_rx_sensor(const std::string &name, size_t chan){ + return _rx_subdev(chan)[named_prop_t(SUBDEV_PROP_SENSOR, name)].as(); + } + + std::vector get_rx_sensor_names(size_t chan){ + return _rx_subdev(chan)[SUBDEV_PROP_SENSOR_NAMES].as(); + } + /******************************************************************* * TX methods ******************************************************************/ @@ -406,6 +422,14 @@ public: return _tx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as(); } + sensor_value_t get_tx_sensor(const std::string &name, size_t chan){ + return _tx_subdev(chan)[named_prop_t(SUBDEV_PROP_SENSOR, name)].as(); + } + + std::vector get_tx_sensor_names(size_t chan){ + return _tx_subdev(chan)[SUBDEV_PROP_SENSOR_NAMES].as(); + } + private: device::sptr _dev; -- cgit v1.2.3 From 9de6f36bc5d9f5d9d602547166c92b53b278b428 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Feb 2011 18:43:20 -0800 Subject: usrp: implement sensors in all the dboards, deprecated read rssi and get lo locked --- host/examples/rx_samples_to_file.cpp | 1 - host/examples/rx_samples_to_udp.cpp | 1 - host/include/uhd/usrp/multi_usrp.hpp | 13 ++++++++++--- host/include/uhd/usrp/subdev_props.hpp | 2 -- host/lib/usrp/dboard/db_basic_and_lf.cpp | 8 -------- host/lib/usrp/dboard/db_dbsrx.cpp | 10 ++++++++-- host/lib/usrp/dboard/db_dbsrx2.cpp | 10 ++++++++-- host/lib/usrp/dboard/db_rfx.cpp | 19 +++++++++++++++---- host/lib/usrp/dboard/db_tvrx.cpp | 5 +---- host/lib/usrp/dboard/db_unknown.cpp | 8 -------- host/lib/usrp/dboard/db_wbx.cpp | 19 +++++++++++++++---- host/lib/usrp/dboard/db_xcvr2450.cpp | 25 +++++++++++++++++++------ host/lib/usrp/multi_usrp.cpp | 12 ------------ 13 files changed, 76 insertions(+), 57 deletions(-) (limited to 'host') diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 296f480b0..e202fcb1c 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -78,7 +78,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl; boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time - std::cout << "LO Locked = " << usrp->get_rx_lo_locked() << std::endl; //setup streaming uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index 801d8e361..7ea775764 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -80,7 +80,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl; boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time - std::cout << "LO Locked = " << usrp->get_rx_lo_locked() << std::endl; //setup streaming uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE); diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index 28c1860d6..da52e6dce 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -28,6 +28,7 @@ #include #include #include +#include //needed until deprecated routines removed #include #include #include @@ -393,7 +394,9 @@ public: * \param chan the channel index 0 to N-1 * \return true for locked */ - virtual bool get_rx_lo_locked(size_t chan = 0) = 0; + UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){ + return this->get_rx_sensor("lo_locked", chan).value == "true"; + } /*! * Set the RX bandwidth on the subdevice. @@ -415,7 +418,9 @@ public: * \return the rssi in dB * \throw exception if RSSI readback not supported */ - virtual double read_rssi(size_t chan = 0) = 0; + UHD_DEPRECATED double read_rssi(size_t chan = 0){ + return boost::lexical_cast(this->get_rx_sensor("rssi", chan).value); + } /*! * Get the dboard interface object for the RX subdevice. @@ -587,7 +592,9 @@ public: * \param chan the channel index 0 to N-1 * \return true for locked */ - virtual bool get_tx_lo_locked(size_t chan = 0) = 0; + UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){ + return this->get_tx_sensor("lo_locked", chan).value == "true"; + } /*! * Set the TX bandwidth on the subdevice. diff --git a/host/include/uhd/usrp/subdev_props.hpp b/host/include/uhd/usrp/subdev_props.hpp index 87628fadc..40b339703 100644 --- a/host/include/uhd/usrp/subdev_props.hpp +++ b/host/include/uhd/usrp/subdev_props.hpp @@ -53,11 +53,9 @@ namespace uhd{ namespace usrp{ SUBDEV_PROP_FREQ_RANGE, //ro, freq_range_t SUBDEV_PROP_ANTENNA, //rw, std::string SUBDEV_PROP_ANTENNA_NAMES, //ro, prop_names_t - SUBDEV_PROP_LO_LOCKED, //ro, bool //TODO deprecate for sensors SUBDEV_PROP_CONNECTION, //ro, subdev_conn_t SUBDEV_PROP_ENABLED, //rw, bool SUBDEV_PROP_USE_LO_OFFSET, //ro, bool - SUBDEV_PROP_RSSI, //ro, double //TODO deprecate for sensors SUBDEV_PROP_BANDWIDTH //rw, double }; diff --git a/host/lib/usrp/dboard/db_basic_and_lf.cpp b/host/lib/usrp/dboard/db_basic_and_lf.cpp index b311576d2..b319289db 100644 --- a/host/lib/usrp/dboard/db_basic_and_lf.cpp +++ b/host/lib/usrp/dboard/db_basic_and_lf.cpp @@ -173,10 +173,6 @@ void basic_rx::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = true; //there is no LO, so it must be true! - return; - case SUBDEV_PROP_BANDWIDTH: val = subdev_bandwidth_scalar[get_subdev_name()]*_max_freq; return; @@ -284,10 +280,6 @@ void basic_tx::tx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = true; //there is no LO, so it must be true! - return; - case SUBDEV_PROP_BANDWIDTH: val = subdev_bandwidth_scalar[get_subdev_name()]*_max_freq; return; diff --git a/host/lib/usrp/dboard/db_dbsrx.cpp b/host/lib/usrp/dboard/db_dbsrx.cpp index 3ea9cea80..98d9479fc 100644 --- a/host/lib/usrp/dboard/db_dbsrx.cpp +++ b/host/lib/usrp/dboard/db_dbsrx.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -561,8 +562,13 @@ void dbsrx::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_dbsrx2.cpp b/host/lib/usrp/dboard/db_dbsrx2.cpp index defb70ff5..f4b797995 100644 --- a/host/lib/usrp/dboard/db_dbsrx2.cpp +++ b/host/lib/usrp/dboard/db_dbsrx2.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -400,8 +401,13 @@ void dbsrx2::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_rfx.cpp b/host/lib/usrp/dboard/db_rfx.cpp index cd25ee9b7..3b0c562ee 100644 --- a/host/lib/usrp/dboard/db_rfx.cpp +++ b/host/lib/usrp/dboard/db_rfx.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -451,8 +452,13 @@ void rfx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(dboard_iface::UNIT_RX); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(dboard_iface::UNIT_RX), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: @@ -548,8 +554,13 @@ void rfx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ val = true; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(dboard_iface::UNIT_TX); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(dboard_iface::UNIT_TX), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_tvrx.cpp b/host/lib/usrp/dboard/db_tvrx.cpp index a9ce38000..578999432 100644 --- a/host/lib/usrp/dboard/db_tvrx.cpp +++ b/host/lib/usrp/dboard/db_tvrx.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -463,10 +464,6 @@ void tvrx::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = true; - return; - case SUBDEV_PROP_BANDWIDTH: val = 6.0e6; return; diff --git a/host/lib/usrp/dboard/db_unknown.cpp b/host/lib/usrp/dboard/db_unknown.cpp index d91d58409..f0a4c000e 100644 --- a/host/lib/usrp/dboard/db_unknown.cpp +++ b/host/lib/usrp/dboard/db_unknown.cpp @@ -154,10 +154,6 @@ void unknown_rx::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = true; //there is no LO, so it must be true! - return; - case SUBDEV_PROP_BANDWIDTH: val = 0.0; return; @@ -256,10 +252,6 @@ void unknown_tx::tx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = true; //there is no LO, so it must be true! - return; - case SUBDEV_PROP_BANDWIDTH: val = 0.0; return; diff --git a/host/lib/usrp/dboard/db_wbx.cpp b/host/lib/usrp/dboard/db_wbx.cpp index 135997789..0bc2d0ca1 100644 --- a/host/lib/usrp/dboard/db_wbx.cpp +++ b/host/lib/usrp/dboard/db_wbx.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -521,8 +522,13 @@ void wbx_xcvr::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(dboard_iface::UNIT_RX); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(dboard_iface::UNIT_RX), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: @@ -622,8 +628,13 @@ void wbx_xcvr::tx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(dboard_iface::UNIT_TX); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(dboard_iface::UNIT_TX), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp index 6fb5a26a8..f4f74eb86 100644 --- a/host/lib/usrp/dboard/db_xcvr2450.cpp +++ b/host/lib/usrp/dboard/db_xcvr2450.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -616,12 +617,19 @@ void xcvr2450::rx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(); + case SUBDEV_PROP_SENSOR: + if (key.name == "lo_locked") + val = sensor_value_t("LO", this->get_locked(), "locked", "unlocked"); + else if (key.name == "rssi") + val = sensor_value_t("RSSI", this->get_rssi(), "dB"); + else + UHD_THROW_INVALID_CODE_PATH(); return; - case SUBDEV_PROP_RSSI: - val = this->get_rssi(); + case SUBDEV_PROP_SENSOR_NAMES:{ + prop_names_t names = list_of("lo_locked")("rssi"); + val = names; + } return; case SUBDEV_PROP_BANDWIDTH: @@ -719,8 +727,13 @@ void xcvr2450::tx_get(const wax::obj &key_, wax::obj &val){ val = false; return; - case SUBDEV_PROP_LO_LOCKED: - val = this->get_locked(); + case SUBDEV_PROP_SENSOR: + UHD_ASSERT_THROW(key.name == "lo_locked"); + val = sensor_value_t("LO", this->get_locked(), "locked", "unlocked"); + return; + + case SUBDEV_PROP_SENSOR_NAMES: + val = prop_names_t(1, "lo_locked"); return; case SUBDEV_PROP_BANDWIDTH: diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index e4e70b594..73bac029d 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -300,10 +300,6 @@ public: return _rx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); } - bool get_rx_lo_locked(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as(); - } - void set_rx_bandwidth(double bandwidth, size_t chan){ _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth; } @@ -312,10 +308,6 @@ public: return _rx_subdev(chan)[SUBDEV_PROP_BANDWIDTH].as(); } - double read_rssi(size_t chan){ - return _rx_subdev(chan)[SUBDEV_PROP_RSSI].as(); - } - dboard_iface::sptr get_rx_dboard_iface(size_t chan){ return _rx_dboard(chan)[DBOARD_PROP_DBOARD_IFACE].as(); } @@ -406,10 +398,6 @@ public: return _tx_subdev(chan)[SUBDEV_PROP_ANTENNA_NAMES].as(); } - bool get_tx_lo_locked(size_t chan){ - return _tx_subdev(chan)[SUBDEV_PROP_LO_LOCKED].as(); - } - void set_tx_bandwidth(double bandwidth, size_t chan){ _tx_subdev(chan)[SUBDEV_PROP_BANDWIDTH] = bandwidth; } -- cgit v1.2.3 From 4613f454c781d258d6d9b210ff1b9043a2125981 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 11 Feb 2011 21:52:13 -0800 Subject: uhd: added to_ calls to sensors to make it easy --- host/include/uhd/types/sensors.hpp | 19 +++++++++++-------- host/include/uhd/usrp/multi_usrp.hpp | 7 +++---- host/lib/types/sensors.cpp | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 14 deletions(-) (limited to 'host') diff --git a/host/include/uhd/types/sensors.hpp b/host/include/uhd/types/sensors.hpp index 6f003bb40..b6215367f 100644 --- a/host/include/uhd/types/sensors.hpp +++ b/host/include/uhd/types/sensors.hpp @@ -37,12 +37,6 @@ namespace uhd{ */ struct UHD_API sensor_value_t{ - //! typedef for the signed integer type - typedef signed int_type; - - //! typedef for the real number type - typedef double real_type; - /*! * Create a sensor value from a boolean. * \param name the name of the sensor @@ -66,7 +60,7 @@ namespace uhd{ */ sensor_value_t( const std::string &name, - int_type value, + signed value, const std::string &unit, const std::string &formatter = "%d" ); @@ -80,7 +74,7 @@ namespace uhd{ */ sensor_value_t( const std::string &name, - real_type value, + double value, const std::string &unit, const std::string &formatter = "%f" ); @@ -97,6 +91,15 @@ namespace uhd{ const std::string &unit ); + //! convert the sensor value to a boolean + bool to_bool(void) const; + + //! convert the sensor value to an integer + signed to_int(void) const; + + //! convert the sensor value to real number + double to_real(void) const; + //! The name of the sensor value const std::string name; diff --git a/host/include/uhd/usrp/multi_usrp.hpp b/host/include/uhd/usrp/multi_usrp.hpp index da52e6dce..3c8dd5fac 100644 --- a/host/include/uhd/usrp/multi_usrp.hpp +++ b/host/include/uhd/usrp/multi_usrp.hpp @@ -28,7 +28,6 @@ #include #include #include -#include //needed until deprecated routines removed #include #include #include @@ -395,7 +394,7 @@ public: * \return true for locked */ UHD_DEPRECATED bool get_rx_lo_locked(size_t chan = 0){ - return this->get_rx_sensor("lo_locked", chan).value == "true"; + return this->get_rx_sensor("lo_locked", chan).to_bool(); } /*! @@ -419,7 +418,7 @@ public: * \throw exception if RSSI readback not supported */ UHD_DEPRECATED double read_rssi(size_t chan = 0){ - return boost::lexical_cast(this->get_rx_sensor("rssi", chan).value); + return this->get_rx_sensor("rssi", chan).to_real(); } /*! @@ -593,7 +592,7 @@ public: * \return true for locked */ UHD_DEPRECATED bool get_tx_lo_locked(size_t chan = 0){ - return this->get_tx_sensor("lo_locked", chan).value == "true"; + return this->get_tx_sensor("lo_locked", chan).to_bool(); } /*! diff --git a/host/lib/types/sensors.cpp b/host/lib/types/sensors.cpp index 2bff136a4..5f7115d70 100644 --- a/host/lib/types/sensors.cpp +++ b/host/lib/types/sensors.cpp @@ -17,6 +17,7 @@ #include #include +#include #include using namespace uhd; @@ -35,7 +36,7 @@ sensor_value_t::sensor_value_t( sensor_value_t::sensor_value_t( const std::string &name, - int_type value, + signed value, const std::string &unit, const std::string &formatter ): @@ -47,7 +48,7 @@ sensor_value_t::sensor_value_t( sensor_value_t::sensor_value_t( const std::string &name, - real_type value, + double value, const std::string &unit, const std::string &formatter ): @@ -79,3 +80,15 @@ std::string sensor_value_t::to_pp_string(void) const{ } UHD_THROW_INVALID_CODE_PATH(); } + +bool sensor_value_t::to_bool(void) const{ + return value == "true"; +} + +signed sensor_value_t::to_int(void) const{ + return boost::lexical_cast(value); +} + +double sensor_value_t::to_real(void) const{ + return boost::lexical_cast(value); +} -- cgit v1.2.3