def __init__(self): gr.top_block.__init__(self, "Handshake Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Handshake Receiver") 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", "handshake_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_rx_gain = range_rx_gain = 15 self.range_mu = range_mu = 0.6 self.usrp_device_address = usrp_device_address = "addr=192.168.10.2" self.tx_center_frequency = tx_center_frequency = 400000000 self.timeout_duration_ms = timeout_duration_ms = 1000 self.system_time_granularity_us = system_time_granularity_us = 1000 self.source_address = source_address = 1 self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = range_rx_gain self.rx_center_frequency = rx_center_frequency = 400000000 self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps) self.reserved_field_II = reserved_field_II = 6 self.reserved_field_I = reserved_field_I = 5 self.preamble_detector_threshold = preamble_detector_threshold = 30 self.mu = mu = range_mu self.min_backoff_ms = min_backoff_ms = 50 self.max_num_retransmission = max_num_retransmission = 5 self.max_buffer_size = max_buffer_size = 10 self.len_source_address = len_source_address = 1 self.len_reserved_field_II = len_reserved_field_II = 2 self.len_reserved_field_I = len_reserved_field_I = 2 self.len_payload_length = len_payload_length = 1 self.len_num_transmission = len_num_transmission = 1 self.len_frame_type = len_frame_type = 1 self.len_frame_index = len_frame_index = 1 self.len_destination_address = len_destination_address = 1 self.increase_index = increase_index = 1 self.frame_type = frame_type = 1 self.frame_index = frame_index = 0 self.experiment_duration_s = experiment_duration_s = 1000 self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128] self.develop_mode_list = develop_mode_list = [0] self.destination_address = destination_address = 2 self.cs_threshold = cs_threshold = 0.005 self.cs_duration = cs_duration = 50 self.counter_id = counter_id = 20 self.backoff_time_unit_ms = backoff_time_unit_ms = 50 self.apply_address_check = apply_address_check = 1 ################################################## # Blocks ################################################## self._range_rx_gain_range = Range(0, 60, 1, 15, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._range_mu_range = Range(0, 1, 0.01, 0.6, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.dmdl_type_check_0 = dmdl.type_check(0, 25, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1) self.dmdl_sending_0 = dmdl.sending(0, 11, gnuradio.digital.constellation_qpsk().base(), diff_preamble_128, samp_rate, sps, system_time_granularity_us, usrp_device_address, tx_center_frequency, 0.005, 0.05, "t1TXs", "Tfr", 0, 1, 0) self.dmdl_receiving_0 = dmdl.receiving(1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency) self.dmdl_probe_0_0_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, "/home/inets/source/gr-inets/results/", "t2RXe", 1) self.dmdl_probe_0_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, "/home/inets/source/gr-inets/results/", "t2CS", 1) self.dmdl_probe_0 = dmdl.probe(0, 100, 0, 0, 0.01, 1, "/home/inets/source/gr-inets/results/", "t2e", 1) self.dmdl_framing_0 = dmdl.framing(0, 17, 2, 1, 0, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_frame_analysis_0 = dmdl.frame_analysis(0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address) self.dmdl_error_detection_0 = dmdl.error_detection(0, 9) self.dmdl_address_check_0 = dmdl.address_check(0, 17, source_address, 0) ################################################## # Connections ################################################## self.msg_connect((self.dmdl_address_check_0, 'P'), (self.dmdl_probe_0_0_0, 'B')) self.msg_connect((self.dmdl_address_check_0, 'P'), (self.dmdl_type_check_0, 'B')) self.msg_connect((self.dmdl_error_detection_0, 'P'), (self.dmdl_address_check_0, 'B')) self.msg_connect((self.dmdl_frame_analysis_0, 'P'), (self.dmdl_error_detection_0, 'B')) self.msg_connect((self.dmdl_framing_0, 'E'), (self.dmdl_receiving_0, 'RXI')) self.msg_connect((self.dmdl_receiving_0, 'E'), (self.dmdl_frame_analysis_0, 'B')) self.msg_connect((self.dmdl_receiving_0, 'RXO'), (self.dmdl_sending_0, 'B')) self.msg_connect((self.dmdl_sending_0, 'E'), (self.dmdl_probe_0, 'B')) self.msg_connect((self.dmdl_sending_0, 'RXO'), (self.dmdl_receiving_0, 'RXI')) self.msg_connect((self.dmdl_type_check_0, 'ACK'), (self.dmdl_framing_0, 'B'))
def __init__(self, constellation=gnuradio.digital.constellation_qpsk().base(), preamble=[]): gr.top_block.__init__(self, "Ieee 80211 Dcf Twoway Handshake I") Qt.QWidget.__init__(self) self.setWindowTitle("Ieee 80211 Dcf Twoway Handshake I") 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", "IEEE_80211_DCF_twoway_handshake_I") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.constellation = constellation self.preamble = preamble ################################################## # Variables ################################################## self.sps = sps = 4 self.usrp_device_address = usrp_device_address = "addr=192.168.10.2" self.tx_center_frequency = tx_center_frequency = 3.9e8 self.timeout_duration_ms = timeout_duration_ms = 100 self.system_time_granularity_us = system_time_granularity_us = 10 self.source_address = source_address = 1 self.slot_time = slot_time = 8 self.samp_rate = samp_rate = 400000 self.rx_gain = rx_gain = 0 self.rx_center_frequency = rx_center_frequency = 3.9e8 self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.mu = mu = 0.6 self.min_window_size = min_window_size = 1 self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.destination_address = destination_address = 2 self.cs_threshold = cs_threshold = 0.001 self.Single_rxp_time_s = Single_rxp_time_s = 60 self.SIFS = SIFS = 10 ################################################## # Blocks ################################################## self.dmdl_type_check_0_0 = dmdl.type_check(0, 25, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) self.dmdl_type_check_0 = dmdl.type_check(0, 25, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) self.dmdl_timer_0_0 = dmdl.timer(0, 5, 0, 20, 10, 0) self.dmdl_timer_0 = dmdl.timer(0, 5, 0, 50, 10, 0) self.dmdl_timeout_0 = dmdl.timeout(0, 10, 100, 1000, 0) self.dmdl_start_0 = dmdl.start(1, 10) self.dmdl_sending_0 = dmdl.sending( 0, 11, gnuradio.digital.constellation_qpsk().base(), diff_preamble_128, samp_rate, sps, system_time_granularity_us, usrp_device_address, tx_center_frequency, 0.005, 0.05, "t1TXs", "Tfr", 0, 1, 0) self.dmdl_resend_check_0 = dmdl.resend_check(0, 24, 6) self.dmdl_receiving_0 = dmdl.receiving( 1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency) self.dmdl_probe_0_0 = dmdl.probe( 1, 2, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "", 1) self.dmdl_path_0 = dmdl.path(0, 44, 1, "") self.dmdl_framing_0_0 = dmdl.framing(0, 17, 2, 1, 0, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_framing_0 = dmdl.framing(0, 17, 1, 1, 1, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_frame_analysis_0 = dmdl.frame_analysis( 0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address) self.dmdl_error_detection_0 = dmdl.error_detection(0, 9) self.dmdl_dummy_source_0 = dmdl.dummy_source(0, 23, 100, 1, 1) self.dmdl_carrier_sensing_0 = dmdl.carrier_sensing( 0, 11, 2, 100, cs_threshold, system_time_granularity_us, 100, 20) self.dmdl_backoff_0_0 = dmdl.backoff(0, 11, 1, 10, 100, 400, 0, 0.005, 10, 1, 6) self.dmdl_backoff_0 = dmdl.backoff(0, 3, 1, 10, 100, 400, 0, 0.005, 10, 1, 2) self.dmdl_attribute_editor_0 = dmdl.attribute_editor( 0, 16, "num_transmission", 1, 1) self.dmdl_address_check_0 = dmdl.address_check(0, 17, source_address, 0) ################################################## # Connections ################################################## self.msg_connect((self.dmdl_address_check_0, 'Pass'), (self.dmdl_type_check_0, 'Begin')) self.msg_connect((self.dmdl_attribute_editor_0, 'cmd_out'), (self.dmdl_path_0, 'Begin')) self.msg_connect((self.dmdl_backoff_0, 'End'), (self.dmdl_resend_check_0, 'Begin')) self.msg_connect((self.dmdl_backoff_0_0, 'End'), (self.dmdl_dummy_source_0, 'Begin')) self.msg_connect((self.dmdl_carrier_sensing_0, 'Fail'), (self.dmdl_backoff_0, 'Begin')) self.msg_connect((self.dmdl_carrier_sensing_0, 'cs_Threshold'), (self.dmdl_backoff_0, 'cs_Threshold')) self.msg_connect((self.dmdl_carrier_sensing_0, 'cs_Threshold'), (self.dmdl_backoff_0_0, 'cs_Threshold')) self.msg_connect((self.dmdl_carrier_sensing_0, 'Pass'), (self.dmdl_receiving_0, 'rx_switch_in')) self.msg_connect((self.dmdl_dummy_source_0, 'End'), (self.dmdl_framing_0, 'Begin')) self.msg_connect((self.dmdl_error_detection_0, 'Pass'), (self.dmdl_address_check_0, 'Begin')) self.msg_connect((self.dmdl_frame_analysis_0, 'Pass'), (self.dmdl_error_detection_0, 'Begin')) self.msg_connect((self.dmdl_frame_analysis_0, 'Pass'), (self.dmdl_probe_0_0, 'info_in')) self.msg_connect((self.dmdl_framing_0, 'End'), (self.dmdl_path_0, 'Begin')) self.msg_connect((self.dmdl_framing_0_0, 'End'), (self.dmdl_timer_0_0, 'Begin')) self.msg_connect((self.dmdl_path_0, 'End'), (self.dmdl_carrier_sensing_0, 'Begin')) self.msg_connect((self.dmdl_path_0, 'End'), (self.dmdl_timer_0, 'Begin')) self.msg_connect((self.dmdl_receiving_0, 'rx_power_out'), (self.dmdl_backoff_0, 'Rssi')) self.msg_connect((self.dmdl_receiving_0, 'rx_power_out'), (self.dmdl_backoff_0_0, 'Rssi')) self.msg_connect((self.dmdl_receiving_0, 'rx_power_out'), (self.dmdl_carrier_sensing_0, 'Rssi')) self.msg_connect((self.dmdl_receiving_0, 'rx_frame_out'), (self.dmdl_frame_analysis_0, 'Begin')) self.msg_connect((self.dmdl_receiving_0, 'rx_switch_out'), (self.dmdl_sending_0, 'in')) self.msg_connect((self.dmdl_resend_check_0, 'Pass'), (self.dmdl_attribute_editor_0, 'cmd_in')) self.msg_connect((self.dmdl_resend_check_0, 'Fail'), (self.dmdl_dummy_source_0, 'Begin')) self.msg_connect((self.dmdl_sending_0, 'rx_control_out'), (self.dmdl_receiving_0, 'rx_switch_in')) self.msg_connect((self.dmdl_sending_0, 'DATA'), (self.dmdl_timeout_0, 'Begin_DATA')) self.msg_connect((self.dmdl_start_0, 'Begin'), (self.dmdl_dummy_source_0, 'Begin')) self.msg_connect((self.dmdl_timeout_0, 'End'), (self.dmdl_type_check_0_0, 'Begin')) self.msg_connect((self.dmdl_timer_0, 'End'), (self.dmdl_carrier_sensing_0, 'Stop')) self.msg_connect((self.dmdl_timer_0_0, 'End'), (self.dmdl_receiving_0, 'rx_switch_in')) self.msg_connect((self.dmdl_type_check_0, 'DATA'), (self.dmdl_framing_0_0, 'Begin')) self.msg_connect((self.dmdl_type_check_0, 'ACK'), (self.dmdl_timeout_0, 'confIrm_ACK')) self.msg_connect((self.dmdl_type_check_0_0, 'DATA'), (self.dmdl_backoff_0, 'Begin')) self.msg_connect((self.dmdl_type_check_0_0, 'ACK'), (self.dmdl_backoff_0_0, 'Begin'))
def __init__(self): gr.top_block.__init__(self, "Simple Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("Simple Receiver") 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", "simple_receiver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_tx_gain = range_tx_gain = 15 self.range_rx_gain = range_rx_gain = 0 self.range_mu = range_mu = 0.6 self.usrp_device_address = usrp_device_address = "addr=192.168.10.2" self.tx_gain = tx_gain = range_tx_gain self.tx_center_frequency = tx_center_frequency = 400000000 self.source_address = source_address = 2 self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = range_rx_gain self.rx_center_frequency = rx_center_frequency = 400000000 self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.preamble_detector_threshold = preamble_detector_threshold = 30 self.mu = mu = range_mu self.initial_frame_index = initial_frame_index = 1 self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.destination_address = destination_address = 1 self.cs_threshold = cs_threshold = 0.005 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'General') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'MAC') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'PHY and Radio') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'System') self.top_grid_layout.addWidget(self.tabs, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._usrp_device_address_tool_bar = Qt.QToolBar(self) self._usrp_device_address_tool_bar.addWidget( Qt.QLabel('USRP address' + ": ")) self._usrp_device_address_line_edit = Qt.QLineEdit( str(self.usrp_device_address)) self._usrp_device_address_tool_bar.addWidget( self._usrp_device_address_line_edit) self._usrp_device_address_line_edit.returnPressed.connect( lambda: self.set_usrp_device_address( str(str(self._usrp_device_address_line_edit.text().toAscii())) )) self.tabs_grid_layout_0.addWidget(self._usrp_device_address_tool_bar) self._sps_tool_bar = Qt.QToolBar(self) self._sps_tool_bar.addWidget(Qt.QLabel('Sample per Symbol' + ": ")) self._sps_line_edit = Qt.QLineEdit(str(self.sps)) self._sps_tool_bar.addWidget(self._sps_line_edit) self._sps_line_edit.returnPressed.connect(lambda: self.set_sps( int(str(self._sps_line_edit.text().toAscii())))) self.tabs_grid_layout_2.addWidget(self._sps_tool_bar) self._source_address_tool_bar = Qt.QToolBar(self) self._source_address_tool_bar.addWidget( Qt.QLabel('Node address' + ": ")) self._source_address_line_edit = Qt.QLineEdit(str(self.source_address)) self._source_address_tool_bar.addWidget(self._source_address_line_edit) self._source_address_line_edit.returnPressed.connect( lambda: self.set_source_address( int(str(self._source_address_line_edit.text().toAscii())))) self.tabs_grid_layout_0.addWidget(self._source_address_tool_bar) self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('Sampling rate' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( int(str(self._samp_rate_line_edit.text().toAscii())))) self.tabs_grid_layout_2.addWidget(self._samp_rate_tool_bar) self._rx_center_frequency_tool_bar = Qt.QToolBar(self) self._rx_center_frequency_tool_bar.addWidget( Qt.QLabel('RX center frequency [Hz]' + ": ")) self._rx_center_frequency_line_edit = Qt.QLineEdit( str(self.rx_center_frequency)) self._rx_center_frequency_tool_bar.addWidget( self._rx_center_frequency_line_edit) self._rx_center_frequency_line_edit.returnPressed.connect( lambda: self.set_rx_center_frequency( int(str(self._rx_center_frequency_line_edit.text().toAscii())) )) self.tabs_grid_layout_2.addWidget(self._rx_center_frequency_tool_bar) self._initial_frame_index_tool_bar = Qt.QToolBar(self) self._initial_frame_index_tool_bar.addWidget( Qt.QLabel('Initial frame index' + ": ")) self._initial_frame_index_line_edit = Qt.QLineEdit( str(self.initial_frame_index)) self._initial_frame_index_tool_bar.addWidget( self._initial_frame_index_line_edit) self._initial_frame_index_line_edit.returnPressed.connect( lambda: self.set_initial_frame_index( int(str(self._initial_frame_index_line_edit.text().toAscii())) )) self.tabs_grid_layout_1.addWidget(self._initial_frame_index_tool_bar) self._diff_preamble_128_tool_bar = Qt.QToolBar(self) self._diff_preamble_128_tool_bar.addWidget( Qt.QLabel('Preamble 128' + ": ")) self._diff_preamble_128_line_edit = Qt.QLineEdit( str(self.diff_preamble_128)) self._diff_preamble_128_tool_bar.addWidget( self._diff_preamble_128_line_edit) self._diff_preamble_128_line_edit.returnPressed.connect( lambda: self.set_diff_preamble_128( eval(str(self._diff_preamble_128_line_edit.text().toAscii())))) self.tabs_grid_layout_2.addWidget(self._diff_preamble_128_tool_bar) self._destination_address_tool_bar = Qt.QToolBar(self) self._destination_address_tool_bar.addWidget( Qt.QLabel('Destination address' + ": ")) self._destination_address_line_edit = Qt.QLineEdit( str(self.destination_address)) self._destination_address_tool_bar.addWidget( self._destination_address_line_edit) self._destination_address_line_edit.returnPressed.connect( lambda: self.set_destination_address( int(str(self._destination_address_line_edit.text().toAscii())) )) self.tabs_grid_layout_0.addWidget(self._destination_address_tool_bar) self._tx_center_frequency_tool_bar = Qt.QToolBar(self) self._tx_center_frequency_tool_bar.addWidget( Qt.QLabel('TX center frequency [Hz]' + ": ")) self._tx_center_frequency_line_edit = Qt.QLineEdit( str(self.tx_center_frequency)) self._tx_center_frequency_tool_bar.addWidget( self._tx_center_frequency_line_edit) self._tx_center_frequency_line_edit.returnPressed.connect( lambda: self.set_tx_center_frequency( int(str(self._tx_center_frequency_line_edit.text().toAscii())) )) self.tabs_grid_layout_2.addWidget(self._tx_center_frequency_tool_bar) self._range_tx_gain_range = Range(0, 25, 1, 15, 200) self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, 'Tx Gain', "counter_slider", float) self.tabs_grid_layout_2.addWidget(self._range_tx_gain_win) self._range_rx_gain_range = Range(0, 25, 1, 0, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float) self.tabs_grid_layout_2.addWidget(self._range_rx_gain_win) self._range_mu_range = Range(0, 1, 0.01, 0.6, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float) self.tabs_grid_layout_2.addWidget(self._range_mu_win) self._preamble_detector_threshold_tool_bar = Qt.QToolBar(self) self._preamble_detector_threshold_tool_bar.addWidget( Qt.QLabel('Preamble Detector Threshold' + ": ")) self._preamble_detector_threshold_line_edit = Qt.QLineEdit( str(self.preamble_detector_threshold)) self._preamble_detector_threshold_tool_bar.addWidget( self._preamble_detector_threshold_line_edit) self._preamble_detector_threshold_line_edit.returnPressed.connect( lambda: self.set_preamble_detector_threshold( int( str(self._preamble_detector_threshold_line_edit.text(). toAscii())))) self.tabs_grid_layout_2.addWidget( self._preamble_detector_threshold_tool_bar) self.dmdl_receiving_0 = dmdl.receiving( 1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency) self.dmdl_probe_0_0_0 = dmdl.probe( 0, 100, 0, 0, 0.01, 1, "/home/inets/source/gr-inets/results/", "t2RXe", 1) self.dmdl_framing_0 = dmdl.framing(0, 17, 1, 1, initial_frame_index, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_frame_analysis_0 = dmdl.frame_analysis( 0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address) self._cs_threshold_tool_bar = Qt.QToolBar(self) self._cs_threshold_tool_bar.addWidget( Qt.QLabel('Carrier Sensing Threshold' + ": ")) self._cs_threshold_line_edit = Qt.QLineEdit(str(self.cs_threshold)) self._cs_threshold_tool_bar.addWidget(self._cs_threshold_line_edit) self._cs_threshold_line_edit.returnPressed.connect( lambda: self.set_cs_threshold( eng_notation.str_to_num( str(self._cs_threshold_line_edit.text().toAscii())))) self.tabs_grid_layout_2.addWidget(self._cs_threshold_tool_bar) ################################################## # Connections ################################################## self.msg_connect((self.dmdl_frame_analysis_0, 'P'), (self.dmdl_probe_0_0_0, 'B')) self.msg_connect((self.dmdl_receiving_0, 'E'), (self.dmdl_frame_analysis_0, 'B'))
def __init__(self, constellation=gnuradio.digital.constellation_qpsk().base(), preamble=[]): gr.top_block.__init__(self, "Top Test Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Top Test Rx") 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", "top_test_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.constellation = constellation self.preamble = preamble ################################################## # Variables ################################################## self.sps = sps = 4 self.usrp_device_address = usrp_device_address = "addr=192.168.10.3" self.tx_center_frequency = tx_center_frequency = 3.9e8 self.timeout_duration_ms = timeout_duration_ms = 100 self.system_time_granularity_us = system_time_granularity_us = 10 self.source_address = source_address = 2 self.slot_time = slot_time = 8 self.samp_rate = samp_rate = 400000 self.rx_gain = rx_gain = 0 self.rx_center_frequency = rx_center_frequency = 3.9e8 self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.mu = mu = 0.6 self.min_window_size = min_window_size = 1 self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.destination_address = destination_address = 1 self.cs_threshold = cs_threshold = 0.001 self.Single_rxp_time_s = Single_rxp_time_s = 60 self.SIFS = SIFS = 10 ################################################## # Blocks ################################################## self.dmdl_type_check_0 = dmdl.type_check(1, 25, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1) self.dmdl_receiving_0 = dmdl.receiving( 1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency) self.dmdl_probe_0_0 = dmdl.probe( 1, 1, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "", 1) self.dmdl_probe_0 = dmdl.probe(1, 2, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "", 1) self.dmdl_framing_0_0 = dmdl.framing(0, 17, 2, 1, 0, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1) self.dmdl_frame_analysis_0 = dmdl.frame_analysis( 0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address) self.dmdl_error_detection_0 = dmdl.error_detection(0, 9) self.dmdl_address_check_0 = dmdl.address_check(0, 17, source_address, 0) ################################################## # Connections ################################################## self.msg_connect((self.dmdl_address_check_0, 'Pass'), (self.dmdl_type_check_0, 'Begin')) self.msg_connect((self.dmdl_error_detection_0, 'Pass'), (self.dmdl_address_check_0, 'Begin')) self.msg_connect((self.dmdl_frame_analysis_0, 'Pass'), (self.dmdl_error_detection_0, 'Begin')) self.msg_connect((self.dmdl_framing_0_0, 'End'), (self.dmdl_probe_0, 'info_in')) self.msg_connect((self.dmdl_receiving_0, 'rx_frame_out'), (self.dmdl_frame_analysis_0, 'Begin')) self.msg_connect((self.dmdl_type_check_0, 'DATA'), (self.dmdl_framing_0_0, 'Begin'))