From 5b42b774d9ac1e74fb2916bf58085fe19ecb6720 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 16 Jan 2010 16:29:31 -0800 Subject: Created device interface for discovery, access, configuration... --- lib/Makefile.am | 1 + lib/device.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ lib/usrp_uhd.cpp | 3 +-- 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 lib/device.cpp (limited to 'lib') diff --git a/lib/Makefile.am b/lib/Makefile.am index 6146f4025..a4b053b0a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -11,6 +11,7 @@ AM_CPPFLAGS = $(GENERAL_CPPFLAGS) lib_LTLIBRARIES = libusrp_uhd.la libusrp_uhd_la_SOURCES = \ + device.cpp \ device_addr.cpp \ usrp_uhd.cpp \ wax.cpp diff --git a/lib/device.cpp b/lib/device.cpp new file mode 100644 index 000000000..fe655ec7a --- /dev/null +++ b/lib/device.cpp @@ -0,0 +1,43 @@ +// +// Copyright 2010 Ettus Research LLC +// + +#include +#include + +using namespace usrp_uhd; + +std::vector device::discover(const device_addr_t& hint){ + std::vector device_addrs; + if (hint.type == DEVICE_ADDR_TYPE_VIRTUAL){ + //TODO device_addrs.push_back(...); + } + return device_addrs; +} + +device::sptr device::make(const device_addr_t& hint, size_t which){ + std::vector device_addrs = discover(hint); + //check that we found any devices + if (device_addrs.size() == 0){ + throw std::runtime_error(str( + boost::format("No devices found for %s") % hint.to_string() + )); + } + //check that the which index is valid + if (device_addrs.size() <= which){ + throw std::runtime_error(str( + boost::format("No device at index %d for %s") + % which % hint.to_string() + )); + } + //create the new device with the discovered address + return sptr(new device(device_addrs.at(which))); +} + +device::device(const device_addr_t&){ + /* NOP */ +} + +device::~device(void){ + /* NOP */ +} diff --git a/lib/usrp_uhd.cpp b/lib/usrp_uhd.cpp index 7d1e62a13..7591d3bea 100644 --- a/lib/usrp_uhd.cpp +++ b/lib/usrp_uhd.cpp @@ -4,5 +4,4 @@ #include -usrp_uhd::usrp_uhd::usrp_uhd(device_addr_t){} -usrp_uhd::usrp_uhd::~usrp_uhd(void){} +//nothing here, just includes the header so the compiler can check -- cgit v1.2.3