Gnuradio,OOT: correcting send() for tagged stream block?

357 views Asked by At

I need help making a gnuradio OOT module. I am actually trying to extending one code.

I am trying to make 2 TX 1Rx tagged stream block (OOT). For 1Tx 1Rx, it is working fine. I am trying to extend it. Now the problem is, I am not being able to configure the send() function. With this code, one transmitter transmits, but other does not work. The subdev specification and frequency and other parameters are allocated correctly. I checked.

If I try make test, it does not show any problem. I checked the every port of my USRP X310, it is working fine.

Here's the code. I putting a short part which deals with the send and receive buffer.

void
usrp_echotimer_cc_impl::send()
{
// Data to USRP
num_tx_samps = d_tx_stream->send(d_in_send1, total_num_samps,
d_metadata_tx, total_num_samps/(float)d_samp_rate+d_timeout_tx);
num_tx_samps = d_tx_stream->send(d_in_send0, total_num_samps,
d_metadata_tx, total_num_samps/(float)d_samp_rate+d_timeout_tx);
}

int
usrp_echotimer_cc_impl::work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
gr_complex *in0 = (gr_complex *) input_items[0];
gr_complex *in1 = (gr_complex *) input_items[1];
gr_complex *out = (gr_complex *) output_items[0];
// Set output items on packet length
noutput_items = ninput_items[0]=ninput_items[1];

// Resize output buffer
if(d_out_buffer.size()!=noutput_items)
d_out_buffer.resize(noutput_items);

// Send thread
d_in_send0 = in0;
d_in_send1 = in1;
d_noutput_items_send = noutput_items;
d_thread_send =
gr::thread::thread(boost::bind(&usrp_echotimer_cc_impl::send, this));

// Receive thread
d_out_recv = &d_out_buffer[0];
d_noutput_items_recv = noutput_items;
d_thread_recv =
gr::thread::thread(boost::bind(&usrp_echotimer_cc_impl::receive, this));

My system config is X310, daughterboard SBX-120 and I am using UHD-3.9. I checked the subdev specification, gain and frequency assignment. Those are fine.

1

There are 1 answers

0
Marcus Müller On BEST ANSWER

For completeness: This has been asked yesterday on the GNU Radio mailing list; Sanjoy has already gotten two responses:

Martin Braun wrote:

Sorry, Sanjoy,

we'll need some more information before we can give you better feedback. It's not clear exactly what you're trying to achieve, and what exactly is failing.

Perhaps this helps getting started: http://gnuradio.org/redmine/projects/gnuradio/wiki/ReportingErrors

Cheers, Martin

And my answer is a bit longish, but it's available here. In excerpts:

Hi Sanjoy,

I am trying to make 2 TX 1Rx tagged stream block(OOT). For 1Tx 1Rx, it was working fine. I am trying to extend it. Now the problem is, I am not being able to configure the send() function.

Is there a particular reason you're creating your own block? Is there a feature missing on the USRP sink and source that come with gr-uhd?

...

your send() function looks a bit strange; what you're doing is transmitting two things on a single channel after each other. Also, what you should be doing (from a programming style point of view) is pass the buffers you want to send as references or something, but not save them to class properties and then call send(). To send two buffers to two different channels, you will need to use a vector containing the two buffers -- have a look at rx_multi_samples; that of course recv()s rather than sends(), but the semantics are the same.

...

noutput_items is given to you to let your work now how much it may produce, that's why it's a parameter.

...

There's no reason GNU Radio couldn't already call your work function again while usrp_echotimer_cc_impl::send() hasn't even started to transmit samples. Then, your d_send variables will be overwritten.

...

Since a single X310 is inherently coherent and has the same time, you can simply use a USRP sink and a source, use set_start_time(...) on both with the same time spec, and have your flow graph consume and produce samples in different threads, coherently.