Sunday, July 2, 2017

[Discuss-gnuradio] Clear output buffer of a block in GnuRadio

Hi all.

I'm implementing the next block:


Depending of a parameter that's put in the message port, it links the input to just one of the outputs. The code is:

int n= std::min(ninput_items[0], noutput_items);
int i=0;
        if(d_st==0){
            while(i < n){
                out_wifi[i] = in[i]; //Output 1
                i++;
            }
        }else{
            while(i < n){
                out_zigbee[i] = in[i]; //Output 2
                i++;
            }
        }
        consume_each (i);
        return i;

When I implement it, I get a bad output if I link one second one output, and the rest of the time the other.

Input to output2 (1 second)


Later, I switch input to output1 (rest of the simulation)


It should continue as the before screenshot, but after a while, suddenly, i have signal in the two outputs.


How can it happen? After that moment, the behavior is cyclic, the output 2 a while has signal and other while it doesn't (The signal must be just in the output 1). So I think, the circular buffer of the  output 2, was wrote and it is not being erased.

How can I clear the buffer after switch the output? or, what do you think is my problem?

Thanks in advance.

Best regards,

Cristian

Pdta: It is the flowgraph

No comments:

Post a Comment