Recently I made block with simple coding using c++

my_demod_block_cb_impl::my_demod_block_cb_impl()
      : gr::block("my_demod_block_cb",
              gr::io_signature::make(1, 1, sizeof(float)),
              gr::io_signature::make(1, 1, sizeof(char)))
    {}

As you can see I use float as an input, char as an output

 void
    my_demod_block_cb_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required)
    {
      unsigned ninputs = ninput_items_required.size();
      for(unsigned i = 0; i < ninputs; i++)
      {
        ninput_items_required[i] = noutput_items;
      }
     
    }

int
    my_demod_block_cb_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 float *in = (const float *) input_items[0];
      unsigned char *out = (unsigned char *) output_items[0];


      pow=in[0];
      for(int i = 1; i < noutput_items; i++)
      {
      if(pow<in[i])
         {
           pow=in[i];
           out[i]=01;
         }else if(pow>=in[i])
          {
           out[i]=00;
           }
      }
Mostly I just followed the way on the internet
My goal is using 'for' structure and comparing the power
So save the highest power in pow and send 1
if not sustain the previous highest power value and send 0
So my problem is pow does not save the value for running time
It just save the value for sometimes
If pow saves the renewed power values from some time it keeps sending 0 but it doesn't
So are there any way to prolong the noutput_items?
Please let me know

Thanks
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to