summaryrefslogtreecommitdiff
path: root/gr-uhd
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd')
-rw-r--r--gr-uhd/grc/gen_uhd_usrp_blocks.py3
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_sink.cc8
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc39
-rw-r--r--gr-uhd/swig/uhd_swig.i2
4 files changed, 39 insertions, 13 deletions
diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index 831d69fc4..8596e14a6 100644
--- a/gr-uhd/grc/gen_uhd_usrp_blocks.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -65,7 +65,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<callback>set_bandwidth(\$bw$(n), $n)</callback>
#end for
<param>
- <name>Input Type</name>
+ <name>$(direction.title())put Type</name>
<key>type</key>
<type>enum</type>
<option>
@@ -140,6 +140,7 @@ self.\$(id).set_bandwidth(\$bw$(n), $n)
<key>num_mboards</key>
<value>1</value>
<type>int</type>
+ <hide>part</hide>
#for $m in range(1, $max_mboards+1)
<option>
<name>$(m)</name>
diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc
index 4598e54c2..b8b99a41a 100644
--- a/gr-uhd/lib/gr_uhd_usrp_sink.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc
@@ -45,7 +45,8 @@ public:
num_channels, num_channels, io_type.size
)),
_type(io_type),
- _nchan(num_channels)
+ _nchan(num_channels),
+ _has_time_spec(_nchan > 1)
{
_dev = uhd::usrp::multi_usrp::make(device_addr);
}
@@ -172,7 +173,7 @@ public:
//send a mid-burst packet with time spec
_metadata.start_of_burst = false;
_metadata.end_of_burst = false;
- _metadata.has_time_spec = true;
+ _metadata.has_time_spec = _has_time_spec;
size_t num_sent = _dev->get_device()->send(
input_items, noutput_items, _metadata,
@@ -189,7 +190,7 @@ public:
bool start(void){
_metadata.start_of_burst = true;
_metadata.end_of_burst = false;
- _metadata.has_time_spec = true;
+ _metadata.has_time_spec = _has_time_spec;
_metadata.time_spec = get_time_now() + uhd::time_spec_t(0.01);
_dev->get_device()->send(
@@ -217,6 +218,7 @@ protected:
uhd::usrp::multi_usrp::sptr _dev;
const uhd::io_type_t _type;
size_t _nchan;
+ bool _has_time_spec;
uhd::tx_metadata_t _metadata;
double _sample_rate;
};
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 09cced567..1234ed7fe 100644
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -46,7 +46,10 @@ public:
uhd_usrp_source(gr_make_io_signature(
num_channels, num_channels, io_type.size
)),
- _type(io_type)
+ _type(io_type),
+ _nchan(num_channels),
+ _stream_now(_nchan == 1),
+ _tmp_buffs(_nchan)
{
_dev = uhd::usrp::multi_usrp::make(device_addr);
}
@@ -169,16 +172,16 @@ public:
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items
){
- uhd::rx_metadata_t metadata; //not passed out of this block
-
+ //wait for a packet to become available
size_t num_samps = _dev->get_device()->recv(
- output_items, noutput_items, metadata,
- _type, uhd::device::RECV_MODE_FULL_BUFF, 1.0
+ output_items, noutput_items, _metadata,
+ _type, uhd::device::RECV_MODE_ONE_PACKET, 1.0
);
- switch(metadata.error_code){
+ //handle possible errors conditions
+ switch(_metadata.error_code){
case uhd::rx_metadata_t::ERROR_CODE_NONE:
- return num_samps;
+ break;
case uhd::rx_metadata_t::ERROR_CODE_OVERFLOW:
//ignore overflows and try work again
@@ -187,16 +190,30 @@ public:
default:
std::cout << boost::format(
"UHD source block got error code 0x%x"
- ) % metadata.error_code << std::endl;
+ ) % _metadata.error_code << std::endl;
return num_samps;
}
+
+ //advance the pointers and count by num_samps
+ noutput_items -= num_samps;
+ for (size_t i = 0; i < _nchan; i++){
+ _tmp_buffs[i] = static_cast<char *>(output_items[i]) + num_samps*_type.size;
+ }
+
+ //receive all available packets without timeout
+ num_samps += _dev->get_device()->recv(
+ _tmp_buffs, noutput_items, _metadata,
+ _type, uhd::device::RECV_MODE_FULL_BUFF, 0.0
+ );
+
+ return num_samps;
}
bool start(void){
//setup a stream command that starts streaming slightly in the future
static const double reasonable_delay = 0.1; //order of magnitude over RTT
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS);
- stream_cmd.stream_now = false;
+ stream_cmd.stream_now = _stream_now;
stream_cmd.time_spec = get_time_now() + uhd::time_spec_t(reasonable_delay);
_dev->issue_stream_cmd(stream_cmd);
return true;
@@ -210,6 +227,10 @@ public:
private:
uhd::usrp::multi_usrp::sptr _dev;
const uhd::io_type_t _type;
+ size_t _nchan;
+ bool _stream_now;
+ gr_vector_void_star _tmp_buffs;
+ uhd::rx_metadata_t _metadata;
};
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index b814471b2..3ffcc7aea 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -66,6 +66,7 @@
%include <uhd/utils/pimpl.hpp>
+%ignore uhd::dict::operator[]; //ignore warnings about %extend
%include <uhd/types/dict.hpp>
%template(string_string_dict_t) uhd::dict<std::string, std::string>; //define after dict
@@ -88,6 +89,7 @@
%include <uhd/types/metadata.hpp>
+%ignore uhd::device::register_device; //causes compile to choke in MSVC
%include <uhd/device.hpp>
%template(device_addr_vector_t) std::vector<uhd::device_addr_t>;