Hi Marcus,
By mentioning that I spent many hours I wanted to say I’m hardly stuck
on
this problem yet!
You said the there is no problem that we wait on the source to produce
as
long as we want! But this is not true when I have other blocks waiting
for
processing!! In other word, when the source produces one packet, I want
this packet go down through blocks and amid of these blocks a message
must
tells the source to produce again.
If the source doesn’t produce anything after generating some packets,
the
scheduler will be locked on the source and does nothing with other
blocks!!
As you said, the wait will work for this source, but it’s also has the
same problem I mentioned.
Here is the summary of random bit generator:
#include <gnuradio/io_signature.h>
#include <stdlib.h>
#include <time.h>
#include
#include <unistd.h>
namespace gr {
namespace my_lte {
lte_random_bit_gen::sptr
lte_random_bit_gen::make(int packet_len) // packet_len: the size of
generating packet bits
{
return gnuradio::get_initial_sptr
(new lte_random_bit_gen_impl(packet_len));
}
/*
*/
lte_random_bit_gen_impl::lte_random_bit_gen_impl(int packet_len)
: gr::sync_block("lte_random_bit_gen",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(1, 1, sizeof(char))),
packet_length(packet_len),
{
srand (time(NULL)); // randomizing the seed
set_max_noutput_items(packet_length);
}
lte_random_bit_gen_impl::~lte_random_bit_gen_impl()
{
}
int
lte_random_bit_gen_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
char *out = (char *) output_items[0];
int random_val, nout_written = 0;
for (int i=0; i<packet_length; i++)
{
random_val = rand();
bitset<8> b(random_val);
if (b[0] == 0)
*out = 1;
else
*out = 0;
out++;
nout_written++;
}
// add tag
add_item_tag(0,
nitems_written(0),
pmt::string_to_symbol("length"),
pmt::from_long(packet_length));
cout << "bit generator " << endl ;
return nout_written;
}
On Sun, Jun 1, 2014 at 1:43 PM, Marcus M. [email protected]