summaryrefslogtreecommitdiff
path: root/gr-uhd/lib/gr_uhd_usrp_source.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-uhd/lib/gr_uhd_usrp_source.cc')
-rw-r--r--gr-uhd/lib/gr_uhd_usrp_source.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc
index 669f890ea..2987d528c 100644
--- a/gr-uhd/lib/gr_uhd_usrp_source.cc
+++ b/gr-uhd/lib/gr_uhd_usrp_source.cc
@@ -33,7 +33,8 @@ public:
uhd_usrp_source_impl(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
- size_t num_channels
+ size_t num_channels,
+ gr_msg_queue_sptr async_queue
):
gr_sync_block(
"gr uhd usrp source",
@@ -43,7 +44,8 @@ public:
_type(io_type),
_nchan(num_channels),
_stream_now(_nchan == 1),
- _tmp_buffs(_nchan)
+ _tmp_buffs(_nchan),
+ _async_queue(async_queue)
{
_dev = uhd::usrp::multi_usrp::make(device_addr);
}
@@ -222,6 +224,15 @@ public:
return num_samps;
}
+ // Scan queue and post async events
+ while (_dev->get_device()->recv_async_msg(_asyncdata, 0.0)) {
+ if (_async_queue) {
+ gr_message_sptr m = gr_make_message(0, 0.0, 0.0, sizeof(_asyncdata));
+ memcpy(m->msg(), &_asyncdata, sizeof(_asyncdata));
+ _async_queue->insert_tail(m);
+ }
+ }
+
return num_samps;
}
@@ -247,6 +258,8 @@ private:
bool _stream_now;
gr_vector_void_star _tmp_buffs;
uhd::rx_metadata_t _metadata;
+ uhd::async_metadata_t _asyncdata;
+ gr_msg_queue_sptr _async_queue;
};
@@ -256,9 +269,10 @@ private:
boost::shared_ptr<uhd_usrp_source> uhd_make_usrp_source(
const uhd::device_addr_t &device_addr,
const uhd::io_type_t &io_type,
- size_t num_channels
+ size_t num_channels,
+ gr_msg_queue_sptr async_queue
){
return boost::shared_ptr<uhd_usrp_source>(
- new uhd_usrp_source_impl(device_addr, io_type, num_channels)
+ new uhd_usrp_source_impl(device_addr, io_type, num_channels, async_queue)
);
}