aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-03-22 15:31:16 +0000
committerJosh Blum <josh@joshknows.com>2010-03-22 15:31:16 +0000
commit09a21dd6d4bc5b7f032e07cfabcba9f55d25b0f6 (patch)
treef94ae1450a01f238339498cbe7449ad7b0264fd0 /host
parenta31761cb0c37b61f7243836d6dd8c40cbf49efc0 (diff)
downloaduhd-09a21dd6d4bc5b7f032e07cfabcba9f55d25b0f6.tar.gz
uhd-09a21dd6d4bc5b7f032e07cfabcba9f55d25b0f6.tar.bz2
uhd-09a21dd6d4bc5b7f032e07cfabcba9f55d25b0f6.zip
bit of io work
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/usrp1e/usrp1e_impl.cpp48
-rw-r--r--host/lib/usrp/usrp1e/usrp1e_impl.hpp3
2 files changed, 35 insertions, 16 deletions
diff --git a/host/lib/usrp/usrp1e/usrp1e_impl.cpp b/host/lib/usrp/usrp1e/usrp1e_impl.cpp
index d3b0264a7..8230cc8e4 100644
--- a/host/lib/usrp/usrp1e/usrp1e_impl.cpp
+++ b/host/lib/usrp/usrp1e/usrp1e_impl.cpp
@@ -71,21 +71,19 @@ device_addrs_t usrp1e::discover(const device_addr_t &device_addr){
* Make
**********************************************************************/
device::sptr usrp1e::make(const device_addr_t &device_addr){
- std::string node = device_addr["node"];
- int node_fd = open(node.c_str(), 0);
- if (node_fd < 0){
- throw std::runtime_error(str(
- boost::format("Failed to open %s") % node
- ));
- }
- return sptr(new usrp1e_impl(node_fd));
+ return sptr(new usrp1e_impl(device_addr["node"]));
}
/***********************************************************************
* Structors
**********************************************************************/
-usrp1e_impl::usrp1e_impl(int node_fd){
- _node_fd = node_fd;
+usrp1e_impl::usrp1e_impl(const std::string &node){
+ //open the device node and check file descriptor
+ if ((_node_fd = ::open(node.c_str(), O_RDWR)) < 0){
+ throw std::runtime_error(str(
+ boost::format("Failed to open %s") % node
+ ));
+ }
//initialize the mboard
mboard_init();
@@ -99,7 +97,8 @@ usrp1e_impl::usrp1e_impl(int node_fd){
}
usrp1e_impl::~usrp1e_impl(void){
- /* NOP */
+ //close the device node file descriptor
+ ::close(_node_fd);
}
/***********************************************************************
@@ -136,11 +135,11 @@ void usrp1e_impl::get(const wax::obj &key_, wax::obj &val){
return;
case DEVICE_PROP_MAX_RX_SAMPLES:
- val = size_t(0); //TODO
+ val = size_t(_max_num_samples);
return;
case DEVICE_PROP_MAX_TX_SAMPLES:
- val = size_t(0); //TODO
+ val = size_t(_max_num_samples);
return;
}
@@ -156,5 +155,24 @@ void usrp1e_impl::set(const wax::obj &, const wax::obj &){
/***********************************************************************
* Device IO (TODO)
**********************************************************************/
-size_t usrp1e_impl::send(const boost::asio::const_buffer &, const uhd::tx_metadata_t &, const std::string &){return 0;}
-size_t usrp1e_impl::recv(const boost::asio::mutable_buffer &, uhd::rx_metadata_t &, const std::string &){return 0;}
+size_t usrp1e_impl::send(
+ const boost::asio::const_buffer &,
+ const uhd::tx_metadata_t &,
+ const std::string &type
+){
+ if (type != "16sc"){
+ throw std::runtime_error(str(boost::format("usrp1e send: cannot handle type \"%s\"") % type));
+ }
+ return 0;
+}
+
+size_t usrp1e_impl::recv(
+ const boost::asio::mutable_buffer &,
+ uhd::rx_metadata_t &,
+ const std::string &type
+){
+ if (type != "16sc"){
+ throw std::runtime_error(str(boost::format("usrp1e recv: cannot handle type \"%s\"") % type));
+ }
+ return 0;
+}
diff --git a/host/lib/usrp/usrp1e/usrp1e_impl.hpp b/host/lib/usrp/usrp1e/usrp1e_impl.hpp
index 7a09254ec..c199a0465 100644
--- a/host/lib/usrp/usrp1e/usrp1e_impl.hpp
+++ b/host/lib/usrp/usrp1e/usrp1e_impl.hpp
@@ -76,7 +76,7 @@ private:
class usrp1e_impl : public uhd::device{
public:
//structors
- usrp1e_impl(int node_fd);
+ usrp1e_impl(const std::string &node);
~usrp1e_impl(void);
//the io interface
@@ -92,6 +92,7 @@ public:
void ioctl(int request, void *mem);
private:
+ static const size_t _max_num_samples = 2048/sizeof(boost::uint32_t);
int _node_fd;
//device functions and settings