aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/device.cpp
diff options
context:
space:
mode:
authorNicholas Corgan <nick.corgan@ettus.com>2014-07-17 11:50:50 -0700
committerNicholas Corgan <nick.corgan@ettus.com>2014-07-23 07:37:32 -0700
commita6e18604befdb6a954542f7722c8d55424065621 (patch)
tree22168e6f4c41c931e38ccd07ff8881b56c8cd88a /host/lib/device.cpp
parent7423d1691fff3af08f8e42e3e09d8c8d9ec99fe8 (diff)
downloaduhd-a6e18604befdb6a954542f7722c8d55424065621.tar.gz
uhd-a6e18604befdb6a954542f7722c8d55424065621.tar.bz2
uhd-a6e18604befdb6a954542f7722c8d55424065621.zip
OctoClock firmware upgrade, added host driver
* OctoClock can communicate with UHD over Ethernet * Can read NMEA strings from GPSDO and send to host * Added multi_usrp_clock class for clock devices * uhd::device can now filter to return only USRP devices or clock devices * New OctoClock bootloader can accept firmware download over Ethernet * Added octoclock_burn_eeprom,octoclock_firmware_burner utilities * Added test_clock_synch example to show clock API
Diffstat (limited to 'host/lib/device.cpp')
-rw-r--r--host/lib/device.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/host/lib/device.cpp b/host/lib/device.cpp
index ff5163f2d..bd7bf5637 100644
--- a/host/lib/device.cpp
+++ b/host/lib/device.cpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010-2011 Ettus Research LLC
+// Copyright 2010-2011,2014 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -57,35 +57,38 @@ static size_t hash_device_addr(
/***********************************************************************
* Registration
**********************************************************************/
-typedef boost::tuple<device::find_t, device::make_t> dev_fcn_reg_t;
+typedef boost::tuple<device::find_t, device::make_t, device::device_filter_t> dev_fcn_reg_t;
// instantiate the device function registry container
UHD_SINGLETON_FCN(std::vector<dev_fcn_reg_t>, get_dev_fcn_regs)
void device::register_device(
const find_t &find,
- const make_t &make
+ const make_t &make,
+ const device_filter_t filter
){
UHD_LOGV(always) << "registering device" << std::endl;
- get_dev_fcn_regs().push_back(dev_fcn_reg_t(find, make));
+ get_dev_fcn_regs().push_back(dev_fcn_reg_t(find, make, filter));
}
/***********************************************************************
* Discover
**********************************************************************/
-device_addrs_t device::find(const device_addr_t &hint){
+device_addrs_t device::find(const device_addr_t &hint, device_filter_t filter){
boost::mutex::scoped_lock lock(_device_mutex);
device_addrs_t device_addrs;
BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){
try{
- device_addrs_t discovered_addrs = fcn.get<0>()(hint);
- device_addrs.insert(
- device_addrs.begin(),
- discovered_addrs.begin(),
- discovered_addrs.end()
- );
+ if(filter == ANY or fcn.get<2>() == filter){
+ device_addrs_t discovered_addrs = fcn.get<0>()(hint);
+ device_addrs.insert(
+ device_addrs.begin(),
+ discovered_addrs.begin(),
+ discovered_addrs.end()
+ );
+ }
}
catch(const std::exception &e){
UHD_MSG(error) << "Device discovery error: " << e.what() << std::endl;
@@ -98,16 +101,18 @@ device_addrs_t device::find(const device_addr_t &hint){
/***********************************************************************
* Make
**********************************************************************/
-device::sptr device::make(const device_addr_t &hint, size_t which){
+device::sptr device::make(const device_addr_t &hint, device_filter_t filter, size_t which){
boost::mutex::scoped_lock lock(_device_mutex);
typedef boost::tuple<device_addr_t, make_t> dev_addr_make_t;
std::vector<dev_addr_make_t> dev_addr_makers;
BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){
- BOOST_FOREACH(device_addr_t dev_addr, fcn.get<0>()(hint)){
- //append the discovered address and its factory function
- dev_addr_makers.push_back(dev_addr_make_t(dev_addr, fcn.get<1>()));
+ if(filter == ANY or fcn.get<2>() == filter){
+ BOOST_FOREACH(device_addr_t dev_addr, fcn.get<0>()(hint)){
+ //append the discovered address and its factory function
+ dev_addr_makers.push_back(dev_addr_make_t(dev_addr, fcn.get<1>()));
+ }
}
}
@@ -159,3 +164,7 @@ device::get_tree(void) const
{
return _tree;
}
+
+device::device_filter_t device::get_device_type() const {
+ return _type;
+}