Hi John,

I wrote the code in C++ based on UHD_AMsg_source.cc, provided in GRExtras.
In my work function, I've finished it using return -1 (ie. the block has
finished processing correctly) as shown below:

int work(
        const InputItems &,
        const OutputItems &
    ){
      //work definition here (ie. generate a packet and post downstream)
      return -1; //done running, work done status
    }

However, in that way the block in GNU Radio Companion runs only once. The
other possibility is not to use "return" at all, but in that case what I
have is:

1. BLOCK 1 generates a packet
2. BLOCK 1 post the packet downstream

Step 1 and 2 repeats "N times". When finishes, it gives the control to
BLOCK 2 to process the message. However, I need a sequence as follows:

1. BLOCK 1 generates a packet
2. BLOCK 1 post the packet downstream
3. BLOCK 2 process the packet
4. BLOCK 2 post the message again downstream and so on...

Step 1 to 4 should repeat "N times".

Thanks again for your help,

Jose

On Wed, Oct 17, 2012 at 4:52 PM, John Malsbury <john.malsb...@ettus.com>wrote:

> Jose,
>
> Try a while(1) with a block and  a blocking call to pop msg's off the
> queue:
>
> self.pop_msg_queue()
>
> Should help you avoid the return -1
>
> Or maybe I've misunderstood your problem...?
>
> -John
>
>
>
> On Tue, Oct 16, 2012 at 11:18 PM, Jose Torres Diaz <
> torresdiaz.j...@gmail.com> wrote:
>
>> Hi All,
>>
>> I'm working with 2 blocks that I've created using "UHD_AMsg_Source" as a
>> reference model. In these blocks, I am passing pmt_dict type as messages,
>> ie:
>>
>>  this->post_msg(0, AMSG_KEY, dictionary,_id);
>>
>> Where, dictionary contains data/metadata that I can read in the next
>> block downstream.
>>
>> BLOCK 1  -- (pmt_dict included in the message) -->  BLOCK 2
>>
>> The blocks are working ok, but the problem is that when I want to
>> generate several packets and post them downstream, BLOCK 1 runs until
>> finishes and then BLOCK 2 takes the control until finishes. The problem is
>> the "return" sentence in my work function. I did 2 possible ways
>>
>> Option 1: Using -1
>>
>> work {
>> //work here
>> return -1
>> }
>>
>> In this way BLOCK 1 stops working after one iteration and it does not run
>> as many times as I want.
>>
>> Option 1: Not using return
>>
>> work {
>> //work here
>> }
>>
>> In this way BLOCK 1 runs many times and posts messages downstream all
>> those times, but it gives the control to BLOCK 2 when it finishes. Then,
>> BLOCK 2 takes the messages from the message queue. However, this
>> implementation is not useful for me. BLOCK 1 should post a message
>> downstream and then, BLOCK 2 takes the message and work with the packet.
>>
>> Any suggestion is welcome, thanks a lot for your time,
>>
>> Regards,
>>
>> Jose
>>
>> _______________________________________________
>> Discuss-gnuradio mailing list
>> Discuss-gnuradio@gnu.org
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>>
>
_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to