Пример #1
0
        def __init__(self, sps=8, bt=0.5, mod_idx=0.68):
            gr.hier_block2.__init__(
                self,
                "simple_modulator",
                gr.io_signature(0, 0, 0),  # Input signature
                gr.io_signature(0, 0, 0))  # Output signature

            # message ports
            self.message_port_register_hier_in("in")
            self.message_port_register_hier_out("out")

            # blocks
            self.pack = pdu_utils.pack_unpack(pdu_utils.MODE_UNPACK_BYTE,
                                              pdu_utils.BIT_ORDER_LSB_FIRST)
            self.preamble = pdu_utils.pdu_preamble([], [], sps, 0)
            modulation_index = mod_idx
            sensitivity = (pi * modulation_index) / sps
            gain = 1.0
            taps = firdes.gaussian(gain, sps, bt, 5)
            self.gmsk = pdu_utils.pdu_gmsk_fc(sensitivity, taps)

            # connections
            self.msg_connect(self, "in", self.pack, "pdu_in")
            self.msg_connect(self.pack, "pdu_out", self.preamble, "pdu_in")
            self.msg_connect(self.preamble, "pdu_out", self.gmsk, "pdu_in")
            self.msg_connect(self.gmsk, "pdu_out", self, "out")
Пример #2
0
    def test_006_basic_nrz(self):

        self.dut = pdu_utils.pdu_preamble([], [], 1, 0, True)
        self.connectUp()

        input_data = pmt.init_u8vector(8, [1, 0, 1, 1, 0, 0, 1, 0])
        input_dict = pmt.dict_add(pmt.make_dict(), pmt.intern("KEY"),
                                  pmt.intern("VALUE"))
        input_pdu = pmt.cons(input_dict, input_data)

        expected_data = [1, -1, 1, 1, -1, -1, 1, -1]
        expected_dict = pmt.dict_add(pmt.make_dict(), pmt.intern("KEY"),
                                     pmt.intern("VALUE"))
        expected_pdu = pmt.cons(
            expected_dict, pmt.init_f32vector(len(expected_data),
                                              expected_data))

        self.tb.start()
        time.sleep(.001)
        self.emitter.emit(input_pdu)
        time.sleep(.01)
        self.tb.stop()
        self.tb.wait()

        self.assertEqual(1, self.debug.num_messages())

        print("test_006_basic_nrz:")
        print("pdu expected: " + repr(pmt.car(expected_pdu)))
        print("pdu got:      " + repr(pmt.car(self.debug.get_message(0))))
        print("data expected: " + repr(pmt.to_python(pmt.cdr(expected_pdu))))
        print("data got:      " +
              repr(pmt.to_python(pmt.cdr(self.debug.get_message(0)))))
        print

        self.assertTrue(pmt.equal(self.debug.get_message(0), expected_pdu))
Пример #3
0
 def setUp (self):
     self.tb = gr.top_block ()
     self.emitter = pdu_utils.message_emitter()
     self.emitter2 = pdu_utils.message_emitter()
     self.pre = pdu_utils.pdu_preamble([], [], 8, 20, True)
     self.gmsk = pdu_utils.pdu_gmsk_fc(0.5, firdes.gaussian(1,4,0.35,9))
     self.debug = blocks.message_debug()
     self.tb.msg_connect((self.emitter, 'msg'), (self.pre, 'pdu_in'))
     self.tb.msg_connect((self.emitter2, 'msg'), (self.gmsk, 'pdu_in'))
     self.tb.msg_connect((self.pre, 'pdu_out'), (self.gmsk, 'pdu_in'))
     self.tb.msg_connect((self.gmsk, 'pdu_out'), (self.debug, 'store'))