def __init__(self): gr.top_block.__init__(self, "BER AWGN Test OQPSK") ################################################## # Variables ################################################## self.snr = snr = 0 self.c = c = ieee802_15_4.css_phy(slow_rate=True, phy_packetsize_bytes=127) ################################################## # Blocks ################################################## self.ieee802_15_4_oqpsk_phy_nosync_0 = ieee802_15_4_oqpsk_phy_nosync( payload_len=c.phy_packetsize_bytes, ) self.ieee802_15_4_make_pair_with_blob_0 = ieee802_15_4.make_pair_with_blob(np.random.randint(0,256,(c.phy_packetsize_bytes,))) self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.cons(pmt.PMT_NIL, pmt.string_to_symbol("trigger")), 1, 5, True, False) # self.msg_trigger = blocks.message_strobe(pmt.cons(pmt.intern("trigger"), pmt.intern("dummy")), 1000) self.comp_bits = ieee802_15_4.compare_blobs(packet_error_mode=False) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 10**(-snr/10), 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.ieee802_15_4_oqpsk_phy_nosync_0, 0)) self.connect((self.ieee802_15_4_oqpsk_phy_nosync_0, 0), (self.blocks_add_xx_0_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.ieee802_15_4_oqpsk_phy_nosync_0, "txin") self.msg_connect(self.foo_periodic_msg_source_0, "out", self.ieee802_15_4_make_pair_with_blob_0, "in") # self.msg_connect(self.msg_trigger, "strobe", self.ieee802_15_4_make_pair_with_blob_0, "in") self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.comp_bits, "ref") self.msg_connect(self.ieee802_15_4_oqpsk_phy_nosync_0, "rxout", self.comp_bits, "test") self.msg_connect(self.ieee802_15_4_oqpsk_phy_nosync_0, "rxout", self.ieee802_15_4_make_pair_with_blob_0, "in")
def setUp(self): print "NOTE: THIS TEST USES THE INSTALLED VERSION OF THE LIBRARY ieee802_15_4!" self.tb = gr.top_block() self.p = ieee802_15_4_installed.css_phy()
def __init__(self): gr.top_block.__init__(self, "IEEE 802.15.4 Transceiver using CSS PHY") Qt.QWidget.__init__(self) self.setWindowTitle("IEEE 802.15.4 Transceiver using CSS PHY") 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", "transceiver_CSS_USRP") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.text_msg = text_msg = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.tx_gain = tx_gain = 0.75 self.samp_rate = samp_rate = 1e6 self.rx_gain = rx_gain = 0.75 self.interval = interval = 300 self.freq = freq = 2480000000 self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15) ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._interval_range = Range(10, 1000, 1, 300, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int) self.top_layout.addWidget(self._interval_win) self._freq_options = [1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)] self._freq_labels = [str(i) for i in range(11, 27)] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel('Channel'+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('addr=192.168.10.4', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(('addr=192.168.10.6', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_normalized_gain(tx_gain, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] 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_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) 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_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def set_text_msg(self, text_msg): self.text_msg = text_msg self.set_c(ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(self.text_msg)+15)) self.blocks_message_strobe_0.set_msg(pmt.intern(self.text_msg))
def setUp (self): print "NOTE: THIS TEST USES THE INSTALLED VERSION OF THE LIBRARY ieee802_15_4!" self.tb = gr.top_block () self.p = ieee802_15_4_installed.css_phy()
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 = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg) + 15) ################################################## # Blocks ################################################## 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) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="TX/RX Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=1, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)], labels=[i for i in range(11, 27)], style=wx.RA_HORIZONTAL, ) self.Add(self._freq_chooser) 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=freq, 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) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.4", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("J1", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("addr=192.168.10.6", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.trafficGenerator_Distribution_0 = trafficGenerator.Distribution( 0, 100, 4, 5, int) 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._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "", "52001", 10000, False) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern(text_msg), msg_interval) ################################################## # 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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.trafficGenerator_Distribution_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 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 = "Hello World, this is GNU Radio using the IEEE 802.15.4 CSS PHY!" self.freq = freq = 2480000000 self.samp_rate = samp_rate = 1e6 self.msg_interval = msg_interval = 1000 self.gain = gain = 20 self.cur_freq = cur_freq = freq self.c = c = ieee802_15_4.css_phy(chirp_number=4, phy_packetsize_bytes=len(text_msg)+15) ################################################## # Blocks ################################################## 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) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="TX/RX Gain", converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=1, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[1000000 * (2400 + 5 * (i - 10)) for i in range(11, 27)], labels=[i for i in range(11, 27)], style=wx.RA_HORIZONTAL, ) self.Add(self._freq_chooser) 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=freq, 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) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_gain(gain, 0) self.uhd_usrp_sink_1.set_antenna("TX/RX", 0) 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._cur_freq_static_text = forms.static_text( parent=self.GetWin(), value=self.cur_freq, callback=self.set_cur_freq, label="Current center frequency", converter=forms.float_converter(), ) self.Add(self._cur_freq_static_text) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "8048", 10000, False) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern(text_msg), msg_interval) ################################################## # 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.ieee802_15_4_css_phy_1, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.ieee802_15_4_css_phy_1, 1), (self.wxgui_scopesink2_3, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_css_phy_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "BER AWGN Test CSS SD/HD vs OQPSK") ################################################## # Variables ################################################## self.snr = snr = 0 self.c = c = ieee802_15_4.css_phy(slow_rate=False, phy_packetsize_bytes=127) ################################################## # Blocks ################################################## self.ieee802_15_4_oqpsk_phy_nosync_0 = ieee802_15_4_oqpsk_phy_nosync( payload_len=c.phy_packetsize_bytes, ) self.ieee802_15_4_make_pair_with_blob_0 = ieee802_15_4.make_pair_with_blob(np.random.randint(0,256,(c.phy_packetsize_bytes,))) self.ieee802_15_4_css_phy_sd_0 = ieee802_15_4_css_phy_sd( phr=c.PHR, nbytes_payload=c.phy_packetsize_bytes, bits_per_cw=c.bits_per_symbol, codewords=c.codewords, intlv_seq=c.intlv_seq, sym_per_frame=c.nsym_frame, num_subchirps=c.n_subchirps, chirp_seq=c.chirp_seq, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, len_sub=38, nzeros_padding=c.padded_zeros, preamble=c.preamble, sfd=c.SFD, nsamp_frame=c.nsamp_frame, ) self.ieee802_15_4_css_phy_hd_0 = ieee802_15_4_css_phy_hd( phr=c.PHR, nbytes_payload=c.phy_packetsize_bytes, bits_per_cw=c.bits_per_symbol, codewords=c.codewords, intlv_seq=c.intlv_seq, sym_per_frame=c.nsym_frame, num_subchirps=c.n_subchirps, chirp_seq=c.chirp_seq, time_gap_1=c.time_gap_1, time_gap_2=c.time_gap_2, len_sub=38, nzeros_padding=c.padded_zeros, preamble=c.preamble, sfd=c.SFD, nsamp_frame=c.nsamp_frame, ) self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.cons(pmt.PMT_NIL, pmt.string_to_symbol("trigger")), 10, 100, True, False) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((1.1687, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1.1687, )) self.blocks_add_xx_0_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 10**(-snr/10), 0) self.comp_bits_sd = ieee802_15_4.compare_blobs() self.comp_bits_hd = ieee802_15_4.compare_blobs() ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self.ieee802_15_4_css_phy_sd_0, 0)) self.connect((self.ieee802_15_4_css_phy_sd_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.ieee802_15_4_css_phy_hd_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.ieee802_15_4_css_phy_hd_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.ieee802_15_4_css_phy_sd_0, "txin") self.msg_connect(self.foo_periodic_msg_source_0, "out", self.ieee802_15_4_make_pair_with_blob_0, "in") self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.ieee802_15_4_css_phy_hd_0, "txin") self.msg_connect(self.ieee802_15_4_css_phy_sd_0, "rxout", self.comp_bits_sd, "test") self.msg_connect(self.ieee802_15_4_css_phy_hd_0, "rxout", self.comp_bits_hd, "test") self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.comp_bits_hd, "ref") self.msg_connect(self.ieee802_15_4_make_pair_with_blob_0, "out", self.comp_bits_sd, "ref") self.msg_connect(self.ieee802_15_4_css_phy_sd_0, "rxout", self.ieee802_15_4_make_pair_with_blob_0, "in")
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))