# Boston, MA 02110-1301, USA.
#
-from gnuradio import gr, gru, modulation_utils
+from gnuradio import gr, gru, modulation_utils, blks2
from gnuradio import eng_notation
from gnuradio.eng_option import eng_option
from optparse import OptionParser
from receive_path_lb import receive_path
import fusb_options
-class awgn_channel(gr.hier_block):
- def __init__(self, fg, sample_rate, noise_voltage, frequency_offset, seed=False):
- self.input = gr.add_const_cc(0) # dummy input device
-
- # Create the Gaussian noise source
- if not seed:
- self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage)
- else:
- rseed = int(time.time())
- self.noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_voltage, rseed)
-
- self.adder = gr.add_cc()
-
- # Create the frequency offset
- self.offset = gr.sig_source_c(1, gr.GR_SIN_WAVE,
- frequency_offset, 1.0, 0.0)
- self.mixer = gr.multiply_cc()
-
- # Connect the components
- fg.connect(self.input, (self.mixer, 0))
- fg.connect(self.offset, (self.mixer, 1))
- fg.connect(self.mixer, (self.adder, 0))
- fg.connect(self.noise, (self.adder, 1))
-
- gr.hier_block.__init__(self, fg, self.input, self.adder)
-
-class my_graph(gr.flow_graph):
+class my_top_block(gr.top_block):
def __init__(self, mod_class, demod_class, rx_callback, options):
- gr.flow_graph.__init__(self)
+ gr.top_block.__init__(self)
channelon = True;
noise_power = power_in_signal/SNR
noise_voltage = math.sqrt(noise_power)
- self.txpath = transmit_path(self, mod_class, options)
+ self.txpath = transmit_path(mod_class, options)
self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
- self.rxpath = receive_path(self, demod_class, rx_callback, options)
+ self.rxpath = receive_path(demod_class, rx_callback, options)
if channelon:
- self.channel = awgn_channel(self, options.sample_rate, noise_voltage,
- frequency_offset, options.seed)
+ self.channel = blks2.channel_model(noise_voltage, frequency_offset, 1.01)
if options.discontinuous:
z = 20000*[0,]
# print payload[2:len(payload)]
def send_pkt(payload='', eof=False):
- return fg.txpath.send_pkt(payload, eof)
+ return tb.txpath.send_pkt(payload, eof)
mods = modulation_utils.type_1_mods()
print "Warning: failed to enable realtime scheduling"
# Create an instance of a hierarchical block
- fg = my_graph(mods[options.modulation], demods[options.modulation], rx_callback, options)
- fg.start()
+ tb = my_top_block(mods[options.modulation], demods[options.modulation], rx_callback, options)
+ tb.start()
# generate and send packets
nbytes = int(1e6 * options.megabytes)
pkt_size = int(options.size)
while n < nbytes:
- send_pkt(struct.pack('!H', pktno) + (pkt_size - 2) * chr(pktno & 0xff))
+ send_pkt(struct.pack('!H', pktno & 0xffff) + (pkt_size - 2) * chr(pktno & 0xff))
n += pkt_size
pktno += 1
send_pkt(eof=True)
- fg.wait()
+ tb.wait()
if __name__ == '__main__':
try: