diff options
Diffstat (limited to 'gr-uhd')
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_sink.h | 30 | ||||
-rw-r--r-- | gr-uhd/include/gr_uhd_usrp_source.h | 30 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_sink.cc | 16 | ||||
-rw-r--r-- | gr-uhd/lib/gr_uhd_usrp_source.cc | 16 | ||||
-rw-r--r-- | gr-uhd/swig/__init__.py | 7 | ||||
-rw-r--r-- | gr-uhd/swig/uhd_swig.i | 2 |
6 files changed, 99 insertions, 2 deletions
diff --git a/gr-uhd/include/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index 109c83a6e..557cb2cdb 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -149,6 +149,36 @@ public: virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! + * Get a daughterboard sensor value. + * \param name the name of the sensor + * \param chan the channel index 0 to N-1 + * \return a sensor value object + */ + virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0; + + /*! + * Get a list of possible daughterboard sensor names. + * \param chan the channel index 0 to N-1 + * \return a vector of sensor names + */ + virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 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 uhd::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<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; + + /*! * Set the clock configuration. * \param clock_config the new configuration * \param mboard the motherboard index 0 to M-1 diff --git a/gr-uhd/include/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index 43420e01c..3b36bf45d 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -149,6 +149,36 @@ public: virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! + * Get a daughterboard sensor value. + * \param name the name of the sensor + * \param chan the channel index 0 to N-1 + * \return a sensor value object + */ + virtual uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan = 0) = 0; + + /*! + * Get a list of possible daughterboard sensor names. + * \param chan the channel index 0 to N-1 + * \return a vector of sensor names + */ + virtual std::vector<std::string> get_dboard_sensor_names(size_t chan = 0) = 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 uhd::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<std::string> get_mboard_sensor_names(size_t mboard = 0) = 0; + + /*! * Set the clock configuration. * \param clock_config the new configuration * \param mboard the motherboard index 0 to M-1 diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 168ebd210..4598e54c2 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -105,6 +105,22 @@ public: return _dev->set_tx_bandwidth(bandwidth, chan); } + uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan){ + return _dev->get_tx_sensor(name, chan); + } + + std::vector<std::string> get_dboard_sensor_names(size_t chan){ + return _dev->get_tx_sensor_names(chan); + } + + uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){ + return _dev->get_mboard_sensor(name, mboard); + } + + std::vector<std::string> get_mboard_sensor_names(size_t mboard){ + return _dev->get_mboard_sensor_names(mboard); + } + void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){ return _dev->set_clock_config(clock_config, mboard); } diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 4ae446332..09cced567 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -105,6 +105,22 @@ public: return _dev->set_rx_bandwidth(bandwidth, chan); } + uhd::sensor_value_t get_dboard_sensor(const std::string &name, size_t chan){ + return _dev->get_rx_sensor(name, chan); + } + + std::vector<std::string> get_dboard_sensor_names(size_t chan){ + return _dev->get_rx_sensor_names(chan); + } + + uhd::sensor_value_t get_mboard_sensor(const std::string &name, size_t mboard){ + return _dev->get_mboard_sensor(name, mboard); + } + + std::vector<std::string> get_mboard_sensor_names(size_t mboard){ + return _dev->get_mboard_sensor_names(mboard); + } + void set_clock_config(const uhd::clock_config_t &clock_config, size_t mboard){ return _dev->set_clock_config(clock_config, mboard); } diff --git a/gr-uhd/swig/__init__.py b/gr-uhd/swig/__init__.py index 276f381d0..7ed689ec0 100644 --- a/gr-uhd/swig/__init__.py +++ b/gr-uhd/swig/__init__.py @@ -52,8 +52,11 @@ def _prepare_uhd_swig(): #Create aliases for uhd swig attributes to avoid the "_t" for attr in dir(uhd_swig): myobj = getattr(uhd_swig, attr) - if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda s: s.to_string().strip() - if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda s: s.to_pp_string().strip() + if hasattr(myobj, 'to_string'): myobj.__repr__ = lambda o: o.to_string().strip() + if hasattr(myobj, 'to_pp_string'): myobj.__str__ = lambda o: o.to_pp_string().strip() + if hasattr(myobj, 'to_bool'): myobj.__nonzero__ = lambda o: o.to_bool() + if hasattr(myobj, 'to_int'): myobj.__int__ = lambda o: o.to_int() + if hasattr(myobj, 'to_real'): myobj.__float__ = lambda o: o.to_real() if attr.endswith('_t'): setattr(uhd_swig, attr[:-2], myobj) #Cast constructor args (FIXME swig handle overloads?) diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i index a42344fab..b814471b2 100644 --- a/gr-uhd/swig/uhd_swig.i +++ b/gr-uhd/swig/uhd_swig.i @@ -91,6 +91,8 @@ %include <uhd/device.hpp> %template(device_addr_vector_t) std::vector<uhd::device_addr_t>; +%include <uhd/types/sensors.hpp> + //////////////////////////////////////////////////////////////////////// // swig dboard_iface for python access //////////////////////////////////////////////////////////////////////// |