def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0, tx_freq=915e6, rx_freq=915e6): gr.top_block.__init__(self, "Batmannoguiofdm") self._lock = threading.RLock() ################################################## # Parameters ################################################## self.ampl = ampl self.args = args self.arq_timeout = arq_timeout self.dest_addr = dest_addr self.iface = iface self.max_arq_attempts = max_arq_attempts self.mtu = mtu self.ogradio_addr = ogradio_addr self.port = port self.rate = rate self.rx_antenna = rx_antenna self.rx_gain = rx_gain self.rx_lo_offset = rx_lo_offset self.samps_per_sym = samps_per_sym self.tx_gain = tx_gain self.tx_lo_offset = tx_lo_offset self.tx_freq = tx_freq self.rx_freq = rx_freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = rate ################################################## # Blocks ################################################## self.ofdm_radio_0 = ofdm_radio( rx_freq=rx_freq, rx_gain=rx_gain, rate=samp_rate, args=args, tx_freq=tx_freq, tx_gain=tx_gain, tx_lo_offset=tx_lo_offset, rx_lo_offset=rx_lo_offset, rx_ant=rx_antenna, ) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1532, False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ofdm_radio_0, 'msg_in')) self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_tuntap_pdu_0, 'pdus'))
def __init__(self, ampl=0.7, args='', mtu=255, port="12345", rate=1e6, rx_antenna="TX/RX", rx_freq=420e6, rx_gain=0, rx_lo_offset=0, samps_per_sym=4, tx_freq=440e6, tx_gain=20, tx_lo_offset=0): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ampl = ampl self.args = args self.mtu = mtu self.port = port self.rate = rate self.rx_antenna = rx_antenna self.rx_freq = rx_freq self.rx_gain = rx_gain self.rx_lo_offset = rx_lo_offset self.samps_per_sym = samps_per_sym self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_lo_offset = tx_lo_offset ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500000 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", args)), 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(rx_freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_bandwidth(2*samp_rate, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", args)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(2*samp_rate, 0) self.ofdm_radio_0 = ofdm_radio( rate=1e6, ) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char*1, "127.0.0.1", 12346, 1470, True) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "", port, mtu, False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "length") self.blocks_message_debug_0_0_1 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ofdm_radio_0, 'msg_in')) self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_message_debug_0_0_1, 'print_pdu')) self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.ofdm_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.ofdm_radio_0, 0))
def __init__(self, ampl=0.7, args='', arq_timeout=.1*0 + 0.04, dest_addr=-1, iface='tun0', max_arq_attempts=5 * 2, mtu=128, ogradio_addr=0, ogrx_freq=915e6, ogtx_freq=915e6, port="12345", rate=1e6, rx_antenna="TX/RX", rx_gain=65-20, rx_lo_offset=0, samps_per_sym=4, tx_gain=45, tx_lo_offset=0): grc_wxgui.top_block_gui.__init__(self, title="Ofdmgui") self._lock = threading.RLock() ################################################## # Parameters ################################################## self.ampl = ampl self.args = args self.arq_timeout = arq_timeout self.dest_addr = dest_addr self.iface = iface self.max_arq_attempts = max_arq_attempts self.mtu = mtu self.ogradio_addr = ogradio_addr self.ogrx_freq = ogrx_freq self.ogtx_freq = ogtx_freq self.port = port self.rate = rate self.rx_antenna = rx_antenna self.rx_gain = rx_gain self.rx_lo_offset = rx_lo_offset self.samps_per_sym = samps_per_sym self.tx_gain = tx_gain self.tx_lo_offset = tx_lo_offset ################################################## # Variables ################################################## self.user_tx_gain = user_tx_gain = tx_gain self.user_rx_gain = user_rx_gain = rx_gain self.tx_freq = tx_freq = 915e6 self.samp_rate = samp_rate = rate self.rx_freq = rx_freq = 915e6 ################################################## # Blocks ################################################## _user_tx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_tx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._user_tx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_tx_gain_sizer, value=self.user_tx_gain, callback=self.set_user_tx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_tx_gain_sizer) _user_rx_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._user_rx_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, label="RX Gain", converter=forms.float_converter(), proportion=0, ) self._user_rx_gain_slider = forms.slider( parent=self.GetWin(), sizer=_user_rx_gain_sizer, value=self.user_rx_gain, callback=self.set_user_rx_gain, minimum=0, maximum=90, num_steps=90, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_user_rx_gain_sizer) self._tx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label='tx_freq', converter=forms.float_converter(), ) self.Add(self._tx_freq_text_box) self._rx_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.rx_freq, callback=self.set_rx_freq, label='rx_freq', converter=forms.float_converter(), ) self.Add(self._rx_freq_text_box) self.ofdm_radio_0 = ofdm_radio( rx_freq=rx_freq, rx_gain=user_rx_gain, rate=samp_rate, args=args, tx_freq=tx_freq, tx_gain=user_tx_gain, tx_lo_offset=tx_lo_offset, rx_lo_offset=rx_lo_offset, rx_ant=rx_antenna, ) self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu(iface, mtu*0 + 1532, False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ofdm_radio_0, 'msg_in')) self.msg_connect((self.ofdm_radio_0, 'msg_out'), (self.blocks_tuntap_pdu_0, 'pdus'))