1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/* -*- c++ -*- */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gr_io_signature.h>
#include "byte_source_impl.h"
namespace gr {
namespace howto {
byte_source::sptr byte_source::make()
{ return gnuradio::get_initial_sptr (new byte_source_impl()); }
// private constructor
byte_source_impl::byte_source_impl() : gr_block(
"byte_source",
gr_make_io_signature( 0, 0, 0 ),
gr_make_io_signature( 1, 1, sizeof(char*) ) ), // What to use, char* ??
counter(0)
{ }
// virtual destructor
byte_source_impl::~byte_source_impl()
{ }
void byte_source_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
{
ninput_items_required[0] = 0; // for source_block it is zero, but not noutput_items;
}
int byte_source_impl::general_work (
int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
char* *out = (char**) output_items[0];
char* sentence[] = {"A", "n", "g", "e", "l" };
for (int i=0; i < noutput_items; i++)
{
out[i] = sentence[counter];
counter++;
if ( counter == 5 )
counter = 0;
}
consume_each (0);
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace howto */
} /* namespace gr */
|