From 4403d4ff7cb453451e792be388b15f7081545d67 Mon Sep 17 00:00:00 2001 From: "kurtis.heimerl" Date: Mon, 28 Nov 2011 06:26:04 +0000 Subject: [PATCH] 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 git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@2699 19bc5d8c-e614-43d4-8b26-e1612bc8e597 --- Transceiver52M/UHDDevice.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp index fd15332a..89f1231f 100644 --- a/Transceiver52M/UHDDevice.cpp +++ b/Transceiver52M/UHDDevice.cpp @@ -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;