Skip to content

Commit e8ca1a3

Browse files
xavierarteagacodebot
authored andcommitted
uhd: fix USRP b210 master clock overwrite
1 parent 0def6b4 commit e8ca1a3

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

lib/radio/uhd/radio_uhd_device.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class radio_uhd_device : public uhd_exception_handler
119119
}
120120
break;
121121
case radio_uhd_device_type::types::B2xx:
122+
if (!device_addr.has_key("master_clock_rate")) {
123+
automatic_master_clock_rate = true;
124+
}
125+
break;
122126
case radio_uhd_device_type::types::UNKNOWN:
123127
default:
124128
// No default parameters are required.
@@ -204,6 +208,11 @@ class radio_uhd_device : public uhd_exception_handler
204208
}
205209
bool set_automatic_master_clock_rate(double srate_Hz)
206210
{
211+
// Skip automatic master clock rate if it is not available.
212+
if (!automatic_master_clock_rate) {
213+
return true;
214+
}
215+
207216
return safe_execution([this, &srate_Hz]() {
208217
// Get range of valid master clock rates.
209218
uhd::meta_range_t range = usrp->get_master_clock_rate_range();
@@ -428,8 +437,9 @@ class radio_uhd_device : public uhd_exception_handler
428437
}
429438

430439
private:
431-
uhd::usrp::multi_usrp::sptr usrp = nullptr;
432-
radio_uhd_device_type type = radio_uhd_device_type::types::UNKNOWN;
440+
uhd::usrp::multi_usrp::sptr usrp = nullptr;
441+
radio_uhd_device_type type = radio_uhd_device_type::types::UNKNOWN;
442+
bool automatic_master_clock_rate = false;
433443
srslog::basic_logger& logger;
434444
};
435445

lib/radio/uhd/radio_uhd_impl.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,9 @@ radio_session_uhd_impl::radio_session_uhd_impl(const radio_configuration::radio&
251251
return;
252252
}
253253

254-
static const std::set<radio_uhd_device_type::types> automatic_mcr_devices = {radio_uhd_device_type::types::B2xx};
255-
if (automatic_mcr_devices.count(device.get_type())) {
256-
if (!device.set_automatic_master_clock_rate(radio_config.sampling_rate_hz)) {
257-
fmt::print("Error setting master clock rate. {}\n", device.get_error_message());
258-
return;
259-
}
254+
if (!device.set_automatic_master_clock_rate(radio_config.sampling_rate_hz)) {
255+
fmt::print("Error setting master clock rate. {}\n", device.get_error_message());
256+
return;
260257
}
261258

262259
// Set sync source.

0 commit comments

Comments
 (0)