Ejemplo n.º 1
0
    def test_preamble(self):
        pream_len = 52
        pream = (mapper.preamble_generator(pream_len, 511,
                                           1033)).get_preamble()

        rand_src = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 2, 1024)), True)
        head = blocks.head(gr.sizeof_char * 1, 1024)
        src_sink = blocks.vector_sink_b(1)
        pream_inst = mapper.preamble_insert_bb(pream_len * 10, (pream))
        bit2symb = mapper.mapper(mapper.BPSK, ([0, 1]))
        pream_sync = mapper.preamble_sync_cc(pream_len * 10, (pream),
                                             mapper.BPSK, ([0, 1]), .97, .90)
        symb2bit = mapper.demapper(mapper.BPSK, ([0, 1]))
        rec_sink = blocks.vector_sink_b(1)

        self.tb.connect((rand_src, 0), (head, 0))
        self.tb.connect((head, 0), (pream_inst, 0))
        self.tb.connect((head, 0), (src_sink, 0))
        self.tb.connect((pream_inst, 0), (bit2symb, 0))
        self.tb.connect((bit2symb, 0), (pream_sync, 0))
        self.tb.connect((pream_sync, 0), (symb2bit, 0))
        self.tb.connect((symb2bit, 0), (rec_sink, 0))

        self.tb.start()
        sleep(1)
        self.tb.stop()

        data_space = pream_len * 9
        sd = src_sink.data()
        rd = rec_sink.data()
        self.assertEqual(sd[0:data_space], rd[0:data_space])
Ejemplo n.º 2
0
    def test_preamble (self):
        pream_len = 52
        pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble()
        
        rand_src    = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1024)), True)
        head        = blocks.head(gr.sizeof_char*1, 1024)
        src_sink    = blocks.vector_sink_b(1)
        pream_inst  = mapper.preamble_insert_bb(pream_len*10, (pream))
        bit2symb    = mapper.mapper(mapper.BPSK, ([0,1]))
        pream_sync  = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.BPSK, ([0,1]), .97, .90)
        symb2bit    = mapper.demapper(mapper.BPSK, ([0,1]))
        rec_sink    = blocks.vector_sink_b(1)

        self.tb.connect((rand_src, 0), (head, 0))
        self.tb.connect((head, 0), (pream_inst, 0))
        self.tb.connect((head, 0), (src_sink, 0))
        self.tb.connect((pream_inst, 0), (bit2symb, 0))
        self.tb.connect((bit2symb, 0), (pream_sync, 0))
        self.tb.connect((pream_sync, 0), (symb2bit, 0))
        self.tb.connect((symb2bit, 0), (rec_sink, 0))
        
        self.tb.start()
        sleep(1)
        self.tb.stop()
        
        data_space = pream_len*9
        sd = src_sink.data()
        rd = rec_sink.data()
        self.assertEqual(sd[0:data_space],rd[0:data_space])
Ejemplo n.º 3
0
samp_rate = samp_rate = 32000
pream = pream = (mapper.preamble_generator(pream_len, 511,
                                           1033)).get_preamble()

##################################################
# Blocks
##################################################
rand_src = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1024)),
                                  True)
#head        = blocks.head(gr.sizeof_char*1, 1024)
src_sink = blocks.vector_sink_b(1)
pream_inst = mapper.preamble_insert_bb(pream_len * 10, (pream))
pre_sink = blocks.vector_sink_b(1)
bit2symb = mapper.mapper(mapper.BPSK, ([0, 1]))
sym_sink = blocks.vector_sink_c(1)
pream_sync = mapper.preamble_sync_cc(pream_len * 10, (pream), mapper.BPSK,
                                     ([0, 1]), .97, .90)
snc_sink = blocks.vector_sink_c(1)
symb2bit = mapper.demapper(mapper.BPSK, ([0, 1]))
rec_sink = blocks.vector_sink_b(1)

##################################################
# Connections
##################################################
#tb.connect((rand_src, 0), (head, 0))
tb.connect((rand_src, 0), (pream_inst, 0))
tb.connect((rand_src, 0), (src_sink, 0))
#tb.connect((head, 0), (pream_inst, 0))
#tb.connect((head, 0), (src_sink, 0))
tb.connect((pream_inst, 0), (bit2symb, 0))
tb.connect((pream_inst, 0), (pre_sink, 0))
tb.connect((bit2symb, 0), (pream_sync, 0))
Ejemplo n.º 4
0
##################################################
pream_len = pream_len = 52
samp_rate = samp_rate = 32000
pream = pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble()

##################################################
# Blocks
##################################################
rand_src    = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1024)), True)
#head        = blocks.head(gr.sizeof_char*1, 1024)
src_sink    = blocks.vector_sink_b(1)
pream_inst  = mapper.preamble_insert_bb(pream_len*10, (pream))
pre_sink    = blocks.vector_sink_b(1)
bit2symb    = mapper.mapper(mapper.BPSK, ([0,1]))
sym_sink    = blocks.vector_sink_c(1)
pream_sync  = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.BPSK, ([0,1]), .97, .90)
snc_sink    = blocks.vector_sink_c(1)
symb2bit    = mapper.demapper(mapper.BPSK, ([0,1]))
rec_sink    = blocks.vector_sink_b(1)

##################################################
# Connections
##################################################
#tb.connect((rand_src, 0), (head, 0))
tb.connect((rand_src, 0), (pream_inst, 0))
tb.connect((rand_src, 0), (src_sink, 0))
#tb.connect((head, 0), (pream_inst, 0))
#tb.connect((head, 0), (src_sink, 0))
tb.connect((pream_inst, 0), (bit2symb, 0))
tb.connect((pream_inst, 0), (pre_sink, 0))
tb.connect((bit2symb, 0), (pream_sync, 0))
Ejemplo n.º 5
0
    def __init__(self):
        gr.top_block.__init__(self, "Sync Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Sync Test")
        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", "sync_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.pream_len = pream_len = 84
        self.samp_rate = samp_rate = 32000
        self.pream = pream = (mapper.preamble_generator(pream_len,511,1033)).get_preamble()
        self.SNR = SNR = 40
        self.Rotation = Rotation = 0
        self.Offset = Offset = 0

        ##################################################
        # Blocks
        ##################################################
        self._SNR_tool_bar = Qt.QToolBar(self)
        self._SNR_tool_bar.addWidget(Qt.QLabel("SNR"+": "))
        self._SNR_line_edit = Qt.QLineEdit(str(self.SNR))
        self._SNR_tool_bar.addWidget(self._SNR_line_edit)
        self._SNR_line_edit.returnPressed.connect(
        	lambda: self.set_SNR(eng_notation.str_to_num(self._SNR_line_edit.text().toAscii())))
        self.top_layout.addWidget(self._SNR_tool_bar)
        self._Rotation_layout = Qt.QVBoxLayout()
        self._Rotation_label = Qt.QLabel("Rotation")
        self._Rotation_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._Rotation_slider.setRange(0, 2*pi, pi/100)
        self._Rotation_slider.setValue(self.Rotation)
        self._Rotation_slider.setMinimumWidth(200)
        self._Rotation_slider.valueChanged.connect(self.set_Rotation)
        self._Rotation_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter)
        self._Rotation_layout.addWidget(self._Rotation_label)
        self._Rotation_layout.addWidget(self._Rotation_slider)
        self.top_layout.addLayout(self._Rotation_layout)
        self._Offset_layout = Qt.QVBoxLayout()
        self._Offset_tool_bar = Qt.QToolBar(self)
        self._Offset_layout.addWidget(self._Offset_tool_bar)
        self._Offset_tool_bar.addWidget(Qt.QLabel("Offset"+": "))
        self._Offset_counter = Qwt.QwtCounter()
        self._Offset_counter.setRange(-100, 100, 1)
        self._Offset_counter.setNumButtons(2)
        self._Offset_counter.setValue(self.Offset)
        self._Offset_tool_bar.addWidget(self._Offset_counter)
        self._Offset_counter.valueChanged.connect(self.set_Offset)
        self._Offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._Offset_slider.setRange(-100, 100, 1)
        self._Offset_slider.setValue(self.Offset)
        self._Offset_slider.setMinimumWidth(200)
        self._Offset_slider.valueChanged.connect(self.set_Offset)
        self._Offset_layout.addWidget(self._Offset_slider)
        self.top_layout.addLayout(self._Offset_layout)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
        	840-84, #size
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	840-84, #size
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.mapper_preamble_sync_cc_0 = mapper.preamble_sync_cc(pream_len*10, (pream), mapper.PSK8, ([0,1,2,3,4,5,6,7]), .97, .90)
        self.mapper_preamble_insert_bb_0 = mapper.preamble_insert_bb(pream_len*10, (pream))
        self.mapper_mapper_0 = mapper.mapper(mapper.PSK8, ([0,1,2,3,4,5,6,7]))
        self.mapper_demapper_0 = mapper.demapper(mapper.PSK8, ([0,1,2,3,4,5,6,7]))
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1.5*pi/100, 8)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=10**(-SNR/20.0),
        	frequency_offset=Offset,
        	epsilon=1.0,
        	taps=(exp( (0 + 1j*Rotation) ), ),
        	noise_seed=0,
        	block_tags=False
        )
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 7, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.mapper_preamble_insert_bb_0, 0), (self.mapper_mapper_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0), (self.mapper_demapper_0, 0))
        self.connect((self.mapper_mapper_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_preamble_sync_cc_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0), (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.mapper_preamble_insert_bb_0, 0))
        self.connect((self.mapper_demapper_0, 0), (self.blocks_vector_sink_x_0_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0))
Ejemplo n.º 6
0
    def __init__(self):
        gr.top_block.__init__(self, "Sync Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Sync Test")
        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", "sync_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.pream_len = pream_len = 84
        self.samp_rate = samp_rate = 32000
        self.pream = pream = (mapper.preamble_generator(pream_len, 511,
                                                        1033)).get_preamble()
        self.SNR = SNR = 40
        self.Rotation = Rotation = 0
        self.Offset = Offset = 0

        ##################################################
        # Blocks
        ##################################################
        self._SNR_tool_bar = Qt.QToolBar(self)
        self._SNR_tool_bar.addWidget(Qt.QLabel("SNR" + ": "))
        self._SNR_line_edit = Qt.QLineEdit(str(self.SNR))
        self._SNR_tool_bar.addWidget(self._SNR_line_edit)
        self._SNR_line_edit.returnPressed.connect(lambda: self.set_SNR(
            eng_notation.str_to_num(self._SNR_line_edit.text().toAscii())))
        self.top_layout.addWidget(self._SNR_tool_bar)
        self._Rotation_layout = Qt.QVBoxLayout()
        self._Rotation_label = Qt.QLabel("Rotation")
        self._Rotation_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                              Qwt.QwtSlider.BottomScale,
                                              Qwt.QwtSlider.BgSlot)
        self._Rotation_slider.setRange(0, 2 * pi, pi / 100)
        self._Rotation_slider.setValue(self.Rotation)
        self._Rotation_slider.setMinimumWidth(200)
        self._Rotation_slider.valueChanged.connect(self.set_Rotation)
        self._Rotation_label.setAlignment(Qt.Qt.AlignBottom
                                          | Qt.Qt.AlignHCenter)
        self._Rotation_layout.addWidget(self._Rotation_label)
        self._Rotation_layout.addWidget(self._Rotation_slider)
        self.top_layout.addLayout(self._Rotation_layout)
        self._Offset_layout = Qt.QVBoxLayout()
        self._Offset_tool_bar = Qt.QToolBar(self)
        self._Offset_layout.addWidget(self._Offset_tool_bar)
        self._Offset_tool_bar.addWidget(Qt.QLabel("Offset" + ": "))
        self._Offset_counter = Qwt.QwtCounter()
        self._Offset_counter.setRange(-100, 100, 1)
        self._Offset_counter.setNumButtons(2)
        self._Offset_counter.setValue(self.Offset)
        self._Offset_tool_bar.addWidget(self._Offset_counter)
        self._Offset_counter.valueChanged.connect(self.set_Offset)
        self._Offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal,
                                            Qwt.QwtSlider.BottomScale,
                                            Qwt.QwtSlider.BgSlot)
        self._Offset_slider.setRange(-100, 100, 1)
        self._Offset_slider.setValue(self.Offset)
        self._Offset_slider.setMinimumWidth(200)
        self._Offset_slider.valueChanged.connect(self.set_Offset)
        self._Offset_layout.addWidget(self._Offset_slider)
        self.top_layout.addLayout(self._Offset_layout)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
            840 - 84,  #size
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            840 - 84,  #size
            "QT GUI Plot",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.mapper_preamble_sync_cc_0 = mapper.preamble_sync_cc(
            pream_len * 10, (pream), mapper.PSK8, ([0, 1, 2, 3, 4, 5, 6, 7]),
            .97, .90)
        self.mapper_preamble_insert_bb_0 = mapper.preamble_insert_bb(
            pream_len * 10, (pream))
        self.mapper_mapper_0 = mapper.mapper(mapper.PSK8,
                                             ([0, 1, 2, 3, 4, 5, 6, 7]))
        self.mapper_demapper_0 = mapper.demapper(mapper.PSK8,
                                                 ([0, 1, 2, 3, 4, 5, 6, 7]))
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(
            1.5 * pi / 100, 8)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=10**(-SNR / 20.0),
            frequency_offset=Offset,
            epsilon=1.0,
            taps=(exp((0 + 1j * Rotation)), ),
            noise_seed=0,
            block_tags=False)
        self.blocks_vector_sink_x_0_0 = blocks.vector_sink_b(1)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(3)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 7, 10000)), True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.mapper_preamble_insert_bb_0, 0),
                     (self.mapper_mapper_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0),
                     (self.mapper_demapper_0, 0))
        self.connect((self.mapper_mapper_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0),
                     (self.mapper_preamble_sync_cc_0, 0))
        self.connect((self.mapper_preamble_sync_cc_0, 0),
                     (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.mapper_preamble_insert_bb_0, 0))
        self.connect((self.mapper_demapper_0, 0),
                     (self.blocks_vector_sink_x_0_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.qtgui_const_sink_x_0, 0))