multi_usrp: Fix setters for ALL_CHANS

Some setters in multi_usrp can take ALL_CHANS as channel parameter,
however there were differences between multi_usrp_rfnoc and multi_usrp.
This commit fixes this for set_trx_gain().
This commit is contained in:
Martin Anderseck 2024-02-13 13:21:34 +01:00 committed by Aki Tomita
parent 56c1a7c63b
commit f2e5ab4472

View File

@ -1453,38 +1453,28 @@ public:
*************************************************************************/
void set_rx_gain(double gain, const std::string& name, size_t chan) override
{
/* Check if any AGC mode is enable and if so warn the user */
if (chan != ALL_CHANS) {
if (_tree->exists(rx_rf_fe_root(chan) / "gain" / "agc")) {
/* Check if any AGC mode is enabled and if so warn the user */
for (size_t c = 0; c < get_rx_num_channels(); c++) {
if (chan != ALL_CHANS && c != chan) {
continue;
}
if (_tree->exists(rx_rf_fe_root(c) / "gain" / "agc")) {
bool agc =
_tree->access<bool>(rx_rf_fe_root(chan) / "gain" / "agc" / "enable")
_tree->access<bool>(rx_rf_fe_root(c) / "gain" / "agc" / "enable")
.get();
if (agc) {
UHD_LOGGER_WARNING("MULTI_USRP")
<< "AGC enabled for this channel. Setting will be ignored.";
UHD_LOGGER_WARNING("MULTI_USRP") << "AGC enabled for channel " << c
<< ". Setting will be ignored.";
}
}
} else {
for (size_t c = 0; c < get_rx_num_channels(); c++) {
if (_tree->exists(rx_rf_fe_root(c) / "gain" / "agc")) {
bool agc = _tree
->access<bool>(
rx_rf_fe_root(chan) / "gain" / "agc" / "enable")
.get();
if (agc) {
UHD_LOGGER_WARNING("MULTI_USRP")
<< "AGC enabled for this channel. Setting will be ignored.";
}
}
/* Apply gain settings to all channels.
* If device is in AGC mode it will ignore the setting. */
try {
rx_gain_group(c)->set_value(gain, name);
} catch (uhd::key_error&) {
THROW_GAIN_NAME_ERROR(name, c, rx);
}
}
/* Apply gain setting.
* If device is in AGC mode it will ignore the setting. */
try {
return rx_gain_group(chan)->set_value(gain, name);
} catch (uhd::key_error&) {
THROW_GAIN_NAME_ERROR(name, chan, rx);
}
}
void set_rx_gain_profile(const std::string& profile, const size_t chan) override
@ -2011,10 +2001,15 @@ public:
void set_tx_gain(double gain, const std::string& name, size_t chan) override
{
try {
return tx_gain_group(chan)->set_value(gain, name);
} catch (uhd::key_error&) {
THROW_GAIN_NAME_ERROR(name, chan, tx);
for (size_t c = 0; c < get_tx_num_channels(); c++) {
if (chan != ALL_CHANS && c != chan) {
continue;
}
try {
tx_gain_group(c)->set_value(gain, name);
} catch (uhd::key_error&) {
THROW_GAIN_NAME_ERROR(name, c, tx);
}
}
}