discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] coding problem


From: 김무연
Subject: [Discuss-gnuradio] coding problem
Date: Wed, 25 Apr 2018 19:11:55 +0900

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]