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()