summaryrefslogtreecommitdiff
path: root/gr-uhd/lib
diff options
context:
space:
mode:
authorJosh Blum2010-03-10 14:48:50 -0800
committerJosh Blum2010-03-10 14:48:50 -0800
commit19d3c0cab37123f8bfd19fdfc576f44b6069300f (patch)
tree1413206ca21b1d354fe09de1562663d2fb7d30da /gr-uhd/lib
parent6c79d5158ace300038937688bb11309736926214 (diff)
downloadgnuradio-19d3c0cab37123f8bfd19fdfc576f44b6069300f.tar.gz
gnuradio-19d3c0cab37123f8bfd19fdfc576f44b6069300f.tar.bz2
gnuradio-19d3c0cab37123f8bfd19fdfc576f44b6069300f.zip
Added samp rate param and using the simple device from uhd
Diffstat (limited to 'gr-uhd/lib')
-rw-r--r--gr-uhd/lib/uhd_simple_sink.cc16
-rw-r--r--gr-uhd/lib/uhd_simple_sink.h10
-rw-r--r--gr-uhd/lib/uhd_simple_source.cc33
-rw-r--r--gr-uhd/lib/uhd_simple_source.h13
-rw-r--r--gr-uhd/lib/utils.cc28
-rw-r--r--gr-uhd/lib/utils.h5
6 files changed, 46 insertions, 59 deletions
diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc
index 01581bb76..c1edf29bb 100644
--- a/gr-uhd/lib/uhd_simple_sink.cc
+++ b/gr-uhd/lib/uhd_simple_sink.cc
@@ -34,7 +34,7 @@ boost::shared_ptr<uhd_simple_sink> uhd_make_simple_sink(
const std::string &type
){
return boost::shared_ptr<uhd_simple_sink>(
- new uhd_simple_sink(args_to_device_addr(args), type)
+ new uhd_simple_sink(args, type)
);
}
@@ -42,7 +42,7 @@ boost::shared_ptr<uhd_simple_sink> uhd_make_simple_sink(
* UHD Sink
**********************************************************************/
uhd_simple_sink::uhd_simple_sink(
- const uhd::device_addr_t &addr,
+ const std::string &args,
const std::string &type
) : gr_sync_block(
"uhd sink",
@@ -50,7 +50,7 @@ uhd_simple_sink::uhd_simple_sink(
gr_make_io_signature(0, 0, 0)
){
_type = type;
- _dev = uhd::device::make(addr);
+ _dev = uhd::simple_device::make(args);
_sizeof_samp = get_size(type);
}
@@ -58,6 +58,14 @@ uhd_simple_sink::~uhd_simple_sink(void){
//NOP
}
+void uhd_simple_sink::set_samp_rate(double rate){
+ return _dev->set_tx_rate(rate);
+}
+
+double uhd_simple_sink::get_samp_rate(void){
+ return _dev->get_tx_rate();
+}
+
/***********************************************************************
* Work
**********************************************************************/
@@ -72,7 +80,7 @@ int uhd_simple_sink::work(
//call until the input items are all sent
while(total_items_sent < size_t(noutput_items)){
- size_t items_sent = _dev->send(
+ size_t items_sent = _dev->get_device()->send(
boost::asio::buffer(
(uint8_t *)input_items[0]+(total_items_sent*_sizeof_samp),
(noutput_items-total_items_sent)*_sizeof_samp
diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h
index 76b4a26cf..301cdd24f 100644
--- a/gr-uhd/lib/uhd_simple_sink.h
+++ b/gr-uhd/lib/uhd_simple_sink.h
@@ -24,7 +24,7 @@
#define INCLUDED_UHD_SIMPLE_SINK_H
#include <gr_sync_block.h>
-#include <uhd/device.hpp>
+#include <uhd/simple_device.hpp>
class uhd_simple_sink;
@@ -33,9 +33,12 @@ uhd_make_simple_sink(const std::string &args, const std::string &type);
class uhd_simple_sink : public gr_sync_block{
public:
- uhd_simple_sink(const uhd::device_addr_t &addr, const std::string &type);
+ uhd_simple_sink(const std::string &args, const std::string &type);
~uhd_simple_sink(void);
+ void set_samp_rate(double rate);
+ double get_samp_rate(void);
+
int work(
int noutput_items,
gr_vector_const_void_star &input_items,
@@ -43,8 +46,7 @@ public:
);
protected:
-
- uhd::device::sptr _dev;
+ uhd::simple_device::sptr _dev;
std::string _type;
size_t _sizeof_samp;
};
diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc
index a8977abc3..827cad458 100644
--- a/gr-uhd/lib/uhd_simple_source.cc
+++ b/gr-uhd/lib/uhd_simple_source.cc
@@ -33,7 +33,7 @@ boost::shared_ptr<uhd_simple_source> uhd_make_simple_source(
const std::string &type
){
return boost::shared_ptr<uhd_simple_source>(
- new uhd_simple_source(args_to_device_addr(args), type)
+ new uhd_simple_source(args, type)
);
}
@@ -41,7 +41,7 @@ boost::shared_ptr<uhd_simple_source> uhd_make_simple_source(
* UHD Source
**********************************************************************/
uhd_simple_source::uhd_simple_source(
- const uhd::device_addr_t &addr,
+ const std::string &args,
const std::string &type
) : gr_sync_block(
"uhd source",
@@ -49,25 +49,23 @@ uhd_simple_source::uhd_simple_source(
gr_make_io_signature(1, 1, get_size(type))
){
_type = type;
- _dev = uhd::device::make(addr);
+ _dev = uhd::simple_device::make(args);
_sizeof_samp = get_size(type);
- set_streaming(false);
+ _dev->set_streaming(false);
+ _is_streaming = false;
}
uhd_simple_source::~uhd_simple_source(void){
- set_streaming(false);
+ _dev->set_streaming(false);
}
-/***********************************************************************
- * DDC Control
- **********************************************************************/
-void uhd_simple_source::set_streaming(bool enb){
- wax::obj ddc = (*_dev)
- [uhd::DEVICE_PROP_MBOARD]
- [uhd::named_prop_t(uhd::MBOARD_PROP_RX_DSP, "ddc0")];
- ddc[std::string("enabled")] = enb;
- _is_streaming = enb;
+void uhd_simple_source::set_samp_rate(double rate){
+ return _dev->set_rx_rate(rate);
+}
+
+double uhd_simple_source::get_samp_rate(void){
+ return _dev->get_rx_rate();
}
/***********************************************************************
@@ -80,7 +78,10 @@ int uhd_simple_source::work(
){
//conditionally start streaming in the work call
//this prevents streaming before the runtime is ready
- if (not _is_streaming) set_streaming(true);
+ if (not _is_streaming){
+ _dev->set_streaming(true);
+ _is_streaming = true;
+ }
size_t total_items_read = 0;
uhd::rx_metadata_t metadata;
@@ -88,7 +89,7 @@ int uhd_simple_source::work(
//call until the output items are all filled
//or an exit condition below is encountered
while(total_items_read < size_t(noutput_items)){
- size_t items_read = _dev->recv(
+ size_t items_read = _dev->get_device()->recv(
boost::asio::buffer(
(uint8_t *)output_items[0]+(total_items_read*_sizeof_samp),
(noutput_items-total_items_read)*_sizeof_samp
diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h
index 5d2dafe49..0ddf9d563 100644
--- a/gr-uhd/lib/uhd_simple_source.h
+++ b/gr-uhd/lib/uhd_simple_source.h
@@ -24,7 +24,7 @@
#define INCLUDED_UHD_SIMPLE_SOURCE_H
#include <gr_sync_block.h>
-#include <uhd/device.hpp>
+#include <uhd/simple_device.hpp>
class uhd_simple_source;
@@ -33,9 +33,12 @@ uhd_make_simple_source(const std::string &args, const std::string &type);
class uhd_simple_source : public gr_sync_block{
public:
- uhd_simple_source(const uhd::device_addr_t &addr, const std::string &type);
+ uhd_simple_source(const std::string &args, const std::string &type);
~uhd_simple_source(void);
+ void set_samp_rate(double rate);
+ double get_samp_rate(void);
+
int work(
int noutput_items,
gr_vector_const_void_star &input_items,
@@ -43,12 +46,10 @@ public:
);
protected:
- void set_streaming(bool enb);
- bool _is_streaming; //shadow for the streaming status
-
- uhd::device::sptr _dev;
+ uhd::simple_device::sptr _dev;
std::string _type;
size_t _sizeof_samp;
+ bool _is_streaming;
};
#endif /* INCLUDED_UHD_SIMPLE_SOURCE_H */
diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc
index e36320c3c..0351d6370 100644
--- a/gr-uhd/lib/utils.cc
+++ b/gr-uhd/lib/utils.cc
@@ -21,33 +21,9 @@
*/
#include "utils.h" //local include
-#include <boost/algorithm/string.hpp>
-#include <boost/algorithm/string/trim.hpp>
-#include <boost/foreach.hpp>
+#include <stdint.h>
#include <complex>
-
-static std::string trim(const std::string &in){
- return boost::algorithm::trim_copy(in);
-}
-
-uhd::device_addr_t args_to_device_addr(const std::string &args){
- uhd::device_addr_t addr;
-
- //split the args at the semi-colons
- std::vector<std::string> pairs;
- boost::split(pairs, args, boost::is_any_of(";"));
- BOOST_FOREACH(std::string pair, pairs){
- if (trim(pair) == "") continue;
-
- //split the key value pairs at the equals
- std::vector<std::string> key_val;
- boost::split(key_val, pair, boost::is_any_of("="));
- if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args);
- addr[trim(key_val[0])] = trim(key_val[1]);
- }
-
- return addr;
-}
+#include <stdexcept>
size_t get_size(const std::string &type){
if(type == "32fc"){
diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h
index 9a6dd604a..eb3a133bc 100644
--- a/gr-uhd/lib/utils.h
+++ b/gr-uhd/lib/utils.h
@@ -23,9 +23,8 @@
#ifndef INCLUDED_NOINST_UTILS_H
#define INCLUDED_NOINST_UTILS_H
-#include <uhd/device_addr.hpp>
-
-uhd::device_addr_t args_to_device_addr(const std::string &args);
+#include <cstddef>
+#include <string>
size_t get_size(const std::string &type);