From b36fa03407f43dfc8e93a719186264b8d3e6db52 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 8 Jan 2021 13:12:34 +0100 Subject: uhd: Fix radio_control-related method constness The const-ness of some radio_control differed between base class and implementation. This fixes the consistency, but also makes sure these methods follow the rules for when to make methods 'const'. The following rules apply: - Methods that query static capabilities are const. Here, we made get_tx_lo_sources() const (the RX version was already const). - Getters that may have to interact with the device (e.g., peek a register) are not const, because the act of peeking is usually also non-const. Here, we changed get_rx_lo_export_enabled() to non-const. - All base classes are fixed such that the derived classes and the base classes have the same const-ness. Clang was warning about differences. This can cause very tricky bugs, where the radio_control_impl version can get called instead of the intended child class. --- host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp') diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp index 3881c9285..b84fcee6d 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_control.cpp @@ -767,7 +767,7 @@ void magnesium_radio_control_impl::set_rx_lo_source( const std::string magnesium_radio_control_impl::get_rx_lo_source( const std::string& name, const size_t /*chan*/ -) const +) { if (name == MAGNESIUM_LO1) { // TODO: should we use this from cache? @@ -1073,7 +1073,7 @@ eeprom_map_t magnesium_radio_control_impl::get_db_eeprom() /************************************************************************** * Sensor API *************************************************************************/ -std::vector magnesium_radio_control_impl::get_rx_sensor_names(size_t) +std::vector magnesium_radio_control_impl::get_rx_sensor_names(size_t) const { auto sensor_names = _rpcc->request_with_token>( this->_rpc_prefix + "get_sensors", "RX"); @@ -1092,7 +1092,7 @@ sensor_value_t magnesium_radio_control_impl::get_rx_sensor( _rpc_prefix + "get_sensor", "RX", name, chan)); } -std::vector magnesium_radio_control_impl::get_tx_sensor_names(size_t) +std::vector magnesium_radio_control_impl::get_tx_sensor_names(size_t) const { auto sensor_names = _rpcc->request_with_token>( this->_rpc_prefix + "get_sensors", "TX"); -- cgit v1.2.3