summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/grc/uhd_simple_sink.xml6
-rw-r--r--gr-uhd/grc/uhd_simple_source.xml6
-rw-r--r--gr-uhd/lib/uhd_simple_sink.cc14
-rw-r--r--gr-uhd/lib/uhd_simple_sink.h7
-rw-r--r--gr-uhd/lib/uhd_simple_source.cc14
-rw-r--r--gr-uhd/lib/uhd_simple_source.h7
-rw-r--r--gr-uhd/lib/utils.cc13
-rw-r--r--gr-uhd/lib/utils.h5
-rw-r--r--gr-uhd/swig/Makefile.am5
-rw-r--r--gr-uhd/swig/uhd_swig.i2
10 files changed, 30 insertions, 49 deletions
diff --git a/gr-uhd/grc/uhd_simple_sink.xml b/gr-uhd/grc/uhd_simple_sink.xml
index cad6194ee..fa9e19be7 100644
--- a/gr-uhd/grc/uhd_simple_sink.xml
+++ b/gr-uhd/grc/uhd_simple_sink.xml
@@ -9,7 +9,7 @@
<key>uhd_simple_sink</key>
<category>UHD</category>
<import>from gnuradio import uhd</import>
- <make>uhd.simple_sink($args, "$type.type")
+ <make>uhd.simple_sink($args, uhd.io_type_t.$type.type)
self.$(id).set_samp_rate($samp_rate)
self.$(id).set_center_freq($center_freq)</make>
<callback>set_samp_rate($samp_rate)</callback>
@@ -21,13 +21,13 @@ self.$(id).set_center_freq($center_freq)</make>
<option>
<name>Complex</name>
<key>complex</key>
- <opt>type:32fc</opt>
+ <opt>type:COMPLEX_FLOAT32</opt>
<opt>vlen:1</opt>
</option>
<option>
<name>Short</name>
<key>short</key>
- <opt>type:16sc</opt>
+ <opt>type:COMPLEX_INT16</opt>
<opt>vlen:2</opt>
</option>
</param>
diff --git a/gr-uhd/grc/uhd_simple_source.xml b/gr-uhd/grc/uhd_simple_source.xml
index 519b7ad6c..7deffeeec 100644
--- a/gr-uhd/grc/uhd_simple_source.xml
+++ b/gr-uhd/grc/uhd_simple_source.xml
@@ -9,7 +9,7 @@
<key>uhd_simple_source</key>
<category>UHD</category>
<import>from gnuradio import uhd</import>
- <make>uhd.simple_source($args, "$type.type")
+ <make>uhd.simple_source($args, uhd.io_type_t.$type.type)
self.$(id).set_samp_rate($samp_rate)
self.$(id).set_center_freq($center_freq)</make>
<callback>set_samp_rate($samp_rate)</callback>
@@ -21,13 +21,13 @@ self.$(id).set_center_freq($center_freq)</make>
<option>
<name>Complex</name>
<key>complex</key>
- <opt>type:32fc</opt>
+ <opt>type:COMPLEX_FLOAT32</opt>
<opt>vlen:1</opt>
</option>
<option>
<name>Short</name>
<key>short</key>
- <opt>type:16sc</opt>
+ <opt>type:COMPLEX_INT16</opt>
<opt>vlen:2</opt>
</option>
</param>
diff --git a/gr-uhd/lib/uhd_simple_sink.cc b/gr-uhd/lib/uhd_simple_sink.cc
index 499ae4d6e..a22b52421 100644
--- a/gr-uhd/lib/uhd_simple_sink.cc
+++ b/gr-uhd/lib/uhd_simple_sink.cc
@@ -31,7 +31,7 @@
**********************************************************************/
boost::shared_ptr<uhd_simple_sink> uhd_make_simple_sink(
const std::string &args,
- const std::string &type
+ const uhd::io_type_t::tid_t &type
){
return boost::shared_ptr<uhd_simple_sink>(
new uhd_simple_sink(args, type)
@@ -43,15 +43,13 @@ boost::shared_ptr<uhd_simple_sink> uhd_make_simple_sink(
**********************************************************************/
uhd_simple_sink::uhd_simple_sink(
const std::string &args,
- const std::string &type
+ const uhd::io_type_t &type
) : gr_sync_block(
"uhd sink",
- gr_make_io_signature(1, 1, get_size(type)),
+ gr_make_io_signature(1, 1, type.size),
gr_make_io_signature(0, 0, 0)
-){
- _type = type;
+), _type(type){
_dev = uhd::simple_device::make(args);
- _sizeof_samp = get_size(type);
}
uhd_simple_sink::~uhd_simple_sink(void){
@@ -86,8 +84,8 @@ int uhd_simple_sink::work(
while(total_items_sent < size_t(noutput_items)){
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
+ (uint8_t *)input_items[0]+(total_items_sent*_type.size),
+ (noutput_items-total_items_sent)*_type.size
), metadata, _type
);
total_items_sent += items_sent;
diff --git a/gr-uhd/lib/uhd_simple_sink.h b/gr-uhd/lib/uhd_simple_sink.h
index e57ba4abb..aa8d1144c 100644
--- a/gr-uhd/lib/uhd_simple_sink.h
+++ b/gr-uhd/lib/uhd_simple_sink.h
@@ -29,11 +29,11 @@
class uhd_simple_sink;
boost::shared_ptr<uhd_simple_sink>
-uhd_make_simple_sink(const std::string &args, const std::string &type);
+uhd_make_simple_sink(const std::string &args, const uhd::io_type_t::tid_t &type);
class uhd_simple_sink : public gr_sync_block{
public:
- uhd_simple_sink(const std::string &args, const std::string &type);
+ uhd_simple_sink(const std::string &args, const uhd::io_type_t &type);
~uhd_simple_sink(void);
void set_samp_rate(double rate);
@@ -49,8 +49,7 @@ public:
protected:
uhd::simple_device::sptr _dev;
- std::string _type;
- size_t _sizeof_samp;
+ const uhd::io_type_t _type;
};
#endif /* INCLUDED_UHD_SIMPLE_SINK_H */
diff --git a/gr-uhd/lib/uhd_simple_source.cc b/gr-uhd/lib/uhd_simple_source.cc
index 725cb2807..677099f11 100644
--- a/gr-uhd/lib/uhd_simple_source.cc
+++ b/gr-uhd/lib/uhd_simple_source.cc
@@ -30,7 +30,7 @@
**********************************************************************/
boost::shared_ptr<uhd_simple_source> uhd_make_simple_source(
const std::string &args,
- const std::string &type
+ const uhd::io_type_t::tid_t &type
){
return boost::shared_ptr<uhd_simple_source>(
new uhd_simple_source(args, type)
@@ -42,15 +42,13 @@ boost::shared_ptr<uhd_simple_source> uhd_make_simple_source(
**********************************************************************/
uhd_simple_source::uhd_simple_source(
const std::string &args,
- const std::string &type
+ const uhd::io_type_t &type
) : gr_sync_block(
"uhd source",
gr_make_io_signature(0, 0, 0),
- gr_make_io_signature(1, 1, get_size(type))
-){
- _type = type;
+ gr_make_io_signature(1, 1, type.size)
+), _type(type){
_dev = uhd::simple_device::make(args);
- _sizeof_samp = get_size(type);
set_streaming(false);
}
@@ -99,8 +97,8 @@ int uhd_simple_source::work(
while(total_items_read < size_t(noutput_items)){
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
+ (uint8_t *)output_items[0]+(total_items_read*_type.size),
+ (noutput_items-total_items_read)*_type.size
), metadata, _type
);
total_items_read += items_read;
diff --git a/gr-uhd/lib/uhd_simple_source.h b/gr-uhd/lib/uhd_simple_source.h
index 27fa2c382..50b1c9518 100644
--- a/gr-uhd/lib/uhd_simple_source.h
+++ b/gr-uhd/lib/uhd_simple_source.h
@@ -29,11 +29,11 @@
class uhd_simple_source;
boost::shared_ptr<uhd_simple_source>
-uhd_make_simple_source(const std::string &args, const std::string &type);
+uhd_make_simple_source(const std::string &args, const uhd::io_type_t::tid_t &type);
class uhd_simple_source : public gr_sync_block{
public:
- uhd_simple_source(const std::string &args, const std::string &type);
+ uhd_simple_source(const std::string &args, const uhd::io_type_t &type);
~uhd_simple_source(void);
void set_samp_rate(double rate);
@@ -49,8 +49,7 @@ public:
protected:
uhd::simple_device::sptr _dev;
- std::string _type;
- size_t _sizeof_samp;
+ const uhd::io_type_t _type;
bool _is_streaming;
void set_streaming(bool enb);
};
diff --git a/gr-uhd/lib/utils.cc b/gr-uhd/lib/utils.cc
index 0351d6370..e81241303 100644
--- a/gr-uhd/lib/utils.cc
+++ b/gr-uhd/lib/utils.cc
@@ -21,16 +21,3 @@
*/
#include "utils.h" //local include
-#include <stdint.h>
-#include <complex>
-#include <stdexcept>
-
-size_t get_size(const std::string &type){
- if(type == "32fc"){
- return sizeof(std::complex<float>);
- }
- if(type == "16sc"){
- return sizeof(std::complex<int16_t>);
- }
- throw std::runtime_error("unknown type");
-}
diff --git a/gr-uhd/lib/utils.h b/gr-uhd/lib/utils.h
index eb3a133bc..9e3acf571 100644
--- a/gr-uhd/lib/utils.h
+++ b/gr-uhd/lib/utils.h
@@ -23,9 +23,4 @@
#ifndef INCLUDED_NOINST_UTILS_H
#define INCLUDED_NOINST_UTILS_H
-#include <cstddef>
-#include <string>
-
-size_t get_size(const std::string &type);
-
#endif /* INCLUDED_NOINST_UTILS_H */
diff --git a/gr-uhd/swig/Makefile.am b/gr-uhd/swig/Makefile.am
index 3b1fd20f8..183e6b587 100644
--- a/gr-uhd/swig/Makefile.am
+++ b/gr-uhd/swig/Makefile.am
@@ -25,6 +25,7 @@ AM_CPPFLAGS = \
$(STD_DEFINES_AND_INCLUDES) \
$(PYTHON_CPPFLAGS) \
$(WITH_INCLUDES) \
+ $(UHD_CFLAGS) \
-I$(top_srcdir)/gr-uhd/lib
if PYTHON
@@ -56,7 +57,9 @@ uhd_swig_swiginclude_headers =
include $(top_srcdir)/Makefile.swig
# FIXME better way to set this?
-STD_SWIG_PYTHON_ARGS += -I$(top_srcdir)/gr-uhd/lib
+STD_SWIG_PYTHON_ARGS += \
+ $(UHD_CFLAGS) \
+ -I$(top_srcdir)/gr-uhd/lib
# add some of the variables generated inside the Makefile.swig.gen
BUILT_SOURCES = $(swig_built_sources)
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index 363d9c914..2642f9450 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -27,8 +27,10 @@
#include <uhd_simple_sink.h>
%}
+%include <uhd/config.hpp>
%include <uhd/types/ranges.hpp>
%include <uhd/types/tune_result.hpp>
+%include <uhd/types/io_type.hpp>
GR_SWIG_BLOCK_MAGIC(uhd,simple_source)
%include <uhd_simple_source.h>