discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] new block creation


From: Josh Blum
Subject: Re: [Discuss-gnuradio] new block creation
Date: Thu, 13 Jun 2013 18:40:46 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6


On 06/13/2013 05:02 PM, Yogesh Dahiya wrote:
> I have created a new block with 2 input ports and 2 output ports
> If i connect to port 0 of block work function gets called but when i
> connect to port 1 it does'nt (and i m leaving some ports of my block
> disconnected)
> 
> Block:
> 
> class another(gras.Block):
> def __init__(self,dest_addr,source_addr,max_attempts,time_out):
> gras.Block.__init__(self,name="aloha_mac",
> in_sig = [numpy.uint8,numpy.uint8],
>             out_sig = [numpy.uint8,numpy.uint8])
> #self.output_config(0).reserve_items = 4096
> 
> def param(self):
> print "Destination addr : ",self.dest_addr
> print "Source addr : ",self.source_addr
> print "TimeOut : ",self.time_out
> print "Max Attempts : ",self.max_attempts
> 
> def work(self,ins,outs):
> print "hello"
> 
> Connection
> 
> self.connect((self.sniffer,0),(self.another_0,0))
> self.connect((self.another_0,0),(self.extras_datagram_to_stream_0,0))
> 
> work get called
> 
> but if
> 
> self.connect((self.sniffer,0),(self.another_1,0))
> self.connect((self.another_1,0),(self.extras_datagram_to_stream_0,0))
> 
> work is not called
> 
> 

Here is my confusion: You mentioned one block with two inputs, but the
code above reads self.another_1 and port #0. So it sounds like 2
instances of block another, each with one port in and one port out. Did
you mean this:?

self.connect((self.sniffer,0),(self.another_0,1))

Anyway, if my misunderstanding is correct, the reason work doesnt get
called is because the block only calls work when both inputs have some
data available. Is it possible that the second port does not have any
data sent?

If you would like the two inputs to be asynchronous to each other, you
can set the reserve_items to 0. This means work will be called when data
is available on any port, but does not require data to actually be
available on both ports.

self.input_config(0).reserve_items = 0

-josh

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



reply via email to

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