[MERGED] osmo-trx[master]: uhd: Fix USRP2/N200/N210 device detection

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Tom Tsou gerrit-no-reply at lists.osmocom.org
Fri Jun 16 17:02:45 UTC 2017


Tom Tsou has submitted this change and it was merged.

Change subject: uhd: Fix USRP2/N200/N210 device detection
......................................................................


uhd: Fix USRP2/N200/N210 device detection

Commit 1fb0ce67 "uhd: Use map container for for device parameter access"
inadvertently removed the string identifier for the USRP2 and derived
devices (N200/N210).

Add the missing USRP2 string identifier. Also search for partial string
matches in the UHD provided device and mboard stings. This is necessary
to guarantee that strings such as "N200r3" instead of just "N200" are
sucessfully found.

Tested with N200, X310, B200mini and B210 devices.

Change-Id: Ide4e22418e2cc469418cba018970cb0eb9906697
---
M Transceiver52M/UHDDevice.cpp
1 file changed, 12 insertions(+), 12 deletions(-)

Approvals:
  Tom Tsou: Looks good to me, approved
  Max: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/Transceiver52M/UHDDevice.cpp b/Transceiver52M/UHDDevice.cpp
index 233d465..833f02f 100644
--- a/Transceiver52M/UHDDevice.cpp
+++ b/Transceiver52M/UHDDevice.cpp
@@ -526,25 +526,25 @@
 		{ "E3XX",     { E3XX,    TX_WINDOW_FIXED } },
 		{ "X300",     { X3XX,    TX_WINDOW_FIXED } },
 		{ "X310",     { X3XX,    TX_WINDOW_FIXED } },
+		{ "USRP2",    { USRP2,   TX_WINDOW_FIXED } },
 		{ "UmTRX",    { UMTRX,   TX_WINDOW_FIXED } },
 		{ "STREAM",   { LIMESDR, TX_WINDOW_USRP1 } },
 	};
 
 	// Compare UHD motherboard and device strings */
-	std::string found;
-	if (devStringMap.find(devString) != devStringMap.end())
-		found = devString;
-	else if (devStringMap.find(mboardString) != devStringMap.end())
-		found = mboardString;
-
-	if (found.empty()) {
-		LOG(ALERT) << "Unsupported device " << devString;
-		return false;
+	auto mapIter = devStringMap.begin();
+	while (mapIter != devStringMap.end()) {
+		if (devString.find(mapIter->first) != std::string::npos ||
+		    mboardString.find(mapIter->first) != std::string::npos) {
+			dev_type = std::get<0>(mapIter->second);
+			tx_window = std::get<1>(mapIter->second);
+			return true;
+		}
+		mapIter++;
 	}
 
-	dev_type = devStringMap.at(found).first;
-	tx_window = devStringMap.at(found).second;
-	return true;
+	LOG(ALERT) << "Unsupported device " << devString;
+	return false;
 }
 
 /*

-- 
To view, visit https://gerrit.osmocom.org/2925
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ide4e22418e2cc469418cba018970cb0eb9906697
Gerrit-PatchSet: 3
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Owner: Tom Tsou <tom at tsou.cc>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Tom Tsou <tom at tsou.cc>



More information about the gerrit-log mailing list