discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] State Machine that drops samples (Problems with r


From: Felipe Domingues
Subject: Re: [Discuss-gnuradio] State Machine that drops samples (Problems with return and consume_each in general_work)
Date: Mon, 3 Aug 2015 21:23:53 +0100

Dear all,

I was able to fix the problem. 

Fist I had forecast set to a big number and vector sink was unable to provide such amount of inputs. I changed that to ninput_items_required[0]= noutput_items, not sure if it's the correct relation thought. But the block still didn't work.

Apparently I was not consuming the item responsible for the state transition, so general_work was in an infinite loop. Changing consume_each(i) to consume_each(i+1) did the trick.

Finally, for some reason I had to delete the blank file generated by past iterations of the program manually and a correct one was created. Now I don't need to do that any more, but watch out if you are using Ubuntu 14.04.

Here is the (apparently) working code:

        for (int i = 0; i < noutput_items; i++) {

          currentState = nextState;
          std::cout << noutput_items << std::endl;
          std::cout << "\nin[i]: " << in[i] << std::endl;


          if(in[i] == std::complex<float> (0,0)){

            if(currentState == 0){
              std::cout << "\nstatezero" << std::endl;
              nextState = 1;
              consume_each(i+1);
              return 0;

            }

            if(currentState == 1){
              std::cout << "\nstateone" << std::endl;
              for (int j = 0; j < i; j++) {
                out[j] = in[j];
              }
              nextState = 0;
              consume_each(i+1);
              return i;
            }

          }

        }

        if (currentState == 0){ 
          std::cout << "\nFinishing loop in state zero" << std::endl;
          consume_each (noutput_items);
          return 0;
        }

        if (currentState == 1){   

          for (int j = 0; j < noutput_items; j++) {
            out[j] = in[j];
          }
          consume_each (noutput_items);
          std::cout << "\nnFinishing loop in state one" << std::endl;
          return noutput_items;
        }



BTW there was a typo in my original email, both state transitions use the same condition. 

Thank you very much for your attention,

reply via email to

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