aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-03-28 15:48:01 -0700
committerMartin Braun <martin.braun@ettus.com>2018-03-29 15:08:37 -0700
commit1e0e079db1f54a515e061adb9967224e7b50e012 (patch)
tree91dbb85c88e2f716fa2330cf9b291bc25fc5aec7
parentdef3b6b2b8e2cb4f63b6d897b7bc2fa9225d5c05 (diff)
downloaduhd-1e0e079db1f54a515e061adb9967224e7b50e012.tar.gz
uhd-1e0e079db1f54a515e061adb9967224e7b50e012.tar.bz2
uhd-1e0e079db1f54a515e061adb9967224e7b50e012.zip
mpmd: Provide list of MPM devices to fail fast on find
With this fix, uhd_find_devices --args type=b200, for example, will not stall in this function. Reviewed-by: Ashish Chaudhari <ashish.chaudhari@ettus.com> Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
-rw-r--r--host/lib/usrp/mpmd/mpmd_devices.hpp23
-rw-r--r--host/lib/usrp/mpmd/mpmd_find.cpp12
2 files changed, 34 insertions, 1 deletions
diff --git a/host/lib/usrp/mpmd/mpmd_devices.hpp b/host/lib/usrp/mpmd/mpmd_devices.hpp
new file mode 100644
index 000000000..7e12fe31a
--- /dev/null
+++ b/host/lib/usrp/mpmd/mpmd_devices.hpp
@@ -0,0 +1,23 @@
+//
+// Copyright 2018 Ettus Research, a National Instruments Company
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+
+#ifndef INCLUDED_MPMD_DEVICES_HPP
+#define INCLUDED_MPMD_DEVICES_HPP
+
+#include <vector>
+#include <string>
+
+static constexpr char MPM_CATCHALL_DEVICE_TYPE[] = "mpm";
+
+// List all MPM devices here by their 'type' key. Note: Do not use these values
+// to make decisions. This vector is for filtering purposes.
+static const std::vector<std::string> MPM_DEVICE_TYPES = {
+ MPM_CATCHALL_DEVICE_TYPE,
+ "n3xx"
+};
+
+#endif /* INCLUDED_MPMD_DEVICES_HPP */
diff --git a/host/lib/usrp/mpmd/mpmd_find.cpp b/host/lib/usrp/mpmd/mpmd_find.cpp
index 8e0bada43..b2471d30c 100644
--- a/host/lib/usrp/mpmd/mpmd_find.cpp
+++ b/host/lib/usrp/mpmd/mpmd_find.cpp
@@ -7,6 +7,7 @@
// find-related code for MPM devices
#include "mpmd_impl.hpp"
+#include "mpmd_devices.hpp"
#include <uhd/types/device_addr.hpp>
#include <uhd/transport/udp_simple.hpp>
#include <uhd/transport/if_addrs.hpp>
@@ -116,7 +117,7 @@ device_addrs_t mpmd_find_with_addr(
if (
(not hint_.has_key("name") or hint_["name"] == new_addr["name"])
and (not hint_.has_key("serial") or hint_["serial"] == new_addr["serial"])
- and (not hint_.has_key("type") or hint_["type"] == new_addr["type"])
+ and (not hint_.has_key("type") or hint_["type"] == new_addr["type"] or hint_["type"] == MPM_CATCHALL_DEVICE_TYPE)
and (not hint_.has_key("product") or hint_["product"] == new_addr["product"])
){
UHD_LOG_TRACE("MPMD FIND",
@@ -201,6 +202,15 @@ device_addrs_t mpmd_find_with_bcast(const device_addr_t& hint)
device_addrs_t mpmd_find(const device_addr_t& hint_)
{
device_addrs_t hints = separate_device_addr(hint_);
+ if (hint_.has_key("type")) {
+ if (std::find(MPM_DEVICE_TYPES.cbegin(),
+ MPM_DEVICE_TYPES.cend(),
+ hint_["type"]) == MPM_DEVICE_TYPES.cend()) {
+ UHD_LOG_TRACE("MPMD FIND",
+ "Returning early, type does not match an MPM device.");
+ return {};
+ }
+ }
UHD_LOG_TRACE("MPMD FIND",
"Finding with " << hints.size() << " different hint(s).");