diff options
Diffstat (limited to 'gr-uhd/lib')
-rw-r--r-- | gr-uhd/lib/uhd_simple_sink.cc | 14 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_sink.h | 7 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.cc | 14 | ||||
-rw-r--r-- | gr-uhd/lib/uhd_simple_source.h | 7 | ||||
-rw-r--r-- | gr-uhd/lib/utils.cc | 13 | ||||
-rw-r--r-- | gr-uhd/lib/utils.h | 5 |
6 files changed, 18 insertions, 42 deletions
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 */ |