aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Foster <nick@ettus.com>2011-10-10 11:51:29 -0700
committerJosh Blum <josh@joshknows.com>2011-10-10 15:49:51 -0700
commit5e01b9eb788e9a4df34405fb24c52a42f9660a0f (patch)
tree9a34b59b46443f5fc1c98f1d46cf7d3d35ea48e6
parentd2a38f7f16dd0eff32069eb376774aac31ef2082 (diff)
downloaduhd-5e01b9eb788e9a4df34405fb24c52a42f9660a0f.tar.gz
uhd-5e01b9eb788e9a4df34405fb24c52a42f9660a0f.tar.bz2
uhd-5e01b9eb788e9a4df34405fb24c52a42f9660a0f.zip
B100/USRP1: pass in VID/PID from args string so you can specify where to look for devices if you like
-rw-r--r--host/lib/usrp/b100/b100_impl.cpp12
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp12
-rw-r--r--host/utils/usrp1_init_eeprom.cpp23
3 files changed, 39 insertions, 8 deletions
diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp
index 6cdd6f280..5e36a19dd 100644
--- a/host/lib/usrp/b100/b100_impl.cpp
+++ b/host/lib/usrp/b100/b100_impl.cpp
@@ -33,6 +33,7 @@
#include <boost/thread/thread.hpp>
#include <boost/lexical_cast.hpp>
#include "b100_regs.hpp"
+#include <cstdio>
using namespace uhd;
using namespace uhd::usrp;
@@ -57,8 +58,15 @@ static device_addrs_t b100_find(const device_addr_t &hint)
//since an address is intended for a different, non-USB, device.
if (hint.has_key("addr")) return b100_addrs;
- boost::uint16_t vid = hint.has_key("uninit") ? FX2_VENDOR_ID : B100_VENDOR_ID;
- boost::uint16_t pid = hint.has_key("uninit") ? FX2_PRODUCT_ID : B100_PRODUCT_ID;
+ unsigned int vid, pid;
+
+ if(hint.has_key("vid") && hint.has_key("pid") && hint.has_key("type") && hint["type"] == "b100") {
+ sscanf(hint.get("vid").c_str(), "%x", &vid);
+ sscanf(hint.get("pid").c_str(), "%x", &pid);
+ } else {
+ vid = B100_VENDOR_ID;
+ pid = B100_PRODUCT_ID;
+ }
// Important note:
// The get device list calls are nested inside the for loop.
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index dbf7a5092..fe4541d38 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -33,6 +33,7 @@
#include <boost/filesystem.hpp>
#include <boost/thread/thread.hpp>
#include <boost/lexical_cast.hpp>
+#include <cstdio>
using namespace uhd;
using namespace uhd::usrp;
@@ -61,8 +62,15 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
//since an address is intended for a different, non-USB, device.
if (hint.has_key("addr")) return usrp1_addrs;
- boost::uint16_t vid = hint.has_key("uninit") ? FX2_VENDOR_ID : USRP1_VENDOR_ID;
- boost::uint16_t pid = hint.has_key("uninit") ? FX2_PRODUCT_ID : USRP1_PRODUCT_ID;
+ unsigned int vid, pid;
+
+ if(hint.has_key("vid") && hint.has_key("pid") && hint.has_key("type") && hint["type"] == "usrp1") {
+ sscanf(hint.get("vid").c_str(), "%x", &vid);
+ sscanf(hint.get("pid").c_str(), "%x", &pid);
+ } else {
+ vid = USRP1_VENDOR_ID;
+ pid = USRP1_PRODUCT_ID;
+ }
// Important note:
// The get device list calls are nested inside the for loop.
diff --git a/host/utils/usrp1_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp
index 95b708c49..c210ae575 100644
--- a/host/utils/usrp1_init_eeprom.cpp
+++ b/host/utils/usrp1_init_eeprom.cpp
@@ -23,6 +23,9 @@
#include <iostream>
#include <cstdlib>
+const std::string FX2_VENDOR_ID("0x04b4");
+const std::string FX2_PRODUCT_ID("0x8613");
+
namespace po = boost::program_options;
int UHD_SAFE_MAIN(int argc, char *argv[]){
@@ -31,8 +34,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
desc.add_options()
("help", "help message")
("image", po::value<std::string>(), "BIN image file")
- ("type", po::value<std::string>(&type)->default_value("usrp1"), "USRP type (usrp1 or b100)")
- ("already-init", "specify to look for an already-initialized USRP")
+ ("vid", po::value<std::string>(), "VID of device to program")
+ ("pid", po::value<std::string>(), "PID of device to program")
+ ("type", po::value<std::string>(), "device type (usrp1 or b100)")
;
po::variables_map vm;
@@ -53,14 +57,25 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//load the options into the address
uhd::device_addr_t device_addr;
device_addr["type"] = type;
- device_addr["uninit"] = vm.count("already-init") ? "" : "yeah"; //tell find to look for an uninitialized FX2
+ if(vm.count("vid") or vm.count("pid") or vm.count("type")) {
+ if(not (vm.count("vid") and vm.count("pid") and vm.count("type"))) {
+ std::cerr << "ERROR: Must specify vid, pid, and type if specifying any of the three args" << std::endl;
+ } else {
+ device_addr["vid"] = vm["vid"].as<std::string>();
+ device_addr["pid"] = vm["pid"].as<std::string>();
+ device_addr["type"] = vm["type"].as<std::string>();
+ }
+ } else {
+ device_addr["vid"] = FX2_VENDOR_ID;
+ device_addr["pid"] = FX2_PRODUCT_ID;
+ }
//find and create a control transport to do the writing.
uhd::device_addrs_t found_addrs = uhd::device::find(device_addr);
if (found_addrs.size() == 0){
- std::cerr << "No uninitialized USRP devices found" << std::endl;
+ std::cerr << "No USRP devices found" << std::endl;
return ~0;
}