Hi,
I have written a simple ‘general’ C++ block that takes some complex
values from a file source and outputs ints to a file as binary.
I find that it adds a ‘0’ after every time the block is called, so if I
have 10 input values in the file, then it runs using the first 8,
outputs 8 values correctly and adds a 0, then runs using the last 2,
outputs 2 values correctly and then adds a 0.
If anyone is interested or has experienced something similar, I will
provide some code!
David
Hi,
I have simplified my code; as below and attached. I include a simple
flow graph too. Lots of 0’s are appended to the output file? I must be
making a silly mistake?!
Thanks for any help!
Regards,
David
/*
* The private constructor
*/
cip_vcic_impl::cip_vcic_impl(int v_len, int r_max, int l_max)
: gr::block("cip_vcic",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(1, 1, sizeof(gr_complex)))
{}
/*
* Our virtual destructor.
*/
cip_vcic_impl::~cip_vcic_impl()
{
}
void
cip_vcic_impl::forecast (int noutput_items, gr_vector_int
&ninput_items_required)
{
ninput_items_required[0] = noutput_items;
}
int
cip_vcic_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
// Copy input to output
for(int item_idx = 0; item_idx < ninput_items[0]; item_idx++)
{
memcpy((void *) &out[item_idx], (void *) &in[item_idx],
sizeof(gr_complex));
produce(0, 1);
}
// Tell runtime system how many input items we consumed on
// each input stream.
consume_each (noutput_items);
// Tell runtime system how many output items we produced.
return noutput_items;
}
p.s. clearly this takes in complex and puts out complex (not ints like
my original code/explanation).