def __init__(self, alpha=0.8, fft_len=1024, samp_rate=32000): gr.hier_block2.__init__( self, "Threechannelpsd", gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(3, 3, [gr.sizeof_float*fft_len, gr.sizeof_float*fft_len, gr.sizeof_float*fft_len]), ) ################################################## # Parameters ################################################## self.alpha = alpha self.fft_len = fft_len self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.utils_psd_cvf_0_9_1 = utils.psd_cvf(samp_rate, fft_len, firdes.WIN_BLACKMAN_hARRIS, alpha) self.utils_psd_cvf_0_9_0 = utils.psd_cvf(samp_rate, fft_len, firdes.WIN_BLACKMAN_hARRIS, alpha) self.utils_psd_cvf_0_9 = utils.psd_cvf(samp_rate, fft_len, firdes.WIN_BLACKMAN_hARRIS, alpha) ################################################## # Connections ################################################## self.connect((self, 0), (self.utils_psd_cvf_0_9, 0)) self.connect((self, 1), (self.utils_psd_cvf_0_9_0, 0)) self.connect((self, 2), (self.utils_psd_cvf_0_9_1, 0)) self.connect((self.utils_psd_cvf_0_9, 0), (self, 0)) self.connect((self.utils_psd_cvf_0_9_0, 0), (self, 1)) self.connect((self.utils_psd_cvf_0_9_1, 0), (self, 2))
def __init__(self, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, thresh): gr.hier_block2.__init__( self, "Sample and Hold Detector", gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]), gr.io_signaturev(4, 4, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ])) ''' Constructor @param freq_sample_delay_samps - @param freq_samps_to_avg - @param mag_samps_to_avg - @param thresh - ''' ################################################## # Parameters ################################################## self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.thresh = thresh ################################################## # Blocks ################################################## self.edge_detector = timing_utils.edge_detector_bb( timing_utils.RISING_EDGE) self.threshold = blocks.threshold_ff(thresh / 4.0, thresh, 0) self.samp_hold = blocks.sample_and_hold_ff() self.mag_avg = blocks.moving_average_ff(int(mag_samps_to_avg), 1.0 / (mag_samps_to_avg), 4000) self.freq_avg = blocks.moving_average_ff(int(freq_samps_to_avg), 1.0 / (freq_samps_to_avg), 4000) self.f2c = blocks.float_to_char(1, 1) self.delay = blocks.delay( gr.sizeof_float * 1, int(freq_samps_to_avg - mag_samps_to_avg + freq_sample_delay_samps)) ################################################## # Connections ################################################## self.connect((self.delay, 0), (self.mag_avg, 0)) self.connect((self.f2c, 0), (self.edge_detector, 0)) self.connect((self.freq_avg, 0), (self.samp_hold, 0)) self.connect((self.freq_avg, 0), (self, 1)) self.connect((self.mag_avg, 0), (self.threshold, 0)) self.connect((self.mag_avg, 0), (self, 3)) self.connect((self.samp_hold, 0), (self, 0)) self.connect((self.threshold, 0), (self.f2c, 0)) self.connect((self.threshold, 0), (self, 2)) self.connect((self, 0), (self.delay, 0)) self.connect((self, 1), (self.freq_avg, 0)) self.connect((self.edge_detector, 0), (self.samp_hold, 1))
def __init__(self, num_ports=2, n_skip_ahead=8192): gr.hier_block2.__init__( self, "TwinRx Phase Offset Estimate", gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports,gr.sizeof_gr_complex)), gr.io_signaturev(num_ports-1, num_ports-1, gen_sig_io(num_ports-1,gr.sizeof_float)), ) ################################################## # Parameters ################################################## self.n_skip_ahead = n_skip_ahead self.num_ports = num_ports # Create skip head blocks and connect them to the inputs self.skiphead = [] for p in range(0, num_ports): object_name_skiphead = 'blocks_skiphead_'+str(p) self.skiphead.append(blocks.skiphead(gr.sizeof_gr_complex*1, n_skip_ahead)) self.connect((self, p), (self.skiphead[p], 0)) #Create blocks computing subtracted phases and connect the results to the outputs self.multiply_conjugate = [] self.complex_to_arg = [] for p in range(0, num_ports-1): self.multiply_conjugate.append(blocks.multiply_conjugate_cc(1)) self.complex_to_arg.append(blocks.complex_to_arg(1)) self.connect((self.skiphead[0], 0), (self.multiply_conjugate[p], 0)) self.connect((self.skiphead[p+1], 0), (self.multiply_conjugate[p], 1)) self.connect((self.multiply_conjugate[p], 0), (self.complex_to_arg[p], 0)) self.connect((self.complex_to_arg[p], 0), (self, p))
def __init__(self, update_period=32, window=1024, step_size=0.001, num_ports=2): gr.hier_block2.__init__( self, "Phase Align", gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports)), gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports)), ) self.message_port_register_hier_in("Trigger") ################################################## # Parameters ################################################## self.update_period = update_period self.window = window self.step_size = step_size self.num_ports = num_ports ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## # Const block for reference signal to do nothing self.blocks_add_const_vxx_0 = blocks.add_const_vcc((0, )) self.connect((self, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self, 0)) for p in range(num_ports-1): # Create PC object object_name_pc = 'wifius_phase_correct_vci_'+str(p) setattr(self, object_name_pc, wifius.phase_correct_vci(1024, samp_rate, window, step_size, update_period, False)) # Add Stream To Vector For Ref object_name_vr = 'blocks_stream_to_vector_a_'+str(p) setattr(self, object_name_vr, blocks.stream_to_vector(gr.sizeof_gr_complex*1, window)) # Add Stream To Vector For Next Signal object_name_sv = 'blocks_stream_to_vector_b_'+str(p) setattr(self, object_name_sv, blocks.stream_to_vector(gr.sizeof_gr_complex*1, window)) # Add Vector To Stream For Output of PC object_name_vs = 'blocks_vector_to_stream_'+str(p) setattr(self, object_name_vs, blocks.vector_to_stream(gr.sizeof_gr_complex*1, window)) # Make Connections self.connect((self, 0), (getattr(self,object_name_vr), 0)) self.connect((self, p+1), (getattr(self,object_name_sv), 0)) self.connect((getattr(self,object_name_vr), 0), (getattr(self,object_name_pc), 0)) self.connect((getattr(self,object_name_sv), 0), (getattr(self,object_name_pc), 1)) self.connect((getattr(self,object_name_pc), 0), (getattr(self,object_name_vs), 0)) self.connect((getattr(self,object_name_vs), 0), (self, p+1)) self.msg_connect((self, 'Trigger'), (getattr(self,object_name_pc), 'set_enable_sync'))
def __init__(self): gr.hier_block2.__init__( self, "BER Computation", gr.io_signaturev( 2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]), gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]), ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.iir_filter_xxx_0_0 = filter.iir_filter_ffd([1], [1, 1], True) self.iir_filter_xxx_0 = filter.iir_filter_ffd([1], [1, 1], True) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_sub_xx_0 = blocks.sub_cc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.5) self.blocks_max_xx_0_0 = blocks.max_ff(1, 1) self.blocks_max_xx_0 = blocks.max_ff(1, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_cc(1) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.iir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self, 0)) self.connect((self.blocks_max_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_max_xx_0_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_max_xx_0_0, 0), (self, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_max_xx_0_0, 0)) self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_max_xx_0, 0)) self.connect((self, 0), (self.blocks_sub_xx_0, 0)) self.connect((self, 1), (self.blocks_sub_xx_0, 1))
def __init__(self, fft_len=64, payload_bps=2): gr.hier_block2.__init__( self, "OFDM TX RX Hier paths", gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), ) ################################################## # Parameters ################################################## self.fft_len = fft_len self.payload_bps = payload_bps ################################################## # Variables ################################################## self.len_tag_key = len_tag_key = "packet_len" ################################################## # Blocks ################################################## self.tag_gate_tx = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.ofdm_tx = ofdm_tools.ofdm_txrx_modules.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=payload_bps, rolloff=0, debug_log=False, scramble_bits=False) self.ofdm_rx = ofdm_tools.ofdm_txrx_modules.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=payload_bps, debug_log=False, scramble_bits=False) self.multiply_const_tx = blocks.multiply_const_vcc((.01, )) self.agc_rx = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.agc_rx.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self, 0), (self.ofdm_tx, 0)) self.connect((self, 1), (self.agc_rx, 0)) self.connect((self.agc_rx, 0), (self.ofdm_rx, 0)) self.connect((self.ofdm_rx, 0), (self, 0)) self.connect((self.multiply_const_tx, 0), (self, 1)) self.connect((self.ofdm_tx, 0), (self.tag_gate_tx, 0)) self.connect((self.tag_gate_tx, 0), (self.multiply_const_tx, 0))
def __init__(self, num_ports=2, config_filename=''): gr.hier_block2.__init__( self, "Phase Correct Chains", gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports, gr.sizeof_gr_complex)), gr.io_signaturev(num_ports, num_ports, gen_sig_io(num_ports, gr.sizeof_gr_complex)), ) ################################################## # Parameters ################################################## self.num_ports = num_ports self.config_filename = config_filename # Check file try: file = open(self.config_filename, 'r') file.close() except: sys.stderr.write("Configuration " + config_filename + ", not valid\n") print(sys.stderr) sys.exit(1) # Check that we have enough measurments self.phases = read_config_file(config_filename) if len(self.phases) != (num_ports - 1): sys.stderr.write("Configuration " + config_filename + ". Not valid number of phase estimates\n") print(sys.stderr) sys.exit(1) ################################################## # Blocks ################################################## # Connect first signal directly to output self.nop = blocks.copy(gr.sizeof_gr_complex * 1) self.nop.set_enabled(True) self.connect((self, 0), self.nop) self.connect(self.nop, (self, 0)) for p in range(num_ports - 1): ## Add blocks # Place multiply object object_name_mc = 'multiply_const_' + str(p) gain = numpy.exp(1j * self.phases[p]) setattr(self, object_name_mc, blocks.multiply_const_vcc((gain, ))) ## Make Connections # Top to multiply self.connect((self, p + 1), (getattr(self, object_name_mc), 0)) # Multiply to top self.connect((getattr(self, object_name_mc), 0), (self, p + 1))
def __init__(self, fft_len=64, payload_bps=2): gr.hier_block2.__init__( self, "OFDM TX RX Hier paths", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.fft_len = fft_len self.payload_bps = payload_bps ################################################## # Variables ################################################## self.len_tag_key = len_tag_key = "packet_len" ################################################## # Blocks ################################################## self.tag_gate_tx = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.ofdm_tx = ofdm_tools.ofdm_txrx_modules.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=payload_bps, rolloff=0, debug_log=False, scramble_bits=False ) self.ofdm_rx = ofdm_tools.ofdm_txrx_modules.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=payload_bps, debug_log=False, scramble_bits=False ) self.multiply_const_tx = blocks.multiply_const_vcc((.01, )) self.agc_rx = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.agc_rx.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self, 0), (self.ofdm_tx, 0)) self.connect((self, 1), (self.agc_rx, 0)) self.connect((self.agc_rx, 0), (self.ofdm_rx, 0)) self.connect((self.ofdm_rx, 0), (self, 0)) self.connect((self.multiply_const_tx, 0), (self, 1)) self.connect((self.ofdm_tx, 0), (self.tag_gate_tx, 0)) self.connect((self.tag_gate_tx, 0), (self.multiply_const_tx, 0))
def __init__(self, rx_callback, options, num_channels): self.num_channels = num_channels #len(options.args.split(',')) gr.hier_block2.__init__( self, "receive_path", gr.io_signaturev(self.num_channels, self.num_channels, gen_multiple_ios(self.num_channels, 1)), gr.io_signaturev( self.num_channels, self.num_channels, gen_multiple_ios(self.num_channels, options.occupied_tones))) #[gr.sizeof_gr_complex*options.occupied_tones,gr.sizeof_gr_complex*options.occupied_tones])) #,gr.sizeof_gr_complex*options.occupied_tones,]))#gr.sizeof_gr_complex*options.occupied_tones])) options = copy.copy( options) # make a copy so we can destructively modify self._verbose = options.verbose self._log = options.log self._rx_callback = rx_callback # this callback is fired when there's a packet available # receiver self.ofdm_rx = ofdm.ofdm_demod(options, self.num_channels, callback=self._rx_callback) # # Carrier Sensing Blocks # alpha = 0.001 # thresh = 30 # in dB, will have to adjust # self.probe = analog.probe_avg_mag_sqrd_c(thresh,alpha) # Make Connections output = 0 for p in range(self.num_channels): # Connect USRP to OFDM Demodulator self.connect((self, p), (self.ofdm_rx, p)) # Extra output from FFT Demod self.connect((self.ofdm_rx, p), (self, p)) # Connect probe to output of channel filter # self.connect((self.ofdm_rx,0), self.probe) # Connect equalized signals to output # self.connect((self.ofdm_rx,2), (self,1)) # self.connect((self.ofdm_rx,3), (self,2)) # Display some information about the setup if self._verbose: self._print_verbage()
def __init__(self, n_bits=1000, bits_per_symbol=3): gr.hier_block2.__init__( self, "Custom Ber", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_char*1]), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Parameters ################################################## self.n_bits = n_bits self.bits_per_symbol = bits_per_symbol ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8e6 ################################################## # Blocks ################################################## self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_symbol) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_moving_average_xx_0 = blocks.moving_average_ff(n_bits, 1/float(n_bits), n_bits*4) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self, 1), (self.blocks_xor_xx_0, 1)) self.connect((self, 0), (self.blocks_xor_xx_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Staticphaseshifter", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_float*1]), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Blocks ################################################## self.blocks_transcendental_0_0 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self, 1), (self.blocks_transcendental_0_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.blocks_transcendental_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self, 1), (self.blocks_transcendental_0, 0))
def __init__(self, args, bandwidth, freq=None, lo_offset=None, gain=None, spec=None, antenna=None, clock_source=None, verbose=False): num_channels = len(args.split(',')) gr.hier_block2.__init__( self, "uhd_receiver", gr.io_signature(0, 0, 0), gr.io_signaturev(num_channels, num_channels, gen_multiple_ios(num_channels))) # Set up the UHD interface as a receiver uhd_interface.__init__(self, False, args, bandwidth, freq, lo_offset, gain, spec, antenna, clock_source) # Connect all outputs print num_channels for o in range(num_channels): self.connect((self.u, o), (self, o)) if (verbose): self._print_verbage()
def __init__(self, packet_sink=None): #we want outputs of different types # NOTE: The output signature depends on the number of the subcarriers signature_sizes = [self._item_size_out, gr.sizeof_gr_complex * packet_sink._occupied_tones] #initialize hier2 gr.hier_block2.__init__( self, "ofdm_demod", gr.io_signature(1, 1, packet_sink._hb.input_signature().sizeof_stream_item(0)), # Input signature gr.io_signaturev(2, 2, signature_sizes) # Output signature ) #create blocks msg_source = gr.message_source(self._item_size_out, DEFAULT_MSGQ_LIMIT) self._msgq_out = msg_source.msgq() #connect self.connect(self, packet_sink) self.connect(msg_source, self) # For the vector analyzer connection self.connect((packet_sink, 1), (self, 1)) if packet_sink._hb.output_signature().sizeof_stream_item(0): self.connect(packet_sink, gr.null_sink(packet_sink._hb.output_signature().sizeof_stream_item(0)))
def __init__(self, num_signals=1): gr.hier_block2.__init__( self, "shift_phase_multiple_hier", gr.io_signaturev( 2 * num_signals, 2 * num_signals, gen_sig_io_two_types_symmetrical(2 * num_signals, gr.sizeof_gr_complex, gr.sizeof_float)), gr.io_signature(num_signals, num_signals, gr.sizeof_gr_complex), ) ################################################## # Parameters ################################################## self.num_signals = num_signals ################################################## # Blocks ################################################## ################################################## # Connections ################################################## for p in range(num_signals): ## Add blocks # Place calc phase shift block object_name_m = 'shift_phase_' + str(p) setattr(self, object_name_m, aoa.shift_phase()) self.connect((getattr(self, object_name_m), 0), (self, p)) self.connect((self, p), (getattr(self, object_name_m), 0)) self.connect((self, p + num_signals), (getattr(self, object_name_m), 1))
def __init__(self, payload_packet_len=96, sync_packet_len=96): gr.hier_block2.__init__(self, "Generic transmission path", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.payload_packet_len = payload_packet_len self.sync_packet_len = sync_packet_len ################################################## # Variables ################################################## self.length_tag_name = length_tag_name = "packet_len" ################################################## # Blocks ################################################## self.dctk_stream_to_tagged_stream_cc_1 = dctk.stream_to_tagged_stream_cc(payload_packet_len, tagged_streams.make_lengthtags((payload_packet_len,), (0,), length_tag_name)) self.dctk_stream_to_tagged_stream_cc_0 = dctk.stream_to_tagged_stream_cc(sync_packet_len, tagged_streams.make_lengthtags((sync_packet_len,), (0,), length_tag_name)) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_name) ################################################## # Connections ################################################## self.connect((self.blocks_tagged_stream_mux_0, 0), (self, 0)) self.connect((self, 0), (self.dctk_stream_to_tagged_stream_cc_0, 0)) self.connect((self.dctk_stream_to_tagged_stream_cc_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self, 1), (self.dctk_stream_to_tagged_stream_cc_1, 0)) self.connect((self.dctk_stream_to_tagged_stream_cc_1, 0), (self.blocks_tagged_stream_mux_0, 1))
def __init__(self, audio_rate=48000, samp_rate=512e3): gr.hier_block2.__init__( self, "FM receiver", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(5, 5, [gr.sizeof_char*1, gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.audio_rate = audio_rate self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.mpx_demod_0 = mpx_demod( audio_rate=audio_rate, samp_rate=samp_rate, ) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(2*math.pi*75e3/samp_rate) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.mpx_demod_0, 0)) self.connect((self.mpx_demod_0, 0), (self, 0)) self.connect((self.mpx_demod_0, 1), (self, 1)) self.connect((self.mpx_demod_0, 2), (self, 2)) self.connect((self.mpx_demod_0, 3), (self, 3)) self.connect((self.mpx_demod_0, 4), (self, 4)) self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, Chips=4, data=8): gr.hier_block2.__init__( self, "pseudoinvMultiply", gr.io_signaturev(2, 2, [gr.sizeof_float * 1, gr.sizeof_float * 1]), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Parameters ################################################## self.Chips = Chips self.data = data ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.Multipliers_multiplyPseudoInv_0 = Multipliers.multiplyPseudoInv( Chips, data) ################################################## # Connections ################################################## self.connect((self.Multipliers_multiplyPseudoInv_0, 0), (self, 0)) self.connect((self, 0), (self.Multipliers_multiplyPseudoInv_0, 0)) self.connect((self, 1), (self.Multipliers_multiplyPseudoInv_0, 1))
def __init__(self, Chips=4, data=8, M=1): gr.hier_block2.__init__( self, "demodulatorQamBpsk", gr.io_signature(1, 1, gr.sizeof_float * 1), gr.io_signaturev(3, 3, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Parameters ################################################## self.Chips = Chips self.data = data self.M = M ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.Modulator_qambpskDemodulator_0 = Modulator.qambpskDemodulator( M, data, Chips) ################################################## # Connections ################################################## self.connect((self.Modulator_qambpskDemodulator_0, 1), (self, 0)) self.connect((self.Modulator_qambpskDemodulator_0, 0), (self, 1)) self.connect((self.Modulator_qambpskDemodulator_0, 2), (self, 2)) self.connect((self, 0), (self.Modulator_qambpskDemodulator_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Staticphaseshifter", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_float * 1]), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Blocks ################################################## self.blocks_transcendental_0_0 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.connect((self, 1), (self.blocks_transcendental_0_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.blocks_transcendental_0_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self, 1), (self.blocks_transcendental_0, 0))
def __init__(self, abs_cfo_threshold=1e6, alpha=0.001, fft_len=512, fft_peak_threshold=0.5, rf_center_freq=1e9, samp_rate=32e3): gr.hier_block2.__init__( self, "Coarse Frequency Recovery", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*fft_len, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.abs_cfo_threshold = abs_cfo_threshold self.alpha = alpha self.fft_len = fft_len self.fft_peak_threshold = fft_peak_threshold self.rf_center_freq = rf_center_freq self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fft_len, ref_scale=2, frame_rate=samp_rate/fft_len, avg_alpha=alpha, average=True, ) self.blocksat_wrap_fft_index_0 = blocksat.wrap_fft_index(fft_len) self.blocksat_runtime_cfo_ctrl_0 = blocksat.runtime_cfo_ctrl(7*int(1/alpha), abs_cfo_threshold, int(rf_center_freq)) self.blocksat_exponentiate_const_cci_0 = blocksat.exponentiate_const_cci(4, 1) self.blocksat_argpeak_0 = blocksat.argpeak(fft_len, fft_peak_threshold) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((samp_rate/(fft_len*4), )) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(int(1/alpha), 1.0/int(1/alpha), int(4/alpha)) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(1/alpha), 1.0/int(1/alpha), int(4/alpha)) ################################################## # Connections ################################################## self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocksat_runtime_cfo_ctrl_0, 1)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocksat_runtime_cfo_ctrl_0, 2)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocksat_runtime_cfo_ctrl_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocksat_argpeak_0, 0), (self.blocksat_wrap_fft_index_0, 0)) self.connect((self.blocksat_exponentiate_const_cci_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blocksat_runtime_cfo_ctrl_0, 0), (self, 1)) self.connect((self.blocksat_wrap_fft_index_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocksat_argpeak_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self, 0)) self.connect((self, 0), (self.blocksat_exponentiate_const_cci_0, 0))
def __init__(self, rx_callback, options, num_channels): self.num_channels = num_channels#len(options.args.split(',')) gr.hier_block2.__init__(self, "receive_path", gr.io_signaturev(self.num_channels, self.num_channels, gen_multiple_ios(self.num_channels,1) ), gr.io_signaturev(self.num_channels, self.num_channels, gen_multiple_ios(self.num_channels,options.occupied_tones) )) #[gr.sizeof_gr_complex*options.occupied_tones,gr.sizeof_gr_complex*options.occupied_tones])) #,gr.sizeof_gr_complex*options.occupied_tones,]))#gr.sizeof_gr_complex*options.occupied_tones])) options = copy.copy(options) # make a copy so we can destructively modify self._verbose = options.verbose self._log = options.log self._rx_callback = rx_callback # this callback is fired when there's a packet available # receiver self.ofdm_rx = ofdm.ofdm_demod(options,self.num_channels,callback=self._rx_callback) # # Carrier Sensing Blocks # alpha = 0.001 # thresh = 30 # in dB, will have to adjust # self.probe = analog.probe_avg_mag_sqrd_c(thresh,alpha) # Make Connections output = 0 for p in range(self.num_channels): # Connect USRP to OFDM Demodulator self.connect((self,p), (self.ofdm_rx,p)) # Extra output from FFT Demod self.connect((self.ofdm_rx,p), (self,p)) # Connect probe to output of channel filter # self.connect((self.ofdm_rx,0), self.probe) # Connect equalized signals to output # self.connect((self.ofdm_rx,2), (self,1)) # self.connect((self.ofdm_rx,3), (self,2)) # Display some information about the setup if self._verbose: self._print_verbage()
def __init__(self, layer_segments=1, mode=3, constellation_size=4, rate=1): gr.hier_block2.__init__( self, "isdbt_channel_decoding", gr.io_signature( 1, 1, gr.sizeof_char * layer_segments * 96 * 2**(mode - 1)), gr.io_signaturev( 3, 3, [gr.sizeof_char * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Parameters ################################################## self.layer_segments = layer_segments self.mode = mode self.constellation_size = constellation_size self.rate = rate ################################################## # Variables ################################################## self.total_carriers = total_carriers = 2**(10 + mode) self.data_carriers = data_carriers = 13 * 96 * 2**(mode - 1) self.active_carriers = active_carriers = 13 * 108 * 2**(mode - 1) + 1 ################################################## # Blocks ################################################## self.isdbt_viterbi_decoder_0 = isdbt.viterbi_decoder( constellation_size, rate) self.isdbt_reed_solomon_dec_isdbt_0_0 = isdbt.reed_solomon_dec_isdbt() self.isdbt_energy_descrambler_0_0 = isdbt.energy_descrambler() self.isdbt_byte_deinterleaver_0_0 = isdbt.byte_deinterleaver() self.isdbt_bit_deinterleaver_0_0 = isdbt.bit_deinterleaver( mode, layer_segments, constellation_size) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_char * 1, 188) ################################################## # Connections ################################################## self.connect((self.blocks_vector_to_stream_0_0, 0), (self, 0)) self.connect((self.isdbt_bit_deinterleaver_0_0, 0), (self.isdbt_viterbi_decoder_0, 0)) self.connect((self.isdbt_byte_deinterleaver_0_0, 0), (self.isdbt_energy_descrambler_0_0, 0)) self.connect((self.isdbt_energy_descrambler_0_0, 0), (self.isdbt_reed_solomon_dec_isdbt_0_0, 0)) self.connect((self.isdbt_reed_solomon_dec_isdbt_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.isdbt_reed_solomon_dec_isdbt_0_0, 1), (self, 1)) self.connect((self.isdbt_viterbi_decoder_0, 0), (self.isdbt_byte_deinterleaver_0_0, 0)) self.connect((self.isdbt_viterbi_decoder_0, 1), (self, 2)) self.connect((self, 0), (self.isdbt_bit_deinterleaver_0_0, 0))
def __init__(self, max_freq_offset=10, guard=0.125, mode=3, snr=10, tmcc_print=False): gr.hier_block2.__init__( # self, "ISDB-T RF Channel Decoding", self, "isdbt_rf_channel_decoding", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(2, 2, [ gr.sizeof_gr_complex * 13 * 96 * 2**(mode - 1), gr.sizeof_gr_complex * (13 * 108 * 2**(mode - 1) + 1) ]), ) ################################################## # Parameters ################################################## self.max_freq_offset = max_freq_offset self.guard = guard self.mode = mode self.snr = snr self.tmcc_print = tmcc_print ################################################## # Variables ################################################## self.total_carriers = total_carriers = 2**(10 + mode) self.data_carriers = data_carriers = 13 * 96 * 2**(mode - 1) self.active_carriers = active_carriers = 13 * 108 * 2**(mode - 1) + 1 ################################################## # Blocks ################################################## self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(mode, tmcc_print) self.isdbt_sync_and_channel_estimaton_0 = isdbt.sync_and_channel_estimaton( total_carriers, active_carriers, max_freq_offset) self.isdbt_ofdm_sym_acquisition_0 = isdbt.ofdm_sym_acquisition( total_carriers, int(guard * total_carriers), snr) self.fft_vxx_0 = fft.fft_vcc(total_carriers, True, (window.rectangular(total_carriers)), True, 1) ################################################## # Connections ################################################## self.connect((self.fft_vxx_0, 0), (self.isdbt_sync_and_channel_estimaton_0, 0)) self.connect((self.isdbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0)) self.connect((self.isdbt_sync_and_channel_estimaton_0, 0), (self.isdbt_tmcc_decoder_0, 0)) self.connect((self.isdbt_sync_and_channel_estimaton_0, 1), (self, 1)) self.connect((self.isdbt_tmcc_decoder_0, 0), (self, 0)) self.connect((self, 0), (self.isdbt_ofdm_sym_acquisition_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Bit Error Rate", gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_char * 1]), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Variables ################################################## self._msgLength_config = ConfigParser.ConfigParser() self._msgLength_config.read("./configs/sdrConfig.txt") try: msgLength = self._msgLength_config.getint("main", "key") except: msgLength = 10000 self.msgLength = msgLength self._bits_per_byte_config = ConfigParser.ConfigParser() self._bits_per_byte_config.read("./configs/sdrConfig.txt") try: bits_per_byte = self._bits_per_byte_config.getint("main", "key") except: bits_per_byte = 8 self.bits_per_byte = bits_per_byte intdecim = 100000 if msgLength < intdecim: intdecim = msgLength ################################################## # Blocks ################################################## self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_byte) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (1.0 / msgLength, )) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdecim) ################################################## # Connections ################################################## self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 1), (self.blocks_xor_xx_0, 1)) self.connect((self, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0))
def __init__(self, filename, filesize=100e6): gr.hier_block2.__init__( self, "Ramdisk File Sink", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(4, 4, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Variables ################################################## mem = psutil.virtual_memory() self.filesize = int(min(mem.free - 500e6, filesize)) print "Actual file size: " + str(filesize) print "Set file size: " + str(self.filesize) self.filename = filename # Create RAMDISK subprocess.call(shlex.split("sudo mkdir /tmp/ramdisk")) subprocess.call( shlex.split("sudo mount -t tmpfs -o size=" + str(int(self.filesize)) + " none /tmp/ramdisk")) username = getpass.getuser() subprocess.call( shlex.split("sudo chown -R " + username + ":" + username + " /tmp/ramdisk")) ################################################## # Blocks ################################################## self.decim = blocks.keep_one_in_n(gr.sizeof_gr_complex * 1, int(self.filesize / 8 / 100)) self.file_meta_sink = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, "/tmp/ramdisk/capture.dat", 1, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.file_meta_sink.set_unbuffered(False) self.ctrl_progress = ctrl_progress(filename=filename, filesize=self.filesize, filesink=self.file_meta_sink) ################################################## # Connections ################################################## self.connect((self, 0), (self.file_meta_sink, 0)) self.connect((self, 0), (self.decim, 0)) self.connect((self.decim, 0), (self.ctrl_progress, 0)) self.connect((self.ctrl_progress, 0), (self, 0)) self.connect((self.ctrl_progress, 1), (self, 1)) self.connect((self.ctrl_progress, 2), (self, 2)) self.connect((self.ctrl_progress, 3), (self, 3))
def __init__(self, payload_len=96, sync_seq=[complex(1,0),complex(-1,0)], threshold=.8): gr.hier_block2.__init__(self, "generic_rx_path", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.threshold = threshold self.sync_seq = sync_seq self.sync_header_len = len(sync_seq) self.items_per_header_symbol = 1 self.payload_len = payload_len ################################################## # Variables ################################################## self.tag_len_name = tag_len_name = "packet_len" ################################################## # Blocks ################################################## self.frame_sync_0 = dctk.frame_sync (self.sync_seq, self.threshold) self.digital_header_payload_demux_0 = digital.header_payload_demux(self.sync_header_len, self.items_per_header_symbol, 0, tag_len_name, "", False, gr.sizeof_gr_complex) self.dctk_header_tag_generator_0 = dctk.header_tag_generator(self.sync_header_len, payload_len, tag_len_name) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, self.sync_header_len) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self, 0), (self.frame_sync_0, 0)) self.connect((self.blocks_delay_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.frame_sync_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_header_payload_demux_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.dctk_header_tag_generator_0, 0)) self.connect((self.frame_sync_0, 0), (self, 2)) self.connect((self.digital_header_payload_demux_0, 1), (self, 1)) self.connect((self.digital_header_payload_demux_0, 0), (self, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.dctk_header_tag_generator_0, "header_data", self.digital_header_payload_demux_0, "header_data")
def __init__(self, decay=0.001, samp_rate=48000, attack=0.1, Frequency=1200): gr.hier_block2.__init__( self, "Detectmarkspace", gr.io_signature(1, 1, gr.sizeof_float*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.decay = decay self.samp_rate = samp_rate self.attack = attack self.Frequency = Frequency ################################################## # Variables ################################################## self.Baud = Baud = 1200 ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 1, samp_rate, Baud, 0.35, samp_rate/Baud)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -Frequency, 1, 0) self.analog_agc2_xx_0 = analog.agc2_ff(attack, decay, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(1.0) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.blocks_complex_to_mag_0, 0))
def __init__(self, ts, factor, alpha, samp_rate, freqs): gr.hier_block2.__init__( self, "freq_timing_estimator_hier", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.ts = ts self.factor = factor self.alpha = alpha self.samp_rate = samp_rate self.freqs = freqs self.n = n = len(freqs) ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self, audio_rate=48000, samp_rate=512e3): gr.hier_block2.__init__( self, "MPX Demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(5, 5, [gr.sizeof_char*1, gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.audio_rate = audio_rate self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.rds_demod_0 = rds_demod( samp_rate=samp_rate, ) self.fm_audio_demod_0 = fm_audio_demod( audio_rate=audio_rate, samp_rate=samp_rate, ) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.band_pass_filter_0_1 = filter.fir_filter_ccf(1, firdes.band_pass( 1, samp_rate, 19e3-500, 19e3+500, 1e3, firdes.WIN_HAMMING, 6.76)) self.analog_pll_refout_cc_0 = analog.pll_refout_cc(2 * math.pi * 8 / samp_rate, 2 * math.pi * (19000+4) / samp_rate, 2 * math.pi * (19000-4) / samp_rate) ################################################## # Connections ################################################## self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_multiply_xx_0_0, 2)) self.connect((self.band_pass_filter_0_1, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fm_audio_demod_0, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.rds_demod_0, 0)) self.connect((self.fm_audio_demod_0, 0), (self, 1)) self.connect((self.fm_audio_demod_0, 1), (self, 2)) self.connect((self.fm_audio_demod_0, 2), (self, 3)) self.connect((self, 0), (self.band_pass_filter_0_1, 0)) self.connect((self, 0), (self.fm_audio_demod_0, 0)) self.connect((self, 0), (self.rds_demod_0, 1)) self.connect((self.rds_demod_0, 0), (self, 0)) self.connect((self.rds_demod_0, 1), (self, 4))
def __init__(self, fftSize=1024, windowType="blackmanharris", iirAlpha=2.0**-3): gr.hier_block2.__init__( self, "LogMagFFT", gr.io_signature(1, 1, gr.sizeof_gr_complex * fftSize), gr.io_signaturev( 2, 2, [gr.sizeof_float * fftSize, gr.sizeof_gr_complex * fftSize]), ) ################################################## # Parameters ################################################## self.fftSize = fftSize self.iirAlpha = iirAlpha self.windowType = windowType ################################################## # Variables ################################################## self.fftWindow = fftWindow = scipy.signal.get_window( windowType, fftSize) ################################################## # Blocks ################################################## self.singlePoleIIR = filter.single_pole_iir_filter_ff( iirAlpha, fftSize) self.nLog10 = CyberRadio.vector_nlog10_ff(10, fftSize, 0) self.fwdFFT = fft.fft_vcc(fftSize, True, (fftWindow / numpy.sum(fftWindow)), True, 1) self.compToMagSq = blocks.complex_to_mag_squared(fftSize) ################################################## # Connections ################################################## self.connect((self, 0), (self.fwdFFT, 0)) self.connect((self.fwdFFT, 0), (self, 1)) self.connect((self.fwdFFT, 0), (self.compToMagSq, 0)) self.connect((self.compToMagSq, 0), (self.singlePoleIIR, 0)) self.connect((self.singlePoleIIR, 0), (self.nLog10, 0)) self.connect((self.nLog10, 0), (self, 0))
def __init__(self, options): config = station_configuration() dsubc = config.data_subcarriers gr.hier_block2.__init__( self, "static_tx_control", gr.io_signature(0, 0, 0), gr.io_signaturev( 4, -1, [ gr.sizeof_short, # ID gr.sizeof_short, # Multiplex control stream gr.sizeof_char * dsubc, # Bit Map gr.sizeof_float * dsubc, # Power Map gr.sizeof_int ])) # Bit count per frame self.control = ctrl = static_control(dsubc, config.frame_id_blocks, config.frame_data_blocks, options) id_out = (self, 0) mux_out = (self, 1) bitmap_out = (self, 2) powmap_out = (self, 3) self.cur_port = 4 ## ID Source (root) id_src = self._id_source = blocks.vector_source_s([ctrl.static_id], True) self.connect(id_src, id_out) ## Multiplex Source mux_src = self._multiplex_source = blocks.vector_source_s( ctrl.mux_stream, True) self.connect(mux_src, mux_out) ## Map Source map_src = blocks.vector_source_b(ctrl.rmod_stream, True, dsubc) self.connect(map_src, bitmap_out) ## Power Allocation Source pa_src = blocks.vector_source_f(ctrl.pow_stream, True, dsubc) self.connect(pa_src, powmap_out)
def __init__(self, layer_segments=1, mode=3, constellation_size=4, rate=1): gr.hier_block2.__init__( self, "isdbt_channel_decoding", gr.io_signature(1, 1, gr.sizeof_char*layer_segments*96*2**(mode-1)), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.layer_segments = layer_segments self.mode = mode self.constellation_size = constellation_size self.rate = rate ################################################## # Variables ################################################## self.total_carriers = total_carriers = 2**(10+mode) self.data_carriers = data_carriers = 13*96*2**(mode-1) self.active_carriers = active_carriers = 13*108*2**(mode-1)+1 ################################################## # Blocks ################################################## self.isdbt_viterbi_decoder_0 = isdbt.viterbi_decoder(constellation_size, rate) self.isdbt_reed_solomon_dec_isdbt_0_0 = isdbt.reed_solomon_dec_isdbt() self.isdbt_energy_descrambler_0_0 = isdbt.energy_descrambler() self.isdbt_byte_deinterleaver_0_0 = isdbt.byte_deinterleaver() self.isdbt_bit_deinterleaver_0_0 = isdbt.bit_deinterleaver(mode, layer_segments, constellation_size) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_char*1, 188) ################################################## # Connections ################################################## self.connect((self.blocks_vector_to_stream_0_0, 0), (self, 0)) self.connect((self.isdbt_bit_deinterleaver_0_0, 0), (self.isdbt_viterbi_decoder_0, 0)) self.connect((self.isdbt_byte_deinterleaver_0_0, 0), (self.isdbt_energy_descrambler_0_0, 0)) self.connect((self.isdbt_energy_descrambler_0_0, 0), (self.isdbt_reed_solomon_dec_isdbt_0_0, 0)) self.connect((self.isdbt_reed_solomon_dec_isdbt_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.isdbt_reed_solomon_dec_isdbt_0_0, 1), (self, 1)) self.connect((self.isdbt_viterbi_decoder_0, 0), (self.isdbt_byte_deinterleaver_0_0, 0)) self.connect((self.isdbt_viterbi_decoder_0, 1), (self, 2)) self.connect((self, 0), (self.isdbt_bit_deinterleaver_0_0, 0))
def __init__(self, fft_len): gr.hier_block2.__init__(self, "FFT Peak", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1])) ''' Constructor @param fft_len - ''' ################################################## # Parameters ################################################## self.fft_len = fft_len ################################################## # Blocks ################################################## self.fft = fft.fft_vcc(fft_len, True, (window.blackmanharris(fft_len)), False, 1) self.v2s = blocks.vector_to_stream(gr.sizeof_float*1, fft_len) self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_len) self.s2f = blocks.short_to_float(1, 1) self.repeat = blocks.repeat(gr.sizeof_short*1, fft_len) self.null_0 = blocks.null_sink(gr.sizeof_float*1) self.null_1 = blocks.null_sink(gr.sizeof_short*1) self.c2mag = blocks.complex_to_mag(fft_len) self.argmax = blocks.argmax_fs(fft_len) ################################################## # Connections ################################################## self.connect((self.argmax, 1), (self.null_1, 0)) self.connect((self.argmax, 0), (self.repeat, 0)) self.connect((self.c2mag, 0), (self.argmax, 0)) self.connect((self.c2mag, 0), (self.v2s, 0)) self.connect((self.repeat, 0), (self.s2f, 0)) self.connect((self.s2f, 0), (self, 0)) self.connect((self.s2v, 0), (self.fft, 0)) self.connect((self.v2s, 0), (self.null_0, 0)) self.connect((self.v2s, 0), (self, 1)) self.connect((self.fft, 0), (self.c2mag, 0)) self.connect((self, 0), (self.s2v, 0))
def __init__(self): gr.hier_block2.__init__( self, "Bit Error Rate", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_char*1]), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Variables ################################################## self._msgLength_config = ConfigParser.ConfigParser() self._msgLength_config.read("./configs/sdrConfig.txt") try: msgLength = self._msgLength_config.getint("main", "key") except: msgLength = 10000 self.msgLength = msgLength self._bits_per_byte_config = ConfigParser.ConfigParser() self._bits_per_byte_config.read("./configs/sdrConfig.txt") try: bits_per_byte = self._bits_per_byte_config.getint("main", "key") except: bits_per_byte = 8 self.bits_per_byte = bits_per_byte intdecim = 100000 if msgLength < intdecim: intdecim = msgLength ################################################## # Blocks ################################################## self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_byte) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.0/msgLength, )) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdecim) ################################################## # Connections ################################################## self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 1), (self.blocks_xor_xx_0, 1)) self.connect((self, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "SDR Transmitter", gr.io_signature(0, 0, 0), gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self._mLength_config = ConfigParser.ConfigParser() self._mLength_config.read("./configs/sdrConfig.txt") try: mLength = self._mLength_config.getint("main", "key") except: mLength = 10000 self.mLength = mLength ################################################## # Blocks ################################################## self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=False, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, mLength)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self, 0)) self.connect((self.digital_psk_mod_0, 0), (self, 1))
def __init__(self, options): config = station_configuration() dsubc = config.data_subcarriers gr.hier_block2.__init__( self, "corba_control", gr.io_signature(0, 0, 0), gr.io_signaturev( 4, -1, [ gr.sizeof_short, # ID gr.sizeof_short, # Multiplex control stream gr.sizeof_char * dsubc, # Bit Map gr.sizeof_int ])) # Bit count per frame id_out = (self, 0) mux_out = (self, 1) bitmap_out = (self, 2) self.cur_port = 3 self.ns_ip = ns_ip = options.nameservice_ip self.ns_port = ns_port = options.nameservice_port self.evchan = evchan = std_event_channel self.coding = coding = options.coding ## ID Source (root) id_src = self._id_source = corba_id_src(evchan, ns_ip, ns_port) self.connect(id_src, id_out) ## Multiplex Source mux_src = self._multiplex_source = corba_multiplex_src_ss( evchan, ns_ip, ns_port, coding) self.connect(id_src, mux_src, mux_out) ## Map Source map_src = self._bitmap_source = corba_bitmap_src( dsubc, 0, evchan, ns_ip, ns_port) self.connect(id_src, map_src, bitmap_out)
def __init__(self, options): config = station_configuration() dsubc = config.data_subcarriers gr.hier_block2.__init__(self, "static_tx_control", gr.io_signature (0,0,0), gr.io_signaturev(4,-1,[gr.sizeof_short, # ID gr.sizeof_short, # Multiplex control stream gr.sizeof_char*dsubc, # Bit Map gr.sizeof_float*dsubc, # Power Map gr.sizeof_int ])) # Bit count per frame self.control = ctrl = static_control(dsubc,config.frame_id_blocks, config.frame_data_blocks,options) id_out = (self,0) mux_out = (self,1) bitmap_out = (self,2) powmap_out = (self,3) self.cur_port = 4 ## ID Source (root) id_src = self._id_source = blocks.vector_source_s([ctrl.static_id],True) self.connect(id_src,id_out) ## Multiplex Source mux_src = self._multiplex_source = blocks.vector_source_s(ctrl.mux_stream,True) self.connect(mux_src,mux_out) ## Map Source map_src = blocks.vector_source_b(ctrl.rmod_stream, True, dsubc) self.connect(map_src,bitmap_out) ## Power Allocation Source pa_src = blocks.vector_source_f(ctrl.pow_stream,True,dsubc) self.connect(pa_src,powmap_out)
def __init__(self, max_freq_offset=10, guard=0.125, mode=3, snr=10, tmcc_print=False): gr.hier_block2.__init__( # self, "ISDB-T RF Channel Decoding", self, "isdbt_rf_channel_decoding", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*13*96*2**(mode-1), gr.sizeof_gr_complex*(13*108*2**(mode-1)+1)]), ) ################################################## # Parameters ################################################## self.max_freq_offset = max_freq_offset self.guard = guard self.mode = mode self.snr = snr self.tmcc_print = tmcc_print ################################################## # Variables ################################################## self.total_carriers = total_carriers = 2**(10+mode) self.data_carriers = data_carriers = 13*96*2**(mode-1) self.active_carriers = active_carriers = 13*108*2**(mode-1)+1 ################################################## # Blocks ################################################## self.isdbt_tmcc_decoder_0 = isdbt.tmcc_decoder(mode, tmcc_print) self.isdbt_sync_and_channel_estimaton_0 = isdbt.sync_and_channel_estimaton(total_carriers, active_carriers, max_freq_offset) self.isdbt_ofdm_sym_acquisition_0 = isdbt.ofdm_sym_acquisition(total_carriers, int(guard*total_carriers), snr) self.fft_vxx_0 = fft.fft_vcc(total_carriers, True, (window.rectangular(total_carriers)), True, 1) ################################################## # Connections ################################################## self.connect((self.fft_vxx_0, 0), (self.isdbt_sync_and_channel_estimaton_0, 0)) self.connect((self.isdbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0)) self.connect((self.isdbt_sync_and_channel_estimaton_0, 0), (self.isdbt_tmcc_decoder_0, 0)) self.connect((self.isdbt_sync_and_channel_estimaton_0, 1), (self, 1)) self.connect((self.isdbt_tmcc_decoder_0, 0), (self, 0)) self.connect((self, 0), (self.isdbt_ofdm_sym_acquisition_0, 0))
def __init__(self, sensingprocessorLambda=0): gr.hier_block2.__init__( self, "Sensing Platform - Central Office", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) self.message_port_register_hier_in("msg_harddecision") ################################################## # Parameters ################################################## self.sensingprocessorLambda = sensingprocessorLambda ################################################## # Blocks ################################################## self.sensing_eigenvalue_cc_0 = sensing.eigenvalue_cc() self.sensing_decisionmaker_ff_0 = sensing.decisionmaker_ff() self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0, )) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, sensingprocessorLambda) ################################################## # Connections ################################################## self.msg_connect((self.sensing_decisionmaker_ff_0, 'hard_decision'), (self, 'msg_harddecision')) self.connect((self.analog_const_source_x_0_0, 0), (self.sensing_decisionmaker_ff_0, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.sensing_eigenvalue_cc_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.sensing_decisionmaker_ff_0, 0)) self.connect((self, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.sensing_eigenvalue_cc_0, 0)) self.connect((self.sensing_decisionmaker_ff_0, 0), (self, 0)) self.connect((self.sensing_decisionmaker_ff_0, 1), (self, 1)) self.connect((self.sensing_eigenvalue_cc_0, 1), (self.blocks_add_xx_0_0, 1)) self.connect((self.sensing_eigenvalue_cc_0, 0), (self.blocks_add_xx_0_0, 0))
def __init__(self, options): config = station_configuration() dsubc = config.data_subcarriers gr.hier_block2.__init__(self, "corba_control", gr.io_signature (0,0,0), gr.io_signaturev(4,-1,[gr.sizeof_short, # ID gr.sizeof_short, # Multiplex control stream gr.sizeof_char*dsubc, # Bit Map gr.sizeof_int ])) # Bit count per frame id_out = (self,0) mux_out = (self,1) bitmap_out = (self,2) self.cur_port = 3 self.ns_ip = ns_ip = options.nameservice_ip self.ns_port = ns_port = options.nameservice_port self.evchan = evchan = std_event_channel self.coding = coding = options.coding ## ID Source (root) id_src = self._id_source = corba_id_src(evchan,ns_ip,ns_port) self.connect(id_src,id_out) ## Multiplex Source mux_src = self._multiplex_source = corba_multiplex_src_ss(evchan,ns_ip,ns_port,coding) self.connect(id_src,mux_src,mux_out) ## Map Source map_src = self._bitmap_source = corba_bitmap_src(dsubc, 0,evchan,ns_ip,ns_port) self.connect(id_src,map_src,bitmap_out)
def __init__(self, fft_tam=64): gr.hier_block2.__init__( self, "SynDet", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_char * 1]), ) ################################################## # Parameters ################################################## self.fft_tam = fft_tam ################################################## # Blocks ################################################## self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_tam, fft_tam / 4, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_tam + fft_tam / 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_tam) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self, 1)) self.connect((self, 0), (self.blocks_delay_0, 0)) self.connect((self, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))
def __init__(self, alpha=0.001): gr.hier_block2.__init__( self, "amp_var_est_hier", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.alpha = alpha ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0_0_1_0 = filter.single_pole_iir_filter_cc(alpha, 1) self.single_pole_iir_filter_xx_0_0_1 = filter.single_pole_iir_filter_ff(alpha, 1) self.blocks_sub_xx_0_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0_0_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.single_pole_iir_filter_xx_0_0_1_0, 0)) self.connect((self.single_pole_iir_filter_xx_0_0_1, 0), (self.blocks_sub_xx_0_0, 0)) self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.single_pole_iir_filter_xx_0_0_1_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_sub_xx_0_0, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self, 1))
def __init__(self, fft_size=64, occupied_carriers=(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),), pilot_carriers=((-21, -7, 7, 21,),), pilot_symbols=((1, 1, 1, -1,),)): gr.hier_block2.__init__( self, "PilotSymbols", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]), gr.io_signature(1, 1, gr.sizeof_gr_complex*64), ) ################################################## # Parameters ################################################## self.fft_size = fft_size self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols ################################################## # Variables ################################################## self.word_sync2 = word_sync2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.word_sync1 = word_sync1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.paquete_tam = paquete_tam = 96 self.length_tag_key = length_tag_key = "paquete_tam" ################################################## # Blocks ################################################## self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(fft_size, occupied_carriers, pilot_carriers, pilot_symbols, (word_sync1,word_sync2), length_tag_key) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) ################################################## # Connections ################################################## self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self, 0)) self.connect((self, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self, 1), (self.blocks_tagged_stream_mux_0, 1))
def __init__(self, seq1, seq2, factor, alpha, samp_rate, freqs): """ Description: This block is functionally equivalent to the frequency_timing_estimator block, except from the fact that each filter is matched to a sequence that can be written as the kronecker product of seq1 and seq2. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. factor takes values in (0,1). alpha: the smoothing factor of a moving average filter used in the peak detector takeng values in (0,1). samp_rate: the sample rate of the system, which is used in the kronecker_filter. freqs: the vector of center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.samp_rate = samp_rate self.freqs = freqs self.n = n = len(freqs) ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): self._filter[i]= cdma.kronecker_filter(seq1,seq2,samp_rate,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, (numpy.conjugate(self.ts[::-1])), self.freqs[i], self.samp_rate) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = blocks.peak_detector_fb(self.factor, self.factor, 0, self.alpha) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__( self, verbose_mode=True, radio_device_name="/dev/ndr47x", radio_baud_rate=921600, gig_iface_to_use="eth0", coherent_mode=0, num_tuners=1, tuner1_param_list=[False, 900e6, 0], tuner2_param_list=[False, 900e6, 0], tuner3_param_list=[False, 900e6, 0], tuner4_param_list=[False, 900e6, 0], tuner5_param_list=[False, 900e6, 0], tuner6_param_list=[False, 900e6, 0], num_wbddcs=1, wbddc1_param_list=[40001, 0, 0, False, 0e6], wbddc2_param_list=[40002, 0, 0, False, 0e6], wbddc3_param_list=[40003, 0, 0, False, 0e6], wbddc4_param_list=[40004, 0, 0, False, 0e6], wbddc5_param_list=[40005, 0, 0, False, 0e6], wbddc6_param_list=[40006, 0, 0, False, 0e6], tagged=False, ): gr.hier_block2.__init__( self, "[CyberRadio] NDR304 Source", gr.io_signature(0, 0, 0), gr.io_signaturev( (6 if coherent_mode & 0x02 > 0 else num_wbddcs) + 1, (6 if coherent_mode & 0x02 > 0 else num_wbddcs) + 1, [gr.sizeof_char * 1] + (6 if coherent_mode & 0x02 > 0 else num_wbddcs) * [gr.sizeof_gr_complex * 1], ), ) self.verbose_mode = verbose_mode self.radio_device_name = radio_device_name self.radio_baud_rate = radio_baud_rate self.gig_iface_to_use = gig_iface_to_use self.coherent_mode = coherent_mode self.tuners_coherent = self.coherent_mode & 0x01 > 0 self.ddcs_coherent = self.coherent_mode & 0x02 > 0 self.udp_host_name = CyberRadioDriver.getInterfaceAddresses(self.gig_iface_to_use)[1] self.num_tuners = num_tuners self.tuner1_param_list = tuner1_param_list if not self.tuners_coherent: self.tuner2_param_list = tuner2_param_list self.tuner3_param_list = tuner3_param_list self.tuner4_param_list = tuner4_param_list self.tuner5_param_list = tuner5_param_list self.tuner6_param_list = tuner6_param_list self.num_wbddcs = num_wbddcs self.wbddc1_param_list = wbddc1_param_list if not self.ddcs_coherent: self.wbddc2_param_list = wbddc2_param_list self.wbddc3_param_list = wbddc3_param_list self.wbddc4_param_list = wbddc4_param_list self.wbddc5_param_list = wbddc5_param_list self.wbddc6_param_list = wbddc6_param_list self.tagged = tagged self.CyberRadio_file_like_object_source_0 = CyberRadio.file_like_object_source() self.connect((self.CyberRadio_file_like_object_source_0, 0), (self, 0)) self.CyberRadio_NDR_driver_interface_0 = CyberRadio.NDR_driver_interface( radio_type="ndr304", verbose=verbose_mode, log_file=self.CyberRadio_file_like_object_source_0, connect_mode="tty", dev_name=radio_device_name, baud_rate=radio_baud_rate, ) self.vita_tail_size = self.CyberRadio_NDR_driver_interface_0.getVitaTailSize() self.vita_payload_size = self.CyberRadio_NDR_driver_interface_0.getVitaPayloadSize() self.vita_header_size = self.CyberRadio_NDR_driver_interface_0.getVitaHeaderSize() self.iq_swapped = self.CyberRadio_NDR_driver_interface_0.isIqSwapped() self.byte_swapped = self.CyberRadio_NDR_driver_interface_0.isByteswapped() self._set_coherent_mode(self.coherent_mode) self._set_udp_dest_info() if self.num_tuners >= 1: self._set_tuner_param_list(1, tuner1_param_list) if not self.tuners_coherent: if self.num_tuners >= 2: self._set_tuner_param_list(2, tuner2_param_list) if self.num_tuners >= 3: self._set_tuner_param_list(3, tuner3_param_list) if self.num_tuners >= 4: self._set_tuner_param_list(4, tuner4_param_list) if self.num_tuners >= 5: self._set_tuner_param_list(5, tuner5_param_list) if self.num_tuners >= 6: self._set_tuner_param_list(6, tuner6_param_list) self.wbddc_sources = {} if self.num_wbddcs >= 1: self.CyberRadio_vita_iq_source_wbddc_1 = self._get_configured_wbddc(1, wbddc1_param_list) if self.ddcs_coherent: self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 0), (self, 1)) self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 1), (self, 2)) self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 2), (self, 3)) self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 3), (self, 4)) self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 4), (self, 5)) self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 5), (self, 6)) else: self.connect((self.CyberRadio_vita_iq_source_wbddc_1, 0), (self, 1)) self.wbddc_sources[1] = self.CyberRadio_vita_iq_source_wbddc_1 if not self.ddcs_coherent: if self.num_wbddcs >= 2: self.CyberRadio_vita_iq_source_wbddc_2 = self._get_configured_wbddc(2, wbddc2_param_list) self.connect((self.CyberRadio_vita_iq_source_wbddc_2, 0), (self, 2)) self.wbddc_sources[2] = self.CyberRadio_vita_iq_source_wbddc_2 if self.num_wbddcs >= 3: self.CyberRadio_vita_iq_source_wbddc_3 = self._get_configured_wbddc(3, wbddc3_param_list) self.connect((self.CyberRadio_vita_iq_source_wbddc_3, 0), (self, 3)) self.wbddc_sources[3] = self.CyberRadio_vita_iq_source_wbddc_3 if self.num_wbddcs >= 4: self.CyberRadio_vita_iq_source_wbddc_4 = self._get_configured_wbddc(4, wbddc4_param_list) self.connect((self.CyberRadio_vita_iq_source_wbddc_4, 0), (self, 4)) self.wbddc_sources[4] = self.CyberRadio_vita_iq_source_wbddc_4 if self.num_wbddcs >= 5: self.CyberRadio_vita_iq_source_wbddc_5 = self._get_configured_wbddc(5, wbddc5_param_list) self.connect((self.CyberRadio_vita_iq_source_wbddc_5, 0), (self, 5)) self.wbddc_sources[5] = self.CyberRadio_vita_iq_source_wbddc_5 if self.num_wbddcs >= 6: self.CyberRadio_vita_iq_source_wbddc_6 = self._get_configured_wbddc(6, wbddc6_param_list) self.connect((self.CyberRadio_vita_iq_source_wbddc_6, 0), (self, 6)) self.wbddc_sources[6] = self.CyberRadio_vita_iq_source_wbddc_6
def __init__( self, options, log = False ): ## Read configuration config = station_configuration() fft_length = config.fft_length cp_length = config.cp_length block_header = config.training_data data_subc = config.data_subcarriers virtual_subc = config.virtual_subcarriers total_subc = config.subcarriers block_length = config.block_length frame_length = config.frame_length dc_null = config.dc_null L = block_header.mm_periodic_parts ## Set Input/Output signature gr.hier_block2.__init__( self, "ofdm_inner_receiver", gr.io_signature( 1, 1, gr.sizeof_gr_complex ), gr.io_signaturev( 4, 4, [gr.sizeof_gr_complex * total_subc, # OFDM blocks gr.sizeof_char, # Frame start gr.sizeof_float * total_subc, gr.sizeof_float] ) ) # Normalized |CTF|^2 ## Input and output ports self.input = rx_input = self out_ofdm_blocks = ( self, 0 ) out_frame_start = ( self, 1 ) out_disp_ctf = ( self, 2 ) out_disp_cfo = ( self, 3 ) ## pre-FFT processing if options.ideal is False and options.ideal2 is False: if options.old_receiver is False: ## Compute autocorrelations for S&C preamble ## and cyclic prefix self._sc_metric = sc_metric = autocorrelator( fft_length/2, fft_length/2 ) self._gi_metric = gi_metric = autocorrelator( fft_length, cp_length ) self.connect( rx_input, sc_metric ) self.connect( rx_input, gi_metric ) ## Sync. Output contains OFDM blocks sync = ofdm.time_sync( fft_length, cp_length ) self.connect( rx_input, ( sync, 0 ) ) self.connect( sc_metric, ( sync, 1 ) ) self.connect( gi_metric, ( sync, 2 ) ) ofdm_blocks = ( sync, 0 ) frame_start = ( sync, 1 ) #log_to_file( self, ( sync, 1 ), "data/peak_detector.char" ) else: #Testing old/new metric self.tm = schmidl.recursive_timing_metric(fft_length) self.connect( self.input, self.tm) #log_to_file( self, self.tm, "data/rec_sc_metric_ofdm.float" ) timingmetric_shift = -2#int(-cp_length/4)# 0#-2 #int(-cp_length * 0.8) tmfilter = filter.fft_filter_fff(1, [1./cp_length]*cp_length) self.connect( self.tm, tmfilter ) self.tm = tmfilter self._pd_thres = 0.3 self._pd_lookahead = fft_length / 2 # empirically chosen peak_detector = ofdm.peak_detector_02_fb(self._pd_lookahead, self._pd_thres) self.connect(self.tm, peak_detector) #log_to_file( self, peak_detector, "data/rec_peak_detector.char" ) frame_start = [0]*frame_length frame_start[0] = 1 frame_start = self.frame_trigger_old = blocks.vector_source_b(frame_start,True) delayed_timesync = blocks.delay(gr.sizeof_char, (frame_length-1)*block_length + timingmetric_shift) self.connect( peak_detector, delayed_timesync ) self.block_sampler = ofdm.vector_sampler(gr.sizeof_gr_complex,block_length*frame_length) self.discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[]) self.connect(self.input,self.block_sampler) self.connect(delayed_timesync,(self.block_sampler,1)) # TODO: dynamic solution vt2s = blocks.vector_to_stream(gr.sizeof_gr_complex*block_length, frame_length) self.connect(self.block_sampler,vt2s,self.discard_cp) #terminate_stream(self,ofdm_blocks) ofdm_blocks = self.discard_cp # else: # serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length) # discard_cp = ofdm.vector_mask(block_length,cp_length,fft_length,[]) # ofdm_blocks = discard_cp # self.connect( rx_input, serial_to_parallel, discard_cp ) # frame_start = [0]*frame_length # frame_start[0] = 1 # frame_start = blocks.vector_source_b(frame_start,True) # # print "Disabled time synchronization stage" ## Compute autocorrelations for S&C preamble ## and cyclic prefix #log_to_file( self, sc_metric, "data/sc_metric_ofdm.float" ) #log_to_file(self, frame_start, "data/frame_start.compl") # log_to_file(self,ofdm_blocks,"data/ofdm_blocks_original.compl") if options.disable_time_sync or options.ideal or options.ideal2: if options.ideal is False and options.ideal2 is False: terminate_stream(self, ofdm_blocks) terminate_stream(self, frame_start) serial_to_parallel = blocks.stream_to_vector(gr.sizeof_gr_complex,block_length) discard_cp = ofdm.vector_mask_dc_null(block_length,cp_length,fft_length,dc_null, []) ofdm_blocks = discard_cp self.connect( rx_input, serial_to_parallel, discard_cp ) frame_start = [0]*frame_length frame_start[0] = 1 frame_start = blocks.vector_source_b(frame_start,True) print "Disabled time synchronization stage" print"\t\t\t\t\tframe_length = ",frame_length if options.ideal is False and options.ideal2 is False: ## Extract preamble, feed to Morelli & Mengali frequency offset estimator assert( block_header.mm_preamble_pos == 0 ) morelli_foe = ofdm.mm_frequency_estimator( fft_length, L,1,0 ) sampler_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * fft_length, 1 ) self.connect( ofdm_blocks, ( sampler_preamble, 0 ) ) self.connect( frame_start, ( sampler_preamble, 1 ) ) self.connect( sampler_preamble, morelli_foe ) freq_offset = morelli_foe ## Adaptive LMS FIR filtering of frequency offset lms_fir = ofdm.lms_fir_ff( 20, 1e-3 ) # TODO: verify parameter choice self.connect( freq_offset, lms_fir ) freq_offset = lms_fir #self.zmq_probe_freqoff = zeromq.pub_sink(gr.sizeof_float, 1, "tcp://*:5557") self.connect(lms_fir, blocks.keep_one_in_n(gr.sizeof_float,20) ,out_disp_cfo) else: self.connect(blocks.vector_source_f ([1]) ,out_disp_cfo) #log_to_file(self, lms_fir, "data/lms_fir.float") if options.disable_freq_sync or options.ideal or options.ideal2: if options.ideal is False and options.ideal2 is False: terminate_stream(self, freq_offset) freq_offset = blocks.vector_source_f([0.0],True) print "Disabled frequency synchronization stage" if options.ideal is False and options.ideal2 is False: ## Correct frequency shift, feed-forward structure frequency_shift = ofdm.frequency_shift_vcc( fft_length, -1.0/fft_length, cp_length ) self.connect( ofdm_blocks, ( frequency_shift, 0 ) ) self.connect( freq_offset, ( frequency_shift, 1 ) ) self.connect( frame_start, ( frequency_shift, 2 ) ) ofdm_blocks = frequency_shift ## FFT fft = fft_blocks.fft_vcc( fft_length, True, [], True ) self.connect( ofdm_blocks, fft ) ofdm_blocks = fft #log_to_file( self, fft, "data/compen.float" ) ## Remove virtual subcarriers if fft_length > data_subc: subcarrier_mask = ofdm.vector_mask_dc_null( fft_length, virtual_subc/2, total_subc, dc_null, [] ) self.connect( ofdm_blocks, subcarrier_mask ) ofdm_blocks = subcarrier_mask #log_to_file(self, ofdm_blocks, "data/vec_mask.compl") ## Least Squares estimator for channel transfer function (CTF) if options.logcir: log_to_file( self, ofdm_blocks, "data/OFDM_Blocks.compl" ) inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ block_header.channel_estimation_pilot[0] ] ) inv_preamble_fd = numpy.concatenate([inv_preamble_fd[:total_subc/2],inv_preamble_fd[total_subc/2+dc_null:]]) #print "Channel estimation pilot: ", inv_preamble_fd inv_preamble_fd = 1. / inv_preamble_fd LS_channel_estimator0 = ofdm.multiply_const_vcc( list( inv_preamble_fd ) ) self.connect( ofdm_blocks, LS_channel_estimator0, gr.null_sink(gr.sizeof_gr_complex*total_subc)) log_to_file( self, LS_channel_estimator0, "data/OFDM_Blocks_eq.compl" ) ## post-FFT processing ## extract channel estimation preamble from frame if options.ideal is False and options.ideal2 is False: chest_pre_trigger = blocks.delay( gr.sizeof_char, 1) sampled_chest_preamble = ofdm.vector_sampler( gr.sizeof_gr_complex * total_subc, 1) self.connect( frame_start, chest_pre_trigger ) self.connect( chest_pre_trigger, ( sampled_chest_preamble, 1 ) ) self.connect( ofdm_blocks, ( sampled_chest_preamble, 0 ) ) ## Least Squares estimator for channel transfer function (CTF) inv_preamble_fd = numpy.array( block_header.pilotsym_fd[ block_header.channel_estimation_pilot[0] ] ) inv_preamble_fd = numpy.concatenate([inv_preamble_fd[:total_subc/2],inv_preamble_fd[total_subc/2+dc_null:]]) #print "Channel estimation pilot: ", inv_preamble_fd inv_preamble_fd = 1. / inv_preamble_fd LS_channel_estimator = ofdm.multiply_const_vcc( list( inv_preamble_fd ) ) self.connect( sampled_chest_preamble, LS_channel_estimator ) estimated_CTF = LS_channel_estimator if options.logcir: log_to_file( self, sampled_chest_preamble, "data/PREAM.compl" ) if not options.disable_ctf_enhancer: if options.logcir: ifft1 = fft_blocks.fft_vcc(total_subc,False,[],True) self.connect( estimated_CTF, ifft1,gr.null_sink(gr.sizeof_gr_complex*total_subc)) summ1 = ofdm.vector_sum_vcc(total_subc) c2m =gr.complex_to_mag(total_subc) self.connect( estimated_CTF,summ1 ,gr.null_sink(gr.sizeof_gr_complex)) self.connect( estimated_CTF, c2m,gr.null_sink(gr.sizeof_float*total_subc)) log_to_file( self, ifft1, "data/CIR1.compl" ) log_to_file( self, summ1, "data/CTFsumm1.compl" ) log_to_file( self, estimated_CTF, "data/CTF1.compl" ) log_to_file( self, c2m, "data/CTFmag1.float" ) ## MSE enhancer ctf_mse_enhancer = ofdm.CTF_MSE_enhancer( total_subc, cp_length + cp_length) self.connect( estimated_CTF, ctf_mse_enhancer ) # log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer_original.compl") #ifft3 = fft_blocks.fft_vcc(total_subc,False,[],True) #null_noise = ofdm.noise_nulling(total_subc, cp_length + cp_length) #ctf_mse_enhancer = fft_blocks.fft_vcc(total_subc,True,[],True) #ctf_mse_enhancer = ofdm.vector_mask( fft_length, virtual_subc/2, # total_subc, [] ) #self.connect( estimated_CTF, ifft3,null_noise,ctf_mse_enhancer ) estimated_CTF = ctf_mse_enhancer print "Disabled CTF MSE enhancer" if options.logcir: ifft2 = fft_blocks.fft_vcc(total_subc,False,[],True) self.connect( estimated_CTF, ifft2,gr.null_sink(gr.sizeof_gr_complex*total_subc)) summ2 = ofdm.vector_sum_vcc(total_subc) c2m2 =gr.complex_to_mag(total_subc) self.connect( estimated_CTF,summ2 ,gr.null_sink(gr.sizeof_gr_complex)) self.connect( estimated_CTF, c2m2,gr.null_sink(gr.sizeof_float*total_subc)) log_to_file( self, ifft2, "data/CIR2.compl" ) log_to_file( self, summ2, "data/CTFsumm2.compl" ) log_to_file( self, estimated_CTF, "data/CTF2.compl" ) log_to_file( self, c2m2, "data/CTFmag2.float" ) ## Postprocess the CTF estimate ## CTF -> inverse CTF (for equalizer) ## CTF -> norm |.|^2 (for CTF display) ctf_postprocess = ofdm.postprocess_CTF_estimate( total_subc ) self.connect( estimated_CTF, ctf_postprocess ) inv_estimated_CTF = ( ctf_postprocess, 0 ) disp_CTF = ( ctf_postprocess, 1 ) # if options.disable_equalization or options.ideal: # terminate_stream(self, inv_estimated_CTF) # inv_estimated_CTF_vec = blocks.vector_source_c([1.0/fft_length*math.sqrt(total_subc)]*total_subc,True,total_subc) # inv_estimated_CTF_str = blocks.vector_to_stream(gr.sizeof_gr_complex, total_subc) # self.inv_estimated_CTF_mul = ofdm.multiply_const_ccf( 1.0/config.rms_amplitude ) # #inv_estimated_CTF_mul.set_k(1.0/config.rms_amplitude) # inv_estimated_CTF = blocks.stream_to_vector(gr.sizeof_gr_complex, total_subc) # self.connect( inv_estimated_CTF_vec, inv_estimated_CTF_str, self.inv_estimated_CTF_mul, inv_estimated_CTF) # print "Disabled equalization stage" ''' ## LMS Phase tracking ## Track residual frequency offset and sampling clock frequency offset nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) print"\t\t\t\t\tnondata_blocks=",nondata_blocks pilot_subc = block_header.pilot_tones pilot_subcarriers = block_header.pilot_subc_sym print "PILOT SUBCARRIERS: ", pilot_subcarriers phase_tracking = ofdm.lms_phase_tracking_03( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers,0 ) self.connect( ofdm_blocks, ( phase_tracking, 0 ) ) self.connect( inv_estimated_CTF, ( phase_tracking, 1 ) ) self.connect( frame_start, ( phase_tracking, 2 ) ) ## if options.scatter_plot_before_phase_tracking: self.before_phase_tracking = equalizer if options.disable_phase_tracking or options.ideal: terminate_stream(self, phase_tracking) print "Disabled phase tracking stage" else: ofdm_blocks = phase_tracking ''' ## Channel Equalizer if options.disable_equalization or options.ideal or options.ideal2: print "Disabled equalization stage" if options.ideal is False and options.ideal2 is False: terminate_stream(self, inv_estimated_CTF) else: equalizer = ofdm.channel_equalizer( total_subc ) self.connect( ofdm_blocks, ( equalizer, 0 ) ) self.connect( inv_estimated_CTF, ( equalizer, 1 ) ) self.connect( frame_start, ( equalizer, 2 ) ) ofdm_blocks = equalizer #log_to_file(self, equalizer,"data/equalizer_siso.compl") #log_to_file(self, ofdm_blocks, "data/equalizer.compl") ## LMS Phase tracking ## Track residual frequency offset and sampling clock frequency offset if options.ideal is False and options.ideal2 is False: nondata_blocks = [] for i in range(config.frame_length): if i in config.training_data.pilotsym_pos: nondata_blocks.append(i) print"\t\t\t\t\tnondata_blocks=",nondata_blocks pilot_subc = block_header.pilot_tones pilot_subcarriers = block_header.pilot_subc_sym print "PILOT SUBCARRIERS: ", pilot_subcarriers phase_tracking2 = ofdm.lms_phase_tracking_dc_null( total_subc, pilot_subc, nondata_blocks, pilot_subcarriers, dc_null ) self.connect( ofdm_blocks, ( phase_tracking2, 0 ) ) self.connect( frame_start, ( phase_tracking2, 1 ) ) ## if options.disable_phase_tracking or options.ideal or options.ideal2: if options.ideal is False and options.ideal2 is False: terminate_stream(self, phase_tracking2) print "Disabled phase tracking stage" else: ofdm_blocks = phase_tracking2 if options.scatter_plot_before_phase_tracking: self.before_phase_tracking = equalizer ## Output connections self.connect( ofdm_blocks, out_ofdm_blocks ) self.connect( frame_start, out_frame_start ) if options.ideal is False and options.ideal2 is False: self.connect( disp_CTF, out_disp_ctf ) else: self.connect( blocks.vector_source_f([1.0]*total_subc),blocks.stream_to_vector(gr.sizeof_float,total_subc), out_disp_ctf ) if log: log_to_file( self, sc_metric, "data/sc_metric.float" ) log_to_file( self, gi_metric, "data/gi_metric.float" ) log_to_file( self, morelli_foe, "data/morelli_foe.float" ) log_to_file( self, lms_fir, "data/lms_fir.float" ) log_to_file( self, sampler_preamble, "data/preamble.compl" ) log_to_file( self, sync, "data/sync.compl" ) log_to_file( self, frequency_shift, "data/frequency_shift.compl" ) log_to_file( self, fft, "data/fft.compl") log_to_file( self, fft, "data/fft.float", mag=True ) if vars().has_key( 'subcarrier_mask' ): log_to_file( self, subcarrier_mask, "data/subcarrier_mask.compl" ) log_to_file( self, ofdm_blocks, "data/ofdm_blocks_out.compl" ) log_to_file( self, frame_start, "data/frame_start.float", char_to_float=True ) log_to_file( self, sampled_chest_preamble, "data/sampled_chest_preamble.compl" ) log_to_file( self, LS_channel_estimator, "data/ls_channel_estimator.compl" ) log_to_file( self, LS_channel_estimator, "data/ls_channel_estimator.float", mag=True ) if "ctf_mse_enhancer" in locals(): log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.compl" ) log_to_file( self, ctf_mse_enhancer, "data/ctf_mse_enhancer.float", mag=True ) log_to_file( self, (ctf_postprocess,0), "data/inc_estimated_ctf.compl" ) log_to_file( self, (ctf_postprocess,1), "data/disp_ctf.float" ) log_to_file( self, equalizer, "data/equalizer.compl" ) log_to_file( self, equalizer, "data/equalizer.float", mag=True ) log_to_file( self, phase_tracking, "data/phase_tracking.compl" )
def __init__( self, pilot_carriers=((-40, -14, 13, 39),), pilot_symbols=((1, 1, 1, -1),), occupied_carriers=( [ -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, ], ), samp_rate=10000, payload_mod="qpsk", sync_word1=[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ], sync_word2=[ 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, ], scramble_mode=0, crc_mode=0, clipper_mode=0, filter_mode=1, clipping_factor=10, ): gr.hier_block2.__init__( self, "Ofdm Radio Hier", gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_gr_complex * 1]), ) ################################################## # Parameters ################################################## self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.occupied_carriers = occupied_carriers self.samp_rate = samp_rate self.sync_word1 = sync_word1 self.sync_word2 = sync_word2 self.scramble_mode = scramble_mode self.crc_mode = crc_mode self.clipping_factor = clipping_factor self.clipper_mode = clipper_mode self.filter_mode = filter_mode if payload_mod == "qpsk": self.payload_mod = payload_mod = digital.constellation_qpsk() elif payload_mod == "qam16": self.payload_mod = payload_mod = digital.qam.qam_constellation(16, True, "none", False) elif payload_mod == "bpsk": self.payload_mod = payload_mod = digital.constellation_bpsk() ################################################## # Variables ################################################## self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1) + len(sync_word2)) / 2 self.scramble_seed = scramble_seed = 0x7F self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1 ) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True, ) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols ) self.forward_OOB = forward_OOB = [ 0.40789374966665903, 3.2351160543115207, 11.253435139165413, 22.423991613997735, 27.99555756436666, 22.423991613997735, 11.253435139165425, 3.235116054311531, 0.40789374966666014, ] self.feedback_OOB = feedback_OOB = [ 1.0, 6.170110168740749, 16.888669609673336, 26.73762881119027, 26.75444043101795, 17.322358010203928, 7.091659316015212, 1.682084643429639, 0.17795354282083842, ] self.cp_len_0 = cp_len_0 = fft_len / 4 self.cp_len = cp_len = fft_len / 4 self.active_carriers = active_carriers = len(occupied_carriers[0]) + 4 ################################################## # Blocks ################################################## self.ofdm_tools_clipper_0 = ofdm_tools.clipper_cc(clipping_factor) self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb( header_formatter.formatter(), "packet_len" ) self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len / 4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True ) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, "", 0, "", True ) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), cp_len, length_tag_key, True, 0 ) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), cp_len, length_tag_key, True, 1 ) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer( fft_len, fft_len + cp_len, rolloff, packet_length_tag_key ) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key ) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, () ) self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.digital_additive_scrambler_bb_txpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.digital_additive_scrambler_bb_rxpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0 ) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False ) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True ) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01,)) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.blks2_selector_0_2 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=clipper_mode, output_index=0 ) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0_2_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=filter_mode, output_index=0 ) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0 / fft_len) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0) ) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0) ) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect( (self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0) ) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blks2_selector_0, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blks2_selector_0, 1)) self.connect((self.blks2_selector_0_1, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_additive_scrambler_bb_txpath_0, 0)) self.connect((self.digital_additive_scrambler_bb_txpath_0, 0), (self.blks2_selector_0_1, 1)) self.connect((self.blks2_selector_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self.blks2_selector_0_0, 1)) self.connect((self.digital_additive_scrambler_bb_rxpath_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_additive_scrambler_bb_rxpath_0, 0)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.ofdm_tools_clipper_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0_2, 0)) self.connect(self.blks2_selector_0_2, self.iir_filter_xxx_1) self.connect(self.blks2_selector_0_2, (self.blks2_selector_0_2_0, 0)) self.connect(self.iir_filter_xxx_1, (self.blks2_selector_0_2_0, 1)) self.connect(self.blks2_selector_0_2_0, (self, 1)) self.connect((self.ofdm_tools_clipper_0, 0), (self.blks2_selector_0_2, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect( self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data", )
def __init__(self, seq1, seq2, factor, alpha, freqs, debug_onoff, debug_port, prefix): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 self.debug_onoff = debug_onoff # 1: dump ports info to file 0: no debug output self.debug_port = debug_port # 0-n_filt-1 is the output of each filter branck; n_filter is the output of maximum self.prefix = prefix ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, 0, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() if self.debug_onoff == True: num_of_file_sinks = len(self.debug_port) self._filesink = [0]*num_of_file_sinks for i in range(num_of_file_sinks): if self.debug_port[i] == self.n: filename = prefix+"max.dat" else: filename = prefix+"filter"+str(i)+".dat" print filename self._filesink[i] = blocks.file_sink(gr.sizeof_float*1, filename, False) self._filesink[i].set_unbuffered(False) # this is the block for bundling the outputs of each branch of filters and the input of peak detector ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2)) if self.debug_onoff == True: for i in range(num_of_file_sinks): port_index = self.debug_port[i] if port_index == self.n: self.connect((self.blocks_max, 0), (self._filesink[i], 0)) else: self.connect((self._c2mag2[port_index], 0), (self._filesink[i], 0))
def __init__(self, verbose_mode=True, radio_host_name="ndr651", radio_host_port=8617, tengig_iface_list=['eth10', 'eth11'], num_tuners=1, tuner1_param_list=[False, 900e6, 0], tuner2_param_list=[False, 900e6, 0], num_wbddcs=1, wbddc1_param_list=["eth10", 40001, 0, 0, False], wbddc2_param_list=["eth10", 40002, 0, 0, False], num_nbddcs=1, nbddc1_param_list=["eth10", 41001, 0, 0, False, 0.0], nbddc2_param_list=["eth10", 41002, 0, 0, False, 0.0], nbddc3_param_list=["eth10", 41003, 0, 0, False, 0.0], nbddc4_param_list=["eth10", 41004, 0, 0, False, 0.0], nbddc5_param_list=["eth10", 41005, 0, 0, False, 0.0], nbddc6_param_list=["eth10", 41006, 0, 0, False, 0.0], nbddc7_param_list=["eth10", 41007, 0, 0, False, 0.0], nbddc8_param_list=["eth10", 41008, 0, 0, False, 0.0], nbddc9_param_list=["eth10", 41009, 0, 0, False, 0.0], nbddc10_param_list=["eth10", 41010, 0, 0, False, 0.0], nbddc11_param_list=["eth10", 41011, 0, 0, False, 0.0], nbddc12_param_list=["eth10", 41012, 0, 0, False, 0.0], nbddc13_param_list=["eth10", 41013, 0, 0, False, 0.0], nbddc14_param_list=["eth10", 41014, 0, 0, False, 0.0], nbddc15_param_list=["eth10", 41015, 0, 0, False, 0.0], nbddc16_param_list=["eth10", 41016, 0, 0, False, 0.0], tagged=False, debug=False, ): gr.hier_block2.__init__( self, "[CyberRadio] NDR651 Source", gr.io_signature(0, 0, 0), gr.io_signaturev(num_wbddcs + num_nbddcs + 1, num_wbddcs + num_nbddcs + 1, [gr.sizeof_char*1] + num_wbddcs * [gr.sizeof_gr_complex*1] + \ num_nbddcs * [gr.sizeof_gr_complex*1]), ) self.logger = gr.logger("CyberRadio") self.logger.set_level("INFO") self.tuner_param_lists = {} self.wbddc_sources = {} self.wbddc_param_lists = {} self.nbddc_sources = {} self.nbddc_param_lists = {} self.verbose_mode = verbose_mode self.radio_host_name = radio_host_name self.radio_host_port = radio_host_port self.tengig_iface_list = tengig_iface_list self.num_tuners = num_tuners self.tuner_param_lists[1] = tuner1_param_list self.tuner_param_lists[2] = tuner2_param_list self.num_wbddcs = num_wbddcs self.wbddc_param_lists[1] = wbddc1_param_list self.wbddc_param_lists[2] = wbddc2_param_list self.num_nbddcs = num_nbddcs self.nbddc_param_lists[1] = nbddc1_param_list self.nbddc_param_lists[2] = nbddc2_param_list self.nbddc_param_lists[3] = nbddc3_param_list self.nbddc_param_lists[4] = nbddc4_param_list self.nbddc_param_lists[5] = nbddc5_param_list self.nbddc_param_lists[6] = nbddc6_param_list self.nbddc_param_lists[7] = nbddc7_param_list self.nbddc_param_lists[8] = nbddc8_param_list self.nbddc_param_lists[9] = nbddc9_param_list self.nbddc_param_lists[10] = nbddc10_param_list self.nbddc_param_lists[11] = nbddc11_param_list self.nbddc_param_lists[12] = nbddc12_param_list self.nbddc_param_lists[13] = nbddc13_param_list self.nbddc_param_lists[14] = nbddc14_param_list self.nbddc_param_lists[15] = nbddc15_param_list self.nbddc_param_lists[16] = nbddc16_param_list self.tagged = tagged self.debug = debug self.CyberRadio_file_like_object_source_0 = CyberRadio.file_like_object_source() self.connect((self.CyberRadio_file_like_object_source_0, 0), (self, 0)) self.CyberRadio_NDR_driver_interface_0 = CyberRadio.NDR_driver_interface( radio_type="ndr651", verbose=verbose_mode, log_file=self.CyberRadio_file_like_object_source_0, connect_mode="tcp", host_name=radio_host_name, host_port=radio_host_port, ) self.vita_tail_size = self.CyberRadio_NDR_driver_interface_0.getVitaTailSize() self.vita_payload_size = self.CyberRadio_NDR_driver_interface_0.getVitaPayloadSize() self.vita_header_size = self.CyberRadio_NDR_driver_interface_0.getVitaHeaderSize() self.iq_swapped = self.CyberRadio_NDR_driver_interface_0.isIqSwapped() self.byte_swapped = self.CyberRadio_NDR_driver_interface_0.isByteswapped() # tengig_iface_info = Nested dictionary caching info for our 10GigE # interfaces. Keyed by interface name and datum keyword ("index", # , "destMAC", "sourceIP", or "destIP"). self.tengig_iface_info = {} self._get_tengig_iface_info() # UDP destination info needs to be tracked dynamically, since # DDCs can be freely assigned to any 10GigE port but there are # not enough DIP table entries to hard-code any assignments. self.udp_dest_dip_entries = {} self.udp_dest_dip_entry_range = self.CyberRadio_NDR_driver_interface_0.getGigEDipEntryIndexRange() self._set_udp_dest_info() for tuner_index in xrange(1, self.num_tuners + 1, 1): self._set_tuner_param_list(tuner_index, self.tuner_param_lists[tuner_index]) for wbddc_index in xrange(1, self.num_wbddcs + 1, 1): self.wbddc_sources[wbddc_index] = self._get_configured_wbddc( wbddc_index, self.wbddc_param_lists[wbddc_index]) self.connect((self.wbddc_sources[wbddc_index], 0), (self, wbddc_index)) for nbddc_index in xrange(1, self.num_nbddcs + 1, 1): self.nbddc_sources[nbddc_index] = self._get_configured_nbddc( nbddc_index, self.nbddc_param_lists[nbddc_index]) self.connect((self.nbddc_sources[nbddc_index], 0), (self, self.num_wbddcs + nbddc_index))
def sig_to_gr_io_sigv(sig): if not len(sig): return gr.io_signature(0, 0, 0) return gr.io_signaturev(len(sig), len(sig), [s.itemsize for s in sig])
def __init__(self, seq1, seq2, factor, lookahead, alpha, freqs): """ Description: frequency timing estimator class does frequency/timing acquisition from scratch.It uses a bank of parallel correlators at each specified frequency. It then takes the max abs value of all these and passes it through a peak detector to find timing. Args: seq1: sequence1 of kronecker filter, which is the given training sequence. seq2: sequence2 of kronecker filter, which is the pulse for each training symbol. factor: the rise and fall factors in peak detector, which is the factor determining when a peak has started and ended. In the peak detector, an average of the signal is calculated. When the value of the signal goes over factor*average, we start looking for a peak. When the value of the signal goes below factor*average, we stop looking for a peak. alpha: the smoothing factor of a moving average filter used in the peak detector taking values in (0,1). freqs: the vector of normalized center frequencies for each matched filter. Note that for a training sequence of length Nt, each matched filter can recover a sequence with normalized frequency offset ~ 1/(2Nt). """ gr.hier_block2.__init__(self, "freq_timing_estimator", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(3, 3, [gr.sizeof_char*1, gr.sizeof_float*1, gr.sizeof_float*1]), ) ################################################## # Parameters ################################################## self.seq1 = seq1 self.seq2 = seq2 self.factor = factor self.lookahead = lookahead self.alpha = alpha self.freqs = freqs self.n = n = len(freqs) self.on = 1 ################################################## # Blocks ################################################## self._filter=[0]*self.n self._c2mag2=[0]*self.n for i in range(self.n): #self._filter[i]= cdma.kronecker_filter(seq1,seq2,1,self.freqs[i]) #self._filter[i]= filter.freq_xlating_fir_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._filter[i]= filter.freq_xlating_fft_filter_ccc(1, numpy.kron(seq1,seq2), self.freqs[i], 1) self._c2mag2[i] = blocks.complex_to_mag_squared(1) self.blocks_max = blocks.max_ff(1) self.blocks_peak_detector = cdma.switched_peak_detector_fb(self.factor, self.factor, self.lookahead, self.alpha, self.on) self.blocks_argmax = blocks.argmax_fs(1) self.blocks_null_sink = blocks.null_sink(gr.sizeof_short*1) self.digital_chunks_to_symbols = digital.chunks_to_symbols_sf((freqs), 1) self.blocks_sample_and_hold = blocks.sample_and_hold_ff() ################################################## # Connections ################################################## for i in range(self.n): self.connect((self, 0), (self._filter[i], 0)) self.connect((self._filter[i], 0), (self._c2mag2[i], 0)) self.connect((self._c2mag2[i], 0), (self.blocks_max, i)) self.connect((self._c2mag2[i], 0), (self.blocks_argmax, i)) self.connect((self.blocks_max, 0), (self.blocks_peak_detector, 0)) self.connect((self.blocks_peak_detector, 0), (self, 0)) self.connect((self.blocks_argmax, 0), (self.blocks_null_sink, 0)) self.connect((self.blocks_argmax, 1), (self.digital_chunks_to_symbols, 0)) self.connect((self.digital_chunks_to_symbols, 0), (self.blocks_sample_and_hold, 0)) self.connect((self.blocks_peak_detector, 0), (self.blocks_sample_and_hold, 1)) self.connect((self.blocks_sample_and_hold, 0), (self, 1)) self.connect((self.blocks_max, 0), (self, 2))
def __init__(self, cp_len=32, fft_len=64, max_fft_shift=4, occupied_carriers=48, ports=2): gr.hier_block2.__init__( self, "OFDM Mutichannel Recover", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*occupied_carriers, gr.sizeof_gr_complex*occupied_carriers]), ) self.message_port_register_hier_out("packet") self.message_port_register_hier_out("header_dfe") ################################################## # Parameters ################################################## self.cp_len = cp_len self.fft_len = fft_len self.max_fft_shift = max_fft_shift self.occupied_carriers = occupied_carriers self.ports = ports ################################################## # Variables ################################################## self.rcvd_pktq = rcvd_pktq = gr.msg_queue() self.modulation = modulation = 'bpsk' self.mods = mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} self.bw = bw = (float(occupied_carriers) / float(fft_len)) / 2.0 self.watcher = watcher = pp._queue_watcher_thread(rcvd_pktq) self.tb = tb = bw*0.08 self.samp_rate = samp_rate = 32000 self.rotated_const = rotated_const = gp.gen_framer_info(modulation) self.phgain = phgain = 0.25 self.arity = arity = mods[modulation] ################################################## # Blocks ################################################## self.ofdm_sync_channel_0 = ofdm_sync_channel( cp_len=cp_len, fftlen=fft_len, max_fft_shift=max_fft_shift, occupied_carriers=occupied_carriers, ) self.ofdm_packet_sync_0 = ofdm_packet_sync( cp_len=cp_len, fft_len=fft_len, ) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (filter.firdes.low_pass (1.0, 1.0, bw+tb, tb, filter.firdes.WIN_HAMMING)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.ofdm_ofdm_mrx_frame_sink_0 = ofdm.ofdm_mrx_frame_sink(rotated_const, range(arity), rcvd_pktq, occupied_carriers, phgain, phgain*phgain /4.0, ports) for p in range(ports-1): # Add OFDM Sync Channel object_name_osc = 'ofdm_sync_channel_'+str(p+1) setattr(self, object_name_osc, ofdm_sync_channel( cp_len=cp_len, fftlen=fft_len, max_fft_shift=max_fft_shift, occupied_carriers=occupied_carriers, )) # Add FFT Filter object_name_ft = 'fft_filter_ccc_'+str(p+1) setattr(self, object_name_ft, filter.fft_filter_ccc(1, (filter.firdes.low_pass (1.0, 1.0, bw+tb, tb, filter.firdes.WIN_HAMMING)), 1) ) # self.fft_filter_xxx_0_0.declare_sample_delay(0) setattr(getattr(self,object_name_ft),'declare_sample_delay',0) # Add null sink object_name_ns = 'blocks_null_sink_'+str(p+1) setattr(self, object_name_ns, blocks.null_sink(gr.sizeof_char*1) ) ### Connections # Pad to FFT Filter self.connect( (self, p+1), (getattr(self,object_name_ft), 0)) # FFT Filt to OFS self.connect( (getattr(self,object_name_ft), 0), (getattr(self,object_name_osc), 0) ) # PS To OFDM SC self.connect( (self.ofdm_packet_sync_0, 0), (getattr(self,object_name_osc), 2)) self.connect( (self.ofdm_packet_sync_0, 1), (getattr(self,object_name_osc), 1)) # OSC To OFDM Frame Sink self.connect((getattr(self,object_name_osc), 1), (self.ofdm_sync_channel_0, p+2)) # OSC To Null Sink self.connect((getattr(self,object_name_osc), 0), (self.blocks_null_sink_0, 0)) # OFDM Frame Sink to Pad self.connect((self.ofdm_ofdm_mrx_frame_sink_0, p), (self, p)) ################################################## # Connections ################################################## self.connect((self, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.ofdm_packet_sync_0, 0)) self.connect((self.ofdm_packet_sync_0, 0), (self.ofdm_sync_channel_0, 2)) self.connect((self.ofdm_packet_sync_0, 1), (self.ofdm_sync_channel_0, 1)) self.connect((self.ofdm_packet_sync_0, 2), (self.ofdm_sync_channel_0, 0)) self.connect((self.ofdm_sync_channel_0, 0), (self.ofdm_ofdm_mrx_frame_sink_0, 0)) # Flag self.connect((self.ofdm_sync_channel_0, 1), (self.ofdm_ofdm_mrx_frame_sink_0, 1)) self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'packet'), (self, 'packet')) self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'header_dfe'), (self, 'header_dfe'))
def __init__(self, rx_channels, fft_length, cp_length, occupied_tones, snr, ks, logging=False): """ Hierarchical block for receiving OFDM symbols. The input is the complex modulated signal at baseband. Synchronized packets are sent back to the demodulator. Args: fft_length: total number of subcarriers (int) cp_length: length of cyclic prefix as specified in subcarriers (<= fft_length) (int) occupied_tones: number of subcarriers used for data (int) snr: estimated signal to noise ratio used to guide cyclic prefix synchronizer (float) ks: known symbols used as preambles to each packet (list of lists) logging: turn file logging on or off (bool) """ self.rx_channels = rx_channels gr.hier_block2.__init__(self, "ofdm_receiver", gr.io_signaturev(self.rx_channels, self.rx_channels, gen_multiple_ios(self.rx_channels)), # Input signature gr.io_signaturev(self.rx_channels*2, self.rx_channels*2, gen_multiple_ios_out(self.rx_channels-1,occupied_tones,fft_length) )) # Output signature bw = (float(occupied_tones) / float(fft_length)) / 2.0 tb = bw*0.08 chan_coeffs = filter.firdes.low_pass (1.0, # gain 1.0, # sampling rate bw+tb, # midpoint of trans. band tb, # width of trans. band filter.firdes.WIN_HAMMING) # filter type self.chan_filt = filter.fft_filter_ccc(1, chan_coeffs) win = [1 for i in range(fft_length)] zeros_on_left = int(math.ceil((fft_length - occupied_tones)/2.0)) ks0 = fft_length*[0,] ks0[zeros_on_left : zeros_on_left + occupied_tones] = ks[0] ks0 = fft.ifftshift(ks0) ks0time = fft.ifft(ks0) # ADD SCALING FACTOR ks0time = ks0time.tolist() SYNC = "pn" if SYNC == "ml": nco_sensitivity = -1.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_ml(fft_length, cp_length, snr, ks0time, logging) elif SYNC == "pn": # Schmidl & Cox Method nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_pn(fft_length, cp_length, logging) elif SYNC == "pnac": nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_pnac(fft_length, cp_length, ks0time, logging) # for testing only; do not user over the air # remove filter and filter delay for this elif SYNC == "fixed": self.chan_filt = blocks.multiply_const_cc(1.0) nsymbols = 18 # enter the number of symbols per packet freq_offset = 0.0 # if you use a frequency offset, enter it here nco_sensitivity = -2.0/fft_length # correct for fine frequency self.ofdm_sync = ofdm_sync_fixed(fft_length, cp_length, nsymbols, freq_offset, logging) # Set up blocks self.nco = analog.frequency_modulator_fc(nco_sensitivity) # generate a signal proportional to frequency error of sync block self.sigmix = blocks.multiply_cc() self.sampler = digital.ofdm_sampler(fft_length, fft_length+cp_length) self.fft_demod = gr_fft.fft_vcc(fft_length, True, win, True) self.ofdm_frame_acq = digital.ofdm_frame_acquisition(occupied_tones,fft_length,cp_length, ks[0]) # Setup Connections for synchronization path self.connect((self,0), self.chan_filt) # filter the input channel self.connect(self.chan_filt, self.ofdm_sync) # into the synchronization alg. self.connect((self.ofdm_sync,0), self.nco, (self.sigmix,1)) # use sync freq. offset output to derotate input signal self.connect(self.chan_filt, (self.sigmix,0)) # signal to be derotated self.connect(self.sigmix, (self.sampler,0)) # sample off timing signal detected in sync alg self.connect((self.ofdm_sync,1), (self.sampler,1)) # timing signal to sample at self.connect((self.sampler,0), self.fft_demod) # send derotated sampled signal to FFT self.connect(self.fft_demod, (self.ofdm_frame_acq,0)) # find frame start and equalize signal self.connect((self.sampler,1), (self.ofdm_frame_acq,1)) # send timing signal to signal frame start self.connect((self.ofdm_frame_acq,0), (self,0)) # finished with fine/coarse freq correction, self.connect((self.ofdm_frame_acq,1), (self,1)) # frame and symbol timing, and equalization # Debugging # self.connect(self.fft_demod, (self,2)) # Output unequalized signal ############ BLOCK OUTPUTS # ofdm_frame_acquisition (0,occupied carriers) # ofdm_frame_acquisition (1,flag) # .... Repeats for each input ########################## # Add additional channels for each radio output = 2 for p in range(1,self.rx_channels): print "ofdm_receiver: "+str(p) # Add channel filter object_name_cf = 'chan_filter_'+str(p) setattr(self, object_name_cf, filter.fft_filter_ccc(1, chan_coeffs) ) # Connect hier to channel filter self.connect((self,p), (getattr(self,object_name_cf), 0)) # Add Mixer object_name_sm = 'sigmix_'+str(p) setattr(self, object_name_sm, blocks.multiply_cc()) # Connect channel filter to mixer self.connect((getattr(self,object_name_cf), 0), (getattr(self,object_name_sm), 0)) # Connect nco to mixer self.connect( self.nco, (getattr(self,object_name_sm), 1) ) # Add ofdm sampler object_name_sp = 'sampler_'+str(p) # setattr(self, object_name_sp, copy.copy(self.sampler)) # not copiable setattr(self, object_name_sp, digital.ofdm_sampler(fft_length, fft_length+cp_length)) # Connect mixer to sampler self.connect((getattr(self,object_name_sm), 0), (getattr(self,object_name_sp), 0)) # Connect timing signal to sampler self.connect((self.ofdm_sync,1), (getattr(self,object_name_sp), 1)) # Add FFT object_name_fft = 'fft_'+str(p) # setattr(self, object_name_fft, copy.copy(self.fft_demod)) setattr(self, object_name_fft, gr_fft.fft_vcc(fft_length, True, win, True)) # Connect sampler to FFT self.connect((getattr(self,object_name_sp), 0), (getattr(self,object_name_fft), 0)) # Add frame acquistion object_name_fa = 'ofdm_frame_ac_'+str(p) setattr(self, object_name_fa, digital.ofdm_frame_acquisition(occupied_tones,fft_length,cp_length, ks[0])) # Connect FFT to frame acquistion self.connect((getattr(self,object_name_fft), 0), (getattr(self,object_name_fa), 0)) # Connect sampler to frame acquistion self.connect((getattr(self,object_name_sp), 1), (getattr(self,object_name_fa), 1)) # Add frame acquistion outputs to hier self.connect((getattr(self,object_name_fa), 0), (self, output)) output = output + 1 self.connect((getattr(self,object_name_fa), 1), (self, output)) output = output + 1 # ############# NULLS ############# # # Add Null sink for unused inputs # object_name_nb = 'null_sink_'+str(p) # setattr(self, object_name_nb, blocks.null_sink(gr.sizeof_gr_complex*1)) # # Connect # self.connect((self, p+1), (getattr(self,object_name_nb), 0)) if logging: self.connect(self.chan_filt, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-chan_filt_c.dat")) self.connect(self.fft_demod, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-fft_out_c.dat")) self.connect(self.ofdm_frame_acq, blocks.file_sink(gr.sizeof_gr_complex*occupied_tones, "ofdm_receiver-frame_acq_c.dat")) self.connect((self.ofdm_frame_acq,1), blocks.file_sink(1, "ofdm_receiver-found_corr_b.dat")) self.connect(self.sampler, blocks.file_sink(gr.sizeof_gr_complex*fft_length, "ofdm_receiver-sampler_c.dat")) self.connect(self.sigmix, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-sigmix_c.dat")) self.connect(self.nco, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_receiver-nco_c.dat"))
def __init__(self, d=0.5, snapshots=4096, source_signals=1, num_elements=2): gr.hier_block2.__init__( self, "MuSIC Spectrum GUI", gr.io_signaturev(num_elements+2, num_elements+2, gen_sig_io(num_elements) ), gr.io_signature(0, 0, 0), ) Qt.QWidget.__init__(self) self.top_layout = Qt.QVBoxLayout() self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.setLayout(self.top_layout) ################################################## # Parameters ################################################## self.d = d self.snapshots = snapshots self.source_signals = source_signals self.num_elements = num_elements ################################################## # Variables ################################################## self.vec = vec = 3 self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( 180, -90, 1.0, "Offset", "dB", "MuSIC Spectrum", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-140, 10) self.qtgui_vector_sink_f_0.enable_autoscale(True) self.qtgui_vector_sink_f_0.enable_grid(True) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance(self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_vector_sink_f_0_win) self.wifius_gen_music_spectrum_vcvf_0 = wifius.gen_music_spectrum_vcvf(num_elements, source_signals, -90, 90, 1, d, snapshots) self.connect((self, 0), (self.wifius_gen_music_spectrum_vcvf_0, 0)) self.connect((self, self.num_elements+1), (self.wifius_gen_music_spectrum_vcvf_0, 1)) self.connect((self.wifius_gen_music_spectrum_vcvf_0, 0), (self.qtgui_vector_sink_f_0, 0)) for n in range(num_elements): # Create SV object object_name_sv = 'blocks_stream_to_vector_'+str(n) print object_name_sv setattr(self, object_name_sv, blocks.stream_to_vector(gr.sizeof_gr_complex*1, snapshots)) # Connect self.connect((self, n+1), (getattr(self,object_name_sv), 0)) self.connect((getattr(self,object_name_sv), 0), (self.wifius_gen_music_spectrum_vcvf_0, n+2))
def __init__(self, options, num_channels, callback=None): """ Hierarchical block for demodulating and deframing packets. The input is the complex modulated signal at baseband. Demodulated packets are sent to the handler. Args: options: pass modulation options from higher layers (fft length, occupied tones, etc.) callback: function of two args: ok, payload (ok: bool; payload: string) """ self.rx_channels = num_channels#len(options.args.split(',')) gr.hier_block2.__init__(self, "ofdm_demod", gr.io_signaturev(self.rx_channels, self.rx_channels, gen_multiple_ios(self.rx_channels,1) ), # Input signature gr.io_signaturev(self.rx_channels, self.rx_channels, gen_multiple_ios(self.rx_channels,options.occupied_tones) )) #[gr.sizeof_gr_complex*options.occupied_tones, gr.sizeof_gr_complex*options.occupied_tones])) # Output signature self._rcvd_pktq = gr.msg_queue() # holds packets from the PHY from all receive channels self._modulation = options.modulation self._fft_length = options.fft_length self._occupied_tones = options.occupied_tones self._cp_length = options.cp_length self._snr = options.snr # Use freq domain to get doubled-up known symbol for correlation in time domain zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) ksfreq = known_symbols_4512_3[0:self._occupied_tones] for i in range(len(ksfreq)): if((zeros_on_left + i) & 1): ksfreq[i] = 0 # hard-coded known symbols preambles = (ksfreq,) symbol_length = self._fft_length + self._cp_length self.ofdm_recv = ofdm_receiver(self.rx_channels, self._fft_length, self._cp_length, self._occupied_tones, self._snr, preambles, options.log) mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} arity = mods[self._modulation] rot = 1 if self._modulation == "qpsk": rot = (0.707+0.707j) # FIXME: pass the constellation objects instead of just the points if(self._modulation.find("psk") >= 0): constel = psk.psk_constellation(arity) rotated_const = map(lambda pt: pt * rot, constel.points()) elif(self._modulation.find("qam") >= 0): constel = qam.qam_constellation(arity) rotated_const = map(lambda pt: pt * rot, constel.points()) #print rotated_const phgain = 0.25 frgain = phgain*phgain / 4.0 # self.ofdm_demod = ofdm.ofdm_frame_sink(rotated_const, range(arity),self._rcvd_pktq,self._occupied_tones,phgain, frgain, 3) self.ofdm_demod = ofdm.ofdm_mrx_frame_sink(rotated_const, range(arity),self._rcvd_pktq,self._occupied_tones,phgain, frgain, self.rx_channels) self.mdb = blocks.message_debug() ############# CONNECTIONS ############## # Connect ofdm_receiver flag to ofdm framer flag self.connect((self.ofdm_recv, 1), (self.ofdm_demod, 0)) # Connect flag from 1st chain only # Connect frame sink msg port to debugger self.msg_connect((self.ofdm_demod, 'packet'), (self.mdb,'print')) # Connect remaining data ports port = 0 for c in range(self.rx_channels): # Connect USRP's to channel filters self.connect((self,c), (self.ofdm_recv,c)) # Add null sink object_name_ns = 'null_sink_'+str(c) setattr(self, object_name_ns, blocks.null_sink(gr.sizeof_char*1)) # Connect ofdm_receiver to ofdm framer self.connect((self.ofdm_recv, port), (self.ofdm_demod, c+1)) # Occupied tones # Connect extra port(s) to null since we dont need it now self.connect((self.ofdm_recv, port+1), (getattr(self,object_name_ns), 0)) port = port + 2 # Connect equalized signals to output self.connect((self.ofdm_demod, c), (self, c)) # added output signature to work around bug, though it might not be a bad # thing to export, anyway # self.connect(self.ofdm_recv.chan_filt, (self,0)) ############## ############## if options.log: self.connect(self.ofdm_demod, blocks.file_sink(gr.sizeof_gr_complex*self._occupied_tones, "ofdm_frame_sink_c.dat")) else: self.connect(self.ofdm_demod, blocks.null_sink(gr.sizeof_gr_complex*self._occupied_tones)) if options.verbose: self._print_verbage() self._watcher = _queue_watcher_thread(self._rcvd_pktq, callback)
def __init__(self, samples_per_symbol=_def_samples_per_symbol, excess_bw=_def_excess_bw, costas_alpha=_def_costas_alpha, timing_alpha=_def_timing_alpha, timing_max_dev=_def_timing_max_dev, gray_code=_def_gray_code, verbose=_def_verbose, log=_def_log, sync_out=False): """ Hierarchical block for RRC-filtered differential BPSK demodulation The input is the complex modulated signal at baseband. The output is a stream of bits packed 1 bit per byte (LSB) @param samples_per_symbol: samples per symbol >= 2 @type samples_per_symbol: float @param excess_bw: Root-raised cosine filter excess bandwidth @type excess_bw: float @param costas_alpha: loop filter gain @type costas_alpha: float @param timing_alpha: timing loop alpha gain @type timing_alpha: float @param timing_max: timing loop maximum rate deviations @type timing_max: float @param gray_code: Tell modulator to Gray code the bits @type gray_code: bool @param verbose: Print information about modulator? @type verbose: bool @param log: Print modualtion data to files? @type log: bool @param sync_out: Output a sync signal on :1? @type sync_out: bool """ if sync_out: io_sig_out = gr.io_signaturev(2, 2, (gr.sizeof_char, gr.sizeof_gr_complex)) else: io_sig_out = gr.io_signature(1, 1, gr.sizeof_char) gr.hier_block2.__init__(self, "dqpsk2_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature io_sig_out) # Output signature self._samples_per_symbol = samples_per_symbol self._excess_bw = excess_bw self._costas_alpha = costas_alpha self._timing_alpha = timing_alpha self._timing_beta = _def_timing_beta self._timing_max_dev=timing_max_dev self._gray_code = gray_code if samples_per_symbol < 2: raise TypeError, "samples_per_symbol must be >= 2, is %r" % (samples_per_symbol,) arity = pow(2,self.bits_per_symbol()) # Automatic gain control self.agc = gr.agc2_cc(0.6e-1, 1e-3, 1, 1, 100) #self.agc = gr.feedforward_agc_cc(16, 1.0) self._costas_beta = 0.25 * self._costas_alpha * self._costas_alpha # Allow a frequency swing of +/- half of the sample rate fmin = -0.5 fmax = 0.5 self.clock_recov = gr.costas_loop_cc(self._costas_alpha, self._costas_beta, fmax, fmin, arity) # symbol timing recovery with RRC data filter nfilts = 32 ntaps = 11 * samples_per_symbol*nfilts taps = gr.firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(self._samples_per_symbol), self._excess_bw, ntaps) self.time_recov = gr.pfb_clock_sync_ccf(self._samples_per_symbol, self._timing_alpha, taps, nfilts, nfilts/2, self._timing_max_dev) self.time_recov.set_beta(self._timing_beta) # Do differential decoding based on phase change of symbols self.diffdec = gr.diff_phasor_cc() # find closest constellation point rot = 1 rotated_const = map(lambda pt: pt * rot, psk.constellation[arity]) self.slicer = gr.constellation_decoder_cb(rotated_const, range(arity)) if self._gray_code: self.symbol_mapper = gr.map_bb(psk.gray_to_binary[arity]) else: self.symbol_mapper = gr.map_bb(psk.ungray_to_binary[arity]) # unpack the k bit vector into a stream of bits self.unpack = gr.unpack_k_bits_bb(self.bits_per_symbol()) if verbose: self._print_verbage() if log: self._setup_logging() # Connect self.connect(self, self.agc, self.clock_recov, self.time_recov, self.diffdec, self.slicer, self.symbol_mapper, self.unpack, self) if sync_out: self.connect(self.time_recov, (self, 1))
def __init__(self, cp_len=32, fft_len=64, max_fft_shift=4, occupied_carriers=48, ports=2): gr.hier_block2.__init__( self, "OFDM Mutichannel Recover", gr.io_signaturev( 2, 2, [gr.sizeof_gr_complex * 1, gr.sizeof_gr_complex * 1]), gr.io_signaturev(2, 2, [ gr.sizeof_gr_complex * occupied_carriers, gr.sizeof_gr_complex * occupied_carriers ]), ) self.message_port_register_hier_out("packet") self.message_port_register_hier_out("header_dfe") ################################################## # Parameters ################################################## self.cp_len = cp_len self.fft_len = fft_len self.max_fft_shift = max_fft_shift self.occupied_carriers = occupied_carriers self.ports = ports ################################################## # Variables ################################################## self.rcvd_pktq = rcvd_pktq = gr.msg_queue() self.modulation = modulation = 'bpsk' self.mods = mods = { "bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256 } self.bw = bw = (float(occupied_carriers) / float(fft_len)) / 2.0 self.watcher = watcher = pp._queue_watcher_thread(rcvd_pktq) self.tb = tb = bw * 0.08 self.samp_rate = samp_rate = 32000 self.rotated_const = rotated_const = gp.gen_framer_info(modulation) self.phgain = phgain = 0.25 self.arity = arity = mods[modulation] ################################################## # Blocks ################################################## self.ofdm_sync_channel_0 = ofdm_sync_channel( cp_len=cp_len, fftlen=fft_len, max_fft_shift=max_fft_shift, occupied_carriers=occupied_carriers, ) self.ofdm_packet_sync_0 = ofdm_packet_sync( cp_len=cp_len, fft_len=fft_len, ) self.fft_filter_xxx_0 = filter.fft_filter_ccc( 1, (filter.firdes.low_pass(1.0, 1.0, bw + tb, tb, filter.firdes.WIN_HAMMING)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.ofdm_ofdm_mrx_frame_sink_0 = ofdm.ofdm_mrx_frame_sink( rotated_const, range(arity), rcvd_pktq, occupied_carriers, phgain, phgain * phgain / 4.0, ports) for p in range(ports - 1): # Add OFDM Sync Channel object_name_osc = 'ofdm_sync_channel_' + str(p + 1) setattr( self, object_name_osc, ofdm_sync_channel( cp_len=cp_len, fftlen=fft_len, max_fft_shift=max_fft_shift, occupied_carriers=occupied_carriers, )) # Add FFT Filter object_name_ft = 'fft_filter_ccc_' + str(p + 1) setattr( self, object_name_ft, filter.fft_filter_ccc(1, (filter.firdes.low_pass( 1.0, 1.0, bw + tb, tb, filter.firdes.WIN_HAMMING)), 1)) # self.fft_filter_xxx_0_0.declare_sample_delay(0) setattr(getattr(self, object_name_ft), 'declare_sample_delay', 0) # Add null sink object_name_ns = 'blocks_null_sink_' + str(p + 1) setattr(self, object_name_ns, blocks.null_sink(gr.sizeof_char * 1)) ### Connections # Pad to FFT Filter self.connect((self, p + 1), (getattr(self, object_name_ft), 0)) # FFT Filt to OFS self.connect((getattr(self, object_name_ft), 0), (getattr(self, object_name_osc), 0)) # PS To OFDM SC self.connect((self.ofdm_packet_sync_0, 0), (getattr(self, object_name_osc), 2)) self.connect((self.ofdm_packet_sync_0, 1), (getattr(self, object_name_osc), 1)) # OSC To OFDM Frame Sink self.connect((getattr(self, object_name_osc), 1), (self.ofdm_sync_channel_0, p + 2)) # OSC To Null Sink self.connect((getattr(self, object_name_osc), 0), (self.blocks_null_sink_0, 0)) # OFDM Frame Sink to Pad self.connect((self.ofdm_ofdm_mrx_frame_sink_0, p), (self, p)) ################################################## # Connections ################################################## self.connect((self, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.ofdm_packet_sync_0, 0)) self.connect((self.ofdm_packet_sync_0, 0), (self.ofdm_sync_channel_0, 2)) self.connect((self.ofdm_packet_sync_0, 1), (self.ofdm_sync_channel_0, 1)) self.connect((self.ofdm_packet_sync_0, 2), (self.ofdm_sync_channel_0, 0)) self.connect((self.ofdm_sync_channel_0, 0), (self.ofdm_ofdm_mrx_frame_sink_0, 0)) # Flag self.connect((self.ofdm_sync_channel_0, 1), (self.ofdm_ofdm_mrx_frame_sink_0, 1)) self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'packet'), (self, 'packet')) self.msg_connect((self.ofdm_ofdm_mrx_frame_sink_0, 'header_dfe'), (self, 'header_dfe'))
def __init__(self, samp_rate=10000): gr.hier_block2.__init__( self, "Sync Radio Hier Grc", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.samp_rate = samp_rate ################################################## # Variables ################################################## self.sync_word2 = sync_word2 = [0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,(1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),(-1+0j),(1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),0j,(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j] self.sync_word1 = sync_word1 = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] self.pilot_symbols = pilot_symbols = ((1, -1,),) self.pilot_carriers = pilot_carriers = ((-13, 12,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ([-16, -15, -14, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15],) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1)+len(sync_word2))/2 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.forward_OOB = forward_OOB = [0.005277622700213007, 0.03443705907448985, 0.1214101788557494, 0.29179662246081545, 0.52428014905364, 0.7350677973792328, 0.8210395030022875, 0.7350677973792348, 0.5242801490536404, 0.291796622460816, 0.1214101788557501, 0.03443705907448997, 0.005277622700213012] self.feedback_OOB = feedback_OOB = [1.0, -1.0455317889337852, 3.9201525346250072, -3.9114761684448958, 6.54266144224035, -5.737287389902878, 5.820328302284336, -4.134700802700442, 2.7949972248757664, -1.4584448495689168, 0.6358650797085171, -0.19847981428665007, 0.04200458351675313] self.cp_len = cp_len = fft_len/4 self.active_carriers = active_carriers = len(occupied_carriers[0])+4 ################################################## # Blocks ################################################## self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len") self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, "", 0, "", True) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), cp_len, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), cp_len, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer(fft_len, fft_len+cp_len, rolloff, packet_length_tag_key) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), ) #self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) #self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, packet_length_tag_key, 0) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), packet_length_tag_key, False) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.01, )) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0/fft_len) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0)) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0)) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0)) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self, 1)) ''' self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iir_filter_xxx_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data")