Hi ??,
this question reveals that you have not considered GNU Radio to not be
bound by real time.
As samples are "bare numbers", they don't have a time. Thus, GNU Radio
nor any of the blocks involved care about how much time has passed in
the real world. Thus, for your block, while no message occurs time
"does not pass". And you can only generate samples in the work function.
Therefore, yes, it can be done, but you'll have to calculate in your
work how many samples you wanted to produce in the time since the last
call to work.
If you have a hardware sink or source involved though, this is *never*
the correct approach, since you will end up with two competing clocks,
and that will, over a longer time, lead to over- or underflows. You can
solve this issue by either using a hardware sink that accepts bursts of
data, so you don't have to zero pad, or by having a block that passes
through input samples (e.g. from a constant 0 source) and adds
message-generated samples when they occur.
Greetings,
Marcus
On 07.08.2014 14:53, ?? wrote:
> Hello Martin,
>
> If you create a block which input is message and output is float. And
> message is arrive discrete just like packet in network, I want the block
> output port will output 0 when no message arrive at input port. Can I do
> that?
>
> Why I ask this question is that I a while ago I trying to create a
> communication system which I defined and there has two kinds of channel one
> is control channel and the other one is message channel like the GSM system
> I think so, and I'm using FDD. And control channel is using gmsk modulation
> and message channel is using fm modulation because I just want to transmit
> audio, I using enough BW to avoid aliasing. After gmsk mod and fm mod, I
> add them together but result failed, because add block in gnuradio will
> wait when two input data and add one-by-one so if if port one data is much
> more then port two, and the add will hold port one data and wait port two
> data then add one-by-one.
>
> I have recreate the same situation and past in the mail, it is python file
> and can test it to check the problem
>
> Here is my setting : I have two source one is audio source and the other is
> packet, and I add it together and output to audio sink. Important audio
> source will generate data when program start. The first 5 second no packet
> is send. After 5 second packet source will send 1000 packets, meantime,
> speaker have sound, and if you have say something in first 5 seconds, you
> will hear what you say in the first 5 second now.
>
> ---------------------------------------------------------
> #!/usr/bin/env python
> ##################################################
> # Gnuradio Python Flow Graph
> # Title: Top Block
> # Generated: Thu Aug 7 20:16:29 2014
> ##################################################
>
> from gnuradio import eng_notation
> from gnuradio import gr
> from gnuradio.eng_option import eng_option
> from gnuradio.filter import firdes
> from optparse import OptionParser
> from gnuradio import digital
> from gnuradio import audio
> from gnuradio import blocks
> from time import sleep
>
> class top_block(gr.top_block):
>
> def __init__(self):
> gr.top_block.__init__(self, "Top Block1")
>
> ##################################################
> # Variables
> ##################################################
> self.samp_rate = samp_rate = 32000
>
> ##################################################
> # Blocks
> ##################################################
> self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2,
> bt=0.35, verbose=False, log=False, )
> self.digital_mod_pkts_0 = digital.mod_pkts(self.digital_gmsk_mod_0,
> access_code=None, msgq_limit=4, pad_for_usrp=False)
> self.audio_source_0 = audio.source(samp_rate, "", True)
> self.audio_sink_0 = audio.sink(samp_rate, "", True)
> self.blocks_add_xx_0 = blocks.add_vcc(1)
> self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
> self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
> self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01,
> ))
>
> ##################################################
> # Connections
> ##################################################
> self.connect((self.blocks_add_xx_0, 0),
> (self.blocks_complex_to_real_0, 0))
> self.connect((self.blocks_complex_to_real_0, 0),
> (self.audio_sink_0, 0))
> self.connect((self.audio_source_0, 0),
> (self.blocks_float_to_complex_0, 0))
> self.connect((self.audio_source_0, 0),
> (self.blocks_float_to_complex_0, 1))
> self.connect((self.blocks_float_to_complex_0, 0),
> (self.blocks_add_xx_0, 0))
> self.connect((self.digital_mod_pkts_0, 0),
> (self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1))
>
> def send_pkt(self, payload='', eof=False):
> self.digital_mod_pkts_0.send_pkt(payload, eof)
>
> if __name__ == '__main__':
> parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
> (options, args) = parser.parse_args()
> tb = top_block()
> tb.start()
> sleep(5)
> for i in range(0, 1000):
> tb.send_pkt('a')
> raw_input('Press Enter to quit: ')
> tb.stop()
> tb.wait()
>
> ------------------------------------------
>
> Jeff Guo
>
>
>
>
> 2014-08-07 19:07 GMT+08:00 Martin Braun <[email protected]>:
>
>> On 08/07/2014 12:54 PM, ?? wrote:
>>> Hello,
>>>
>>> Is there any way to combine continuous block (like audio source) and
>>> discrete block (like message source) ? Question 1
>> Combine how? You can do that in your own blocks, sure. Maybe stream tags
>> are what you want?
>>
>>> I using add block to add them together, but it failed. It work well when
>>> the discrete block output data like continuous block but discrete block
>>> means there is not output data continuous, it output data when something
>>> trigger.
>>>
>>> Can I write a block which input is message and output is like float, and
>>> output will always generate like 32k samples but input doesn't have 32k
>>> samples suppose this block is sync. Is there any solution ? Question 2
>> You can write a block who's input is message and output is float. I
>> didn't really understand the rest of the question.
>>
>> M
>>
>>
>> _______________________________________________
>> Discuss-gnuradio mailing list
>> [email protected]
>> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>>
>
>
> _______________________________________________
> Discuss-gnuradio mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
_______________________________________________
Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio