[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 03/11: uhd: changed length_tag member varia
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 03/11: uhd: changed length_tag member variable from string to pmt symbol |
Date: |
Sat, 26 Apr 2014 22:34:11 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 3e3d20358e88aeba41baf03cae0785936e96bce8
Author: Sean Nowlan <address@hidden>
Date: Mon Mar 10 14:48:15 2014 -0400
uhd: changed length_tag member variable from string to pmt symbol
---
gr-uhd/examples/c++/tag_source_demo.h | 20 ++++++++++----------
gr-uhd/include/gnuradio/uhd/usrp_sink.h | 16 ++++++++--------
gr-uhd/lib/usrp_sink_impl.cc | 27 ++++++++++++++-------------
gr-uhd/lib/usrp_sink_impl.h | 4 ++--
4 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/gr-uhd/examples/c++/tag_source_demo.h
b/gr-uhd/examples/c++/tag_source_demo.h
index 904087c..8508c32 100644
--- a/gr-uhd/examples/c++/tag_source_demo.h
+++ b/gr-uhd/examples/c++/tag_source_demo.h
@@ -36,7 +36,7 @@ public:
const double samp_rate,
const double idle_duration,
const double burst_duration,
- const std::string &length_tag_key = ""
+ const std::string &length_tag_name = ""
):
sync_block(
"uhd tag source demo",
@@ -50,8 +50,8 @@ public:
_cycle_duration(idle_duration + burst_duration),
_samps_left_in_burst(1), //immediate EOB
_do_new_burst(false),
- _firstrun(not length_tag_key.empty()),
- _length_tag_key(length_tag_key)
+ _firstrun(not length_tag_name.empty()),
+ _length_tag_key(length_tag_name.empty() ? pmt::PMT_NIL :
pmt::string_to_symbol(length_tag_name))
{
//NOP
}
@@ -85,12 +85,12 @@ public:
void make_length_tag(const uint64_t tag_count, const uint64_t burst_len)
{
- if (_length_tag_key.empty()){
+ if (pmt::is_null(_length_tag_key)) {
//no length_tag was specified at initialization; make a tx_sob tag
instead
this->make_sob_tag(tag_count);
return;
}
- const pmt::pmt_t key = pmt::string_to_symbol(_length_tag_key);
+ const pmt::pmt_t key = _length_tag_key;
const pmt::pmt_t value = pmt::from_long((long)burst_len);
const pmt::pmt_t srcid = pmt::string_to_symbol(this->name());
this->add_item_tag(0/*chan0*/, tag_count, key, value, srcid);
@@ -103,18 +103,18 @@ public:
{
//load the output with a constant
std::complex<float> *output = reinterpret_cast<std::complex<float>
*>(output_items[0]);
- for (size_t i = 0; i < size_t(noutput_items); i++){
+ for (size_t i = 0; i < size_t(noutput_items); i++) {
output[i] = std::complex<float>(0.7, 0.7);
}
//Handle the start of burst condition.
//Tag a start of burst and timestamp.
//Increment the time for the next burst.
- if (_do_new_burst){
+ if (_do_new_burst) {
_do_new_burst = false;
_samps_left_in_burst = _samps_per_burst;
- if (_length_tag_key.empty())
+ if (pmt::is_null(_length_tag_key))
this->make_sob_tag(this->nitems_written(0));
else
#if 1
@@ -138,7 +138,7 @@ public:
//Tag an end of burst and return early.
//the next work call will be a start of burst.
if (_samps_left_in_burst < size_t(noutput_items)){
- if (_length_tag_key.empty())
+ if (pmt::is_null(_length_tag_key))
this->make_eob_tag(this->nitems_written(0) +
_samps_left_in_burst - 1);
else if (_firstrun){
_firstrun = false;
@@ -161,6 +161,6 @@ private:
uint64_t _samps_left_in_burst;
bool _do_new_burst;
bool _firstrun;
- const std::string _length_tag_key;
+ const pmt::pmt_t _length_tag_key;
};
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_sink.h
b/gr-uhd/include/gnuradio/uhd/usrp_sink.h
index 08bad49..c57524e 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_sink.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_sink.h
@@ -72,12 +72,12 @@ namespace gr {
* - pmt::string_to_symbol("tx_sob")
* - pmt::string_to_symbol("tx_eob")
* - pmt::string_to_symbol("tx_time")
- * - pmt::string_to_symbol(length_tag_key)
+ * - pmt::string_to_symbol(length_tag_name)
*
* The sob and eob (start and end of burst) tag values are pmt booleans.
* When present, burst tags should be set to true (pmt::PMT_T).
*
- * If length_tag_key is not an empty string, all "tx_sob" and "tx_eob"
+ * If length_tag_name is not an empty string, all "tx_sob" and "tx_eob"
* tags will be ignored.
*
* The length tag value should be a pmt long specifying the number
@@ -92,13 +92,13 @@ namespace gr {
* \param device_addr the address to identify the hardware
* \param io_type the desired input data type
* \param num_channels number of stream from the device
- * \param length_tag_key the key of the tag identifying tagged stream
length
+ * \param length_tag_name the name of the tag identifying tagged stream
length
* \return a new USRP sink block object
*/
static sptr make(const ::uhd::device_addr_t &device_addr,
const ::uhd::io_type_t &io_type,
size_t num_channels,
- const std::string &length_tag_key = "");
+ const std::string &length_tag_name = "");
/*!
* \brief Make a new USRP sink block.
@@ -112,12 +112,12 @@ namespace gr {
* - pmt::string_to_symbol("tx_sob")
* - pmt::string_to_symbol("tx_eob")
* - pmt::string_to_symbol("tx_time")
- * - pmt::string_to_symbol(length_tag_key)
+ * - pmt::string_to_symbol(length_tag_name)
*
* The sob and eob (start and end of burst) tag values are pmt booleans.
* When present, burst tags should be set to true (pmt::PMT_T).
*
- * If length_tag_key is not an empty string, all "tx_sob" and "tx_eob"
+ * If length_tag_name is not an empty string, all "tx_sob" and "tx_eob"
* tags will be ignored.
*
* The length tag value should be a pmt long specifying the number
@@ -131,12 +131,12 @@ namespace gr {
*
* \param device_addr the address to identify the hardware
* \param stream_args the IO format and channel specification
- * \param length_tag_key the key of the tag identifying tagged stream
length
+ * \param length_tag_name the name of the tag identifying tagged stream
length
* \return a new USRP sink block object
*/
static sptr make(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
- const std::string &length_tag_key = "");
+ const std::string &length_tag_name = "");
/*!
* Set the start time for outgoing samples.
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 759019f..c96e486 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -33,7 +33,7 @@ namespace gr {
usrp_sink::make(const ::uhd::device_addr_t &device_addr,
const ::uhd::io_type_t &io_type,
size_t num_channels,
- const std::string &length_tag_key)
+ const std::string &length_tag_name)
{
//fill in the streamer args
::uhd::stream_args_t stream_args;
@@ -47,22 +47,22 @@ namespace gr {
for(size_t chan = 0; chan < num_channels; chan++)
stream_args.channels.push_back(chan); //linear mapping
- return usrp_sink::make(device_addr, stream_args, length_tag_key);
+ return usrp_sink::make(device_addr, stream_args, length_tag_name);
}
usrp_sink::sptr
usrp_sink::make(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
- const std::string &length_tag_key)
+ const std::string &length_tag_name)
{
check_abi();
return usrp_sink::sptr
- (new usrp_sink_impl(device_addr, stream_args_ensure(stream_args),
length_tag_key));
+ (new usrp_sink_impl(device_addr, stream_args_ensure(stream_args),
length_tag_name));
}
usrp_sink_impl::usrp_sink_impl(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
- const std::string &length_tag_key)
+ const std::string &length_tag_name)
: sync_block("gr uhd usrp sink",
args_to_io_sig(stream_args),
io_signature::make(0, 0, 0)),
@@ -70,7 +70,7 @@ namespace gr {
_nchan(stream_args.channels.size()),
_stream_now(_nchan == 1),
_start_time_set(false),
- _length_tag_key(length_tag_key),
+ _length_tag_key(length_tag_name.empty() ? pmt::PMT_NIL :
pmt::string_to_symbol(length_tag_name)),
_nitems_to_send(0)
{
if(stream_args.cpu_format == "fc32")
@@ -484,7 +484,7 @@ namespace gr {
//check if there is data left to send from a burst tagged with length_tag
//note: if a burst is started during this call to work(), tag_work()
should
//have been called and we should have _nitems_to_send > 0.
- if(not _length_tag_key.empty() and _nitems_to_send > 0) {
+ if(not pmt::is_null(_length_tag_key) and _nitems_to_send > 0) {
ninput_items = std::min<long>(_nitems_to_send, ninput_items);
//if we run out of items to send, it's the end of the burst
if(_nitems_to_send - long(ninput_items) == 0)
@@ -502,8 +502,9 @@ namespace gr {
#endif
//if using length_tags, decrement items left to send by the number of
samples sent
- if(not _length_tag_key.empty() and _nitems_to_send > 0)
+ if(not pmt::is_null(_length_tag_key) and _nitems_to_send > 0) {
_nitems_to_send -= long(num_sent);
+ }
//increment the timespec by the number of samples sent
_metadata.time_spec += ::uhd::time_spec_t(0, num_sent, _sample_rate);
@@ -547,20 +548,20 @@ namespace gr {
break;
}
- //handle end of burst with a mini end of burst packet; ignore if we
have a nonempty length_tag_key string
- else if(_length_tag_key.empty() and pmt::equal(key, EOB_KEY)) {
+ //handle end of burst with a mini end of burst packet; ignore if
length_tag_key is not null
+ else if(pmt::is_null(_length_tag_key) and pmt::equal(key, EOB_KEY)) {
_metadata.end_of_burst = pmt::to_bool(value);
ninput_items = 1;
return;
}
- //set the start of burst flag in the metadata; ignore if we have a
nonempty length_tag_key string
- else if(_length_tag_key.empty() and pmt::equal(key, SOB_KEY)) {
+ //set the start of burst flag in the metadata; ignore if
length_tag_key is not null
+ else if(pmt::is_null(_length_tag_key) and pmt::equal(key, SOB_KEY)) {
_metadata.start_of_burst = pmt::to_bool(value);
}
//length_tag found; set the start of burst flag in the metadata
- else if(not _length_tag_key.empty() and pmt::equal(key,
pmt::string_to_symbol(_length_tag_key))) {
+ else if(not pmt::is_null(_length_tag_key) and pmt::equal(key,
_length_tag_key)) {
//If there are still items left to send, we will truncate the
previous burst
//by setting the end of burst flag in a mini end of burst packet.
The next
//call to work will start at the new burst.
diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h
index 873c01f..ae31b51 100644
--- a/gr-uhd/lib/usrp_sink_impl.h
+++ b/gr-uhd/lib/usrp_sink_impl.h
@@ -54,7 +54,7 @@ namespace gr {
public:
usrp_sink_impl(const ::uhd::device_addr_t &device_addr,
const ::uhd::stream_args_t &stream_args,
- const std::string &length_tag_key);
+ const std::string &length_tag_name);
~usrp_sink_impl();
void setup_rpc();
@@ -136,7 +136,7 @@ namespace gr {
//stream tags related stuff
std::vector<tag_t> _tags;
- const std::string _length_tag_key;
+ const pmt::pmt_t _length_tag_key;
long _nitems_to_send;
};
- [Commit-gnuradio] [gnuradio] branch master updated (754cfa7 -> a337dcb), git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 02/11: uhd: fixed tags_demo, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 01/11: gr-uhd: added tagged stream support, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 10/11: uhd: Added freq hopping example, improved tag handling in usrp_sink, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 06/11: uhd: modified tag preemption/gap handling, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 03/11: uhd: changed length_tag member variable from string to pmt symbol,
git <=
- [Commit-gnuradio] [gnuradio] 11/11: uhd: Used uhd-internal fragmentation handling, bursty tx w/o time tags now no longer uses time specs, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 05/11: uhd: added length tag name parameter in GRC, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 07/11: uhd: Added retune-by-tag and a command interface via message passing, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 08/11: uhd: Allow post-burst tune; tag handling less restrictive, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 04/11: uhd: added notification for tagged stream preemptions/gaps, git, 2014/04/26
- [Commit-gnuradio] [gnuradio] 09/11: docs: Updated uhd to reflect tag changes., git, 2014/04/26