def test_001_t(self): np.set_printoptions(precision=2) n_frames = 3 alpha = .5 active = 8 M = 8 K = 16 L = 2 cp_len = 8 cs_len = 4 ramp_len = 4 block_len = M * K window_len = get_window_len(cp_len, M, K, cs_len) taps = get_frequency_domain_filter('rrc', alpha, M, K, L) taps /= np.sqrt(calculate_signal_energy(taps) / M) window_taps = get_raised_cosine_ramp(ramp_len, window_len) pn_symbols = get_random_qpsk(K) H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L) preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len, ramp_len)[0] smap = get_subcarrier_map(K, active, dc_free=True) ref = np.array([], dtype=complex) data = np.array([], dtype=complex) frame_len = window_len + len(preamble) frame_gap = np.zeros(frame_len) for i in range(n_frames): d = get_random_qpsk(active * M) dd = map_to_waveform_resources(d, active, K, smap) D = get_data_matrix(dd, K, group_by_subcarrier=False) b = gfdm_modulate_block(D, taps, M, K, L, False) b = add_cyclic_starfix(b, cp_len, cs_len) b = pinch_block(b, window_taps) ref = np.concatenate((ref, frame_gap, preamble, b)) data = np.concatenate((data, d)) src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(active, K, M, smap, True) mod = gfdm.simple_modulator_cc(M, K, L, taps) prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len, window_taps) preambler = blocks.vector_insert_c(preamble, window_len + len(preamble), 0) gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap), 0) dst = blocks.vector_sink_c() self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst) # self.tb.connect(src, mapper, dst) self.tb.run() res = np.array(dst.data())[0:len(ref)] self.assertComplexTuplesAlmostEqual(ref, res, 5)
def test_001_t(self): np.set_printoptions(precision=2) n_frames = 3 alpha = .5 active = 8 M = 8 K = 16 L = 2 cp_len = 8 cs_len = 4 ramp_len = 4 block_len = M * K window_len = get_window_len(cp_len, M, K, cs_len) taps = get_frequency_domain_filter('rrc', alpha, M, K, L) taps /= np.sqrt(calculate_signal_energy(taps) / M) window_taps = get_raised_cosine_ramp(ramp_len, window_len) pn_symbols = get_random_qpsk(K) H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L) preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len, ramp_len)[0] smap = get_subcarrier_map(K, active, dc_free=True) ref = np.array([], dtype=np.complex) data = np.array([], dtype=np.complex) frame_len = window_len + len(preamble) frame_gap = np.zeros(frame_len) for i in range(n_frames): d = get_random_qpsk(active * M) dd = map_to_waveform_resources(d, active, K, smap) D = get_data_matrix(dd, K, group_by_subcarrier=False) b = gfdm_modulate_block(D, taps, M, K, L, False) b = add_cyclic_starfix(b, cp_len, cs_len) b = pinch_block(b, window_taps) ref = np.concatenate((ref, frame_gap, preamble, b)) data = np.concatenate((data, d)) src = blocks.vector_source_c(data) mapper = gfdm.resource_mapper_cc(active, K, M, smap, True) mod = gfdm.simple_modulator_cc(M, K, L, taps) prefixer = gfdm.cyclic_prefixer_cc(block_len, cp_len, cs_len, ramp_len, window_taps) preambler = blocks.vector_insert_c(preamble, window_len + len(preamble), 0) gapper = blocks.vector_insert_c(frame_gap, frame_len + len(frame_gap), 0) dst = blocks.vector_sink_c() self.tb.connect(src, mapper, mod, prefixer, preambler, gapper, dst) # self.tb.connect(src, mapper, dst) self.tb.run() res = np.array(dst.data())[0:len(ref)] self.assertComplexTuplesAlmostEqual(ref, res, 5)
def __init__(self, M, syms_per_frame, sel_preamble, zero_pads, extra_pad=False): gr.hier_block2.__init__(self, "insert_preamble_vcvc", gr.io_signature(1, 1, gr.sizeof_gr_complex*M), gr.io_signature(1, 1, gr.sizeof_gr_complex*M), ) # Parameters self.M = M self.syms_per_frame = syms_per_frame; if sel_preamble == 0: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4)) elif sel_preamble == 1: # standard preamble with triple repetition self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4))*3 #[1/math.sqrt(3), -1j/math.sqrt(3), -1/math.sqrt(3), 1j/math.sqrt(3)]*((int)(M/4))*3 elif sel_preamble ==2: # IAM-R preamble [1, -1,-1, 1] self.center_preamble = center_preamble = [1, -1, -1, 1]*((int)(M/4)) else: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4)) self.preamble = preamble = [0]*M*zero_pads+center_preamble+[0]*M*zero_pads if extra_pad: self.preamble = preamble = preamble + [0]*M # Variables self.preamble_length = len(preamble) # Assertions assert (M>0 and syms_per_frame>0), "M and syms_per_frame should be larger than zero!" assert ( int(math.log(M,2))==math.log(M,2)), "M should be of 2^n!" assert (self.preamble_length>0), "Preamble should be predefined." assert (self.preamble_length%M == 0), "preamble should be a multiple of M" # Blocks self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, M) self.blocks_vector_insert_x_0 = blocks.vector_insert_c(preamble, 2*syms_per_frame*M+self.preamble_length, 0) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, M) # Connections self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self, 0))
def test_001_t(self): np.set_printoptions(precision=2) n_frames = 3 alpha = .5 M = 8 K = 4 L = 2 cp_len = 8 ramp_len = 4 block_len = M * K window_len = get_window_len(cp_len, M, K) taps = get_frequency_domain_filter('rrc', alpha, M, K, L) window_taps = get_raised_cosine_ramp(ramp_len, window_len) pn_symbols = get_random_qpsk(K) H_preamble = get_frequency_domain_filter('rrc', alpha, 2, K, L) preamble = get_sync_symbol(pn_symbols, H_preamble, K, L, cp_len, ramp_len) ref = np.array([], dtype=np.complex) data = np.array([], dtype=np.complex) for i in range(n_frames): d = get_random_qpsk(block_len) D = get_data_matrix(d, K, group_by_subcarrier=False) b = gfdm_modulate_block(D, taps, M, K, L, False) b = add_cyclic_prefix(b, cp_len) b = pinch_block(b, window_taps) ref = np.concatenate((ref, preamble, b)) data = np.concatenate((data, d)) src = blocks.vector_source_c(data) mod = gfdm.simple_modulator_cc(M, K, L, taps) prefixer = gfdm.cyclic_prefixer_cc(cp_len, ramp_len, block_len, window_taps) preambler = blocks.vector_insert_c(preamble, window_len + len(preamble), 0) dst = blocks.vector_sink_c() self.tb.connect(src, mod, prefixer, preambler, dst) self.tb.run() res = np.array(dst.data())[0:len(ref)] self.assertComplexTuplesAlmostEqual(ref, res, 5)
def __init__(self): gr.top_block.__init__(self, "Mod Ook Sim Inputfile") Qt.QWidget.__init__(self) self.setWindowTitle("Mod Ook Sim Inputfile") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "mod_OOK_sim_inputfile") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100e6 self.freq_carrier = freq_carrier = 10e6 self.data_2 = data_2 = (1, 1) self.bitstream = bitstream = 600 self.Event = Event = '@FlUxIuS - Synacktiv.com / PentHertz.com' ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.1) self.qtgui_time_sink_x_0.set_y_axis(-10, 10) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_vector_source_x_0 = blocks.vector_source_c( data_2, True, 1, []) self.blocks_vector_insert_x_0 = blocks.vector_insert_c( (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0), len(data_2) + 16, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, bitstream) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, 'OOK_gen_inputfile.cfile', False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq_carrier, 1, 0) self._Event_tool_bar = Qt.QToolBar(self) if None: self._Event_formatter = None else: self._Event_formatter = lambda x: str(x) self._Event_tool_bar.addWidget( Qt.QLabel('GreHack Workshop 2019' + ": ")) self._Event_label = Qt.QLabel(str(self._Event_formatter(self.Event))) self._Event_tool_bar.addWidget(self._Event_label) self.top_layout.addWidget(self._Event_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_vector_insert_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Not titled yet") Qt.QWidget.__init__(self) self.setWindowTitle("Not titled yet") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "send") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 25e5 self.payload = payload = np.load("payload.npy") self.padding = padding = list(np.zeros(32)) self.carrier = carrier = 915552 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 433e6, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0.enable_rf_freq(False) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.blocks_vector_source_x_0 = blocks.vector_source_c( payload, True, 1, []) self.blocks_vector_insert_x_0 = blocks.vector_insert_c( padding, len(payload) + len(padding), 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 1250) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, carrier, 1, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_vector_insert_x_0, 0))
def __init__(self, M, syms_per_frame, sel_preamble, zero_pads, extra_pad=False): gr.hier_block2.__init__( self, "insert_preamble_vcvc", gr.io_signature(1, 1, gr.sizeof_gr_complex * M), gr.io_signature(1, 1, gr.sizeof_gr_complex * M), ) # Parameters self.M = M self.syms_per_frame = syms_per_frame if sel_preamble == 0: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j] * ( (int)(M / 4)) elif sel_preamble == 1: # standard preamble with triple repetition self.center_preamble = center_preamble = [1, -1j, -1, 1j] * ( (int)(M / 4) ) * 3 #[1/math.sqrt(3), -1j/math.sqrt(3), -1/math.sqrt(3), 1j/math.sqrt(3)]*((int)(M/4))*3 elif sel_preamble == 2: # IAM-R preamble [1, -1,-1, 1] self.center_preamble = center_preamble = [1, -1, -1, 1] * ( (int)(M / 4)) else: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j] * ( (int)(M / 4)) self.preamble = preamble = [0] * M * zero_pads + center_preamble + [ 0 ] * M * zero_pads if extra_pad: self.preamble = preamble = preamble + [0] * M # Variables self.preamble_length = len(preamble) # Assertions assert (M > 0 and syms_per_frame > 0 ), "M and syms_per_frame should be larger than zero!" assert (int(math.log(M, 2)) == math.log(M, 2)), "M should be of 2^n!" assert (self.preamble_length > 0), "Preamble should be predefined." assert (self.preamble_length % M == 0), "preamble should be a multiple of M" # Blocks self.blocks_vector_to_stream_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, M) self.blocks_vector_insert_x_0 = blocks.vector_insert_c( preamble, 2 * syms_per_frame * M + self.preamble_length, 0) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, M) # Connections self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="IEEE 802.15.4 Transceiver using CSS PHY") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.text_msg = text_msg = "This is a test message" self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg) + 15) self.samp_rate = samp_rate = 32e6 self.phi = phi = 10 self.pad_len = pad_len = c.nsamp_frame * 0 self.msg_interval = msg_interval = 1000 self.freq_off = freq_off = 0 self.enable = enable = 1.0 self.delay = delay = 0 self.ampl = ampl = 0 ################################################## # Blocks ################################################## _pad_len_sizer = wx.BoxSizer(wx.VERTICAL) self._pad_len_text_box = forms.text_box( parent=self.GetWin(), sizer=_pad_len_sizer, value=self.pad_len, callback=self.set_pad_len, label="Pad Length", converter=forms.float_converter(), proportion=0, ) self._pad_len_slider = forms.slider( parent=self.GetWin(), sizer=_pad_len_sizer, value=self.pad_len, callback=self.set_pad_len, minimum=0, maximum=10000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_pad_len_sizer) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Waterfall") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Time") self.nb.AddPage(grc_wxgui.Panel(self.nb), "RX Symbols") self.Add(self.nb) _msg_interval_sizer = wx.BoxSizer(wx.VERTICAL) self._msg_interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, label="Message Interval [ms]", converter=forms.float_converter(), proportion=0, ) self._msg_interval_slider = forms.slider( parent=self.GetWin(), sizer=_msg_interval_sizer, value=self.msg_interval, callback=self.set_msg_interval, minimum=1, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_msg_interval_sizer) _freq_off_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_off_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, label="Frequency Offset", converter=forms.float_converter(), proportion=0, ) self._freq_off_slider = forms.slider( parent=self.GetWin(), sizer=_freq_off_sizer, value=self.freq_off, callback=self.set_freq_off, minimum=-1e5, maximum=1e5, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_off_sizer) _delay_sizer = wx.BoxSizer(wx.VERTICAL) self._delay_text_box = forms.text_box( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, label="Delay", converter=forms.float_converter(), proportion=0, ) self._delay_slider = forms.slider( parent=self.GetWin(), sizer=_delay_sizer, value=self.delay, callback=self.set_delay, minimum=0, maximum=100000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_delay_sizer) _ampl_sizer = wx.BoxSizer(wx.VERTICAL) self._ampl_text_box = forms.text_box( parent=self.GetWin(), sizer=_ampl_sizer, value=self.ampl, callback=self.set_ampl, label="Noise Amplitude", converter=forms.float_converter(), proportion=0, ) self._ampl_slider = forms.slider( parent=self.GetWin(), sizer=_ampl_sizer, value=self.ampl, callback=self.set_ampl, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_ampl_sizer) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="RX Waterfall", ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_3 = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="RX Correlator Output", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.wxgui_scopesink2_3.win) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.nb.GetPage(2).GetWin(), title="RX Time Signal", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_2.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="RX FFT", peak_hold=False, ) self.nb.GetPage(1).Add(self.wxgui_fftsink2_0.win) _phi_sizer = wx.BoxSizer(wx.VERTICAL) self._phi_text_box = forms.text_box( parent=self.GetWin(), sizer=_phi_sizer, value=self.phi, callback=self.set_phi, label="Phi", converter=forms.float_converter(), proportion=0, ) self._phi_slider = forms.slider( parent=self.GetWin(), sizer=_phi_sizer, value=self.phi, callback=self.set_phi, minimum=2, maximum=20, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_phi_sizer) self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack( ([129]), ([131]), ([132]), ([23, 42])) self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True) self.ieee802_15_4_css_phy_1 = ieee802_15_4_css_phy( bits_per_cw=c.bits_per_symbol, chirp_seq=c.chirp_seq, codewords=c.codewords, intlv_seq=c.intlv_seq, len_sub=38, nbytes_payload=c.phy_packetsize_bytes, nsamp_frame=c.nsamp_frame, num_subchirps=c.n_subchirps, nzeros_padding=c.padded_zeros, phr=c.PHR, preamble=c.preamble, sfd=c.SFD, sym_per_frame=c.nsym_frame, threshold=0.95, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, ) self._enable_chooser = forms.button( parent=self.GetWin(), value=self.enable, callback=self.set_enable, label="TX Enable", choices=[1.0, 0.0], labels=['on', 'off'], ) self.Add(self._enable_chooser) self.blocks_vector_insert_x_0 = blocks.vector_insert_c( ([0 for i in range(pad_len)]), 3 * c.nsamp_frame, 3 * c.nsamp_frame) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern(text_msg), msg_interval) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_SIN_WAVE, freq_off, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, ampl, 0, 8192) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 10) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.ieee802_15_4_rime_stack_0, 'bcin')) self.msg_connect((self.ieee802_15_4_css_phy_1, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in')) self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_css_phy_1, 'txin')) self.msg_connect((self.ieee802_15_4_mac_0, 'app out'), (self.ieee802_15_4_rime_stack_0, 'fromMAC')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'bcout'), (self.blocks_socket_pdu_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'), (self.ieee802_15_4_mac_0, 'app in')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.ieee802_15_4_css_phy_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0))
def __init__(self, M, syms_per_frame, start, end, sel_eq, sel_preamble, zero_pads, extra_pad=False): gr.hier_block2.__init__(self, "fbmc_insert_preamble_mu_vcvc", gr.io_signature(1, 1, gr.sizeof_gr_complex*M), gr.io_signature(1, 1, gr.sizeof_gr_complex*M), ) # Parameters self.M = M self.syms_per_frame = syms_per_frame; self.sel_eq = sel_eq if sel_preamble == 0: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4)) elif sel_preamble == 1: # standard preamble with triple repetition self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4))*3 #[1/math.sqrt(3), -1j/math.sqrt(3), -1/math.sqrt(3), 1j/math.sqrt(3)]*((int)(M/4))*3 elif sel_preamble ==2: # IAM-R preamble [1, -1,-1, 1] self.center_preamble = center_preamble = [1, -1, -1, 1]*((int)(M/4)) else: # standard one vector center preamble [1,-j,-1,j] self.center_preamble = center_preamble = [1, -1j, -1, 1j]*((int)(M/4)) # modify center preamble so that unused subchannels would be nulled. center = list() for i in range(len(center_preamble)): if ((sel_eq == 1) or (sel_eq == 2)): # for now it's assumed that subchannel 0 won't be ever used. assert(start>0), "assumption: subchannel #0 won't be ever used." assert(end<M-1), "assumption: subchannel #M-1 won't be ever used." if ((i%M)<=(end+1) and (i%M)>=(start-1)): center.append(center_preamble[i]) else: center.append(0) else: if ((i%M)<=end and (i%M)>=start): center.append(center_preamble[i]) else: center.append(0) self.preamble = preamble = [0]*M*zero_pads+center+[0]*M*zero_pads if extra_pad: self.preamble = preamble = preamble + [0]*M # Variables self.preamble_length = len(preamble) # Assertions assert (M>0 and syms_per_frame>0), "M and syms_per_frame should be larger than zero!" assert ( int(math.log(M,2))==math.log(M,2)), "M should be of 2^n!" assert (self.preamble_length>0), "Preamble should be predefined." assert (self.preamble_length%M == 0), "preamble should be a multiple of M" # Blocks self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, M) self.blocks_vector_insert_x_0 = blocks.vector_insert_c(preamble, 2*syms_per_frame*M+self.preamble_length, 0) self.blocks_stream_to_vector_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, M) # Connections self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_vector_insert_x_0, 0)) self.connect((self.blocks_vector_insert_x_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self, 0))