transceiver, uhd: exit informatively if no devices are found

Perform a UHD device search before constructing the object,
and inform the user if no device is found.

No device found is the most common reason for the transceiver
to fail with the dreaded error "assuming TRX is dead".

Signed-off-by: Thomas Tsou <ttsou@vt.edu>

git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2699 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
Kurtis Heimerl
2011-11-28 06:26:04 +00:00
parent 8b45fb52ef
commit 847b05e885

View File

@@ -425,11 +425,18 @@ bool uhd_device::open()
// Register msg handler
uhd::msg::register_handler(&uhd_msg_handler);
// Allow all UHD devices
LOG(INFO) << "Creating transceiver with first found UHD device";
uhd::device_addr_t dev_addr("");
// Find UHD devices
uhd::device_addr_t args("");
uhd::device_addrs_t dev_addrs = uhd::device::find(args);
if (dev_addrs.size() == 0) {
LOG(ALERT) << "No UHD devices found";
return false;
}
// Use the first found device
LOG(INFO) << "Using discovered UHD device " << dev_addrs[0].to_string();
try {
usrp_dev = uhd::usrp::single_usrp::make(dev_addr);
usrp_dev = uhd::usrp::single_usrp::make(dev_addrs[0]);
} catch(...) {
LOG(ALERT) << "UHD make failed";
return false;