Esempio n. 1
0
 def setUp (self):
     self.tb = gr.top_block ()
     self.c = phy(slow_rate=True)
     self.dqcsk_mapper = ieee802_15_4.dqcsk_mapper_fc(self.c.chirp_seq, self.c.time_gap_1, self.c.time_gap_2, c.n_sub, self.c.n_subchirps)
     self.dqcsk_demapper = ieee802_15_4.dqcsk_demapper_cf(self.c.chirp_seq, self.c.time_gap_1, self.c.time_gap_2, c.n_sub, self.c.n_subchirps)   
     self.dqpsk_mapper = ieee802_15_4.dqpsk_mapper_ff(framelen=self.c.nsym_frame, forward=True)
     self.dqpsk_demapper = ieee802_15_4.dqpsk_mapper_ff(framelen=self.c.nsym_frame, forward=False) 
     self.qpsk_mapper = ieee802_15_4.qpsk_mapper_if() 
     self.qpsk_demapper = ieee802_15_4.qpsk_demapper_fi() 
     self.preamble_sfd_prefixer_I = ieee802_15_4.preamble_sfd_prefixer_ii(self.c.preamble, self.c.SFD, self.c.nsym_frame)
     self.preamble_sfd_removal_I = blocks.keep_m_in_n(gr.sizeof_int, self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD), self.c.nsym_frame, len(self.c.preamble)+len(self.c.SFD))
     self.preamble_sfd_prefixer_Q = ieee802_15_4.preamble_sfd_prefixer_ii(self.c.preamble, self.c.SFD, self.c.nsym_frame)
     self.preamble_sfd_removal_Q = blocks.keep_m_in_n(gr.sizeof_int, self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD), self.c.nsym_frame, len(self.c.preamble)+len(self.c.SFD))
     self.interleaver_I = ieee802_15_4.interleaver_ii(self.c.intlv_seq, forward=True)
     self.interleaver_Q = ieee802_15_4.interleaver_ii(self.c.intlv_seq, forward=True)
     self.deinterleaver_I = ieee802_15_4.interleaver_ii(self.c.intlv_seq, forward=False)
     self.deinterleaver_Q = ieee802_15_4.interleaver_ii(self.c.intlv_seq, forward=False)
     self.codeword_mapper_I = ieee802_15_4.codeword_mapper_bi(self.c.bits_per_symbol, self.c.codewords)
     self.codeword_mapper_Q = ieee802_15_4.codeword_mapper_bi(self.c.bits_per_symbol, self.c.codewords)
     self.codeword_demapper_I = ieee802_15_4.codeword_demapper_ib(self.c.bits_per_symbol, self.c.codewords)
     self.codeword_demapper_Q = ieee802_15_4.codeword_demapper_ib(self.c.bits_per_symbol, self.c.codewords)
     self.demux = blocks.deinterleave(gr.sizeof_char*1,1)
     self.mux = blocks.interleave(gr.sizeof_char*1,1)
     self.zeropadding = ieee802_15_4.zeropadding_b(self.c.padded_zeros)
     self.zeropadding_removal = ieee802_15_4.zeropadding_removal_b(self.c.phy_packetsize_bytes*8+len(self.c.PHR), self.c.padded_zeros)
     self.phr_prefixer = ieee802_15_4.phr_prefixer(self.c.PHR)
     self.phr_removal = ieee802_15_4.phr_removal(self.c.PHR)
     self.fragmentation = ieee802_15_4.fragmentation(self.c.phy_packetsize_bytes)
Esempio n. 2
0
 def setUp(self):
     self.tb = gr.top_block()
     self.c = phy(slow_rate=True)
     self.dqcsk_mapper = ieee802_15_4.dqcsk_mapper_fc(
         self.c.chirp_seq, self.c.time_gap_1, self.c.time_gap_2, c.n_sub,
         self.c.n_subchirps)
     self.dqcsk_demapper = ieee802_15_4.dqcsk_demapper_cf(
         self.c.chirp_seq, self.c.time_gap_1, self.c.time_gap_2, c.n_sub,
         self.c.n_subchirps)
     self.dqpsk_mapper = ieee802_15_4.dqpsk_mapper_ff(
         framelen=self.c.nsym_frame, forward=True)
     self.dqpsk_demapper = ieee802_15_4.dqpsk_mapper_ff(
         framelen=self.c.nsym_frame, forward=False)
     self.qpsk_mapper = ieee802_15_4.qpsk_mapper_if()
     self.qpsk_demapper = ieee802_15_4.qpsk_demapper_fi()
     self.preamble_sfd_prefixer_I = ieee802_15_4.preamble_sfd_prefixer_ii(
         self.c.preamble, self.c.SFD, self.c.nsym_frame)
     self.preamble_sfd_removal_I = blocks.keep_m_in_n(
         gr.sizeof_int,
         self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD),
         self.c.nsym_frame,
         len(self.c.preamble) + len(self.c.SFD))
     self.preamble_sfd_prefixer_Q = ieee802_15_4.preamble_sfd_prefixer_ii(
         self.c.preamble, self.c.SFD, self.c.nsym_frame)
     self.preamble_sfd_removal_Q = blocks.keep_m_in_n(
         gr.sizeof_int,
         self.c.nsym_frame - len(self.c.preamble) - len(self.c.SFD),
         self.c.nsym_frame,
         len(self.c.preamble) + len(self.c.SFD))
     self.interleaver_I = ieee802_15_4.interleaver_ii(self.c.intlv_seq,
                                                      forward=True)
     self.interleaver_Q = ieee802_15_4.interleaver_ii(self.c.intlv_seq,
                                                      forward=True)
     self.deinterleaver_I = ieee802_15_4.interleaver_ii(self.c.intlv_seq,
                                                        forward=False)
     self.deinterleaver_Q = ieee802_15_4.interleaver_ii(self.c.intlv_seq,
                                                        forward=False)
     self.codeword_mapper_I = ieee802_15_4.codeword_mapper_bi(
         self.c.bits_per_symbol, self.c.codewords)
     self.codeword_mapper_Q = ieee802_15_4.codeword_mapper_bi(
         self.c.bits_per_symbol, self.c.codewords)
     self.codeword_demapper_I = ieee802_15_4.codeword_demapper_ib(
         self.c.bits_per_symbol, self.c.codewords)
     self.codeword_demapper_Q = ieee802_15_4.codeword_demapper_ib(
         self.c.bits_per_symbol, self.c.codewords)
     self.demux = blocks.deinterleave(gr.sizeof_char * 1, 1)
     self.mux = blocks.interleave(gr.sizeof_char * 1, 1)
     self.zeropadding = ieee802_15_4.zeropadding_b(self.c.padded_zeros)
     self.zeropadding_removal = ieee802_15_4.zeropadding_removal_b(
         self.c.phy_packetsize_bytes * 8 + len(self.c.PHR),
         self.c.padded_zeros)
     self.phr_prefixer = ieee802_15_4.phr_prefixer(self.c.PHR)
     self.phr_removal = ieee802_15_4.phr_removal(self.c.PHR)
     self.fragmentation = ieee802_15_4.fragmentation(
         self.c.phy_packetsize_bytes)
 def test_002_t (self):
     # set up fg
     pi=np.pi
     data_in = [0, pi/2, pi, -pi/2, pi/2, -pi/2, -pi/2, 0, 0, pi, pi/2, pi/2]
     data_in = [i + pi/4 for i in data_in]
     self.src = blocks.vector_source_f(data_in)
     self.dqpsk = ieee802_15_4.dqpsk_mapper_ff(framelen=6, forward=False)
     self.snk = blocks.vector_sink_f(1)
     self.tb.connect(self.src, self.dqpsk, self.snk)
     self.tb.run ()
     # check data
     data_out = self.snk.data()
     data_out = [np.exp(1j*i) for i in data_out]
     ref = [0, pi/2, pi, -pi/2, pi/2, pi, -pi/2, 0, 0, pi, pi, pi/2]
     ref = [np.exp(1j*i) for i in ref]
     # print "in:", data_in
     # print "out:", data_out
     # print "ref:", ref
     self.assertComplexTuplesAlmostEqual(ref, data_out, 5)       
    def test_001_t (self):
        # set up fg
        pi=np.pi
        data_in = [0, pi/2, pi, -pi/2, pi/2, pi, -pi/2, 0, 0, pi, 0, pi/2]
        self.src = blocks.vector_source_f(data_in)
        self.dqpsk = ieee802_15_4.dqpsk_mapper_ff(framelen=6, forward=True)
        self.snk = blocks.vector_sink_f(1)
        self.tb.connect(self.src, self.dqpsk, self.snk)
        self.tb.run ()
        # check data
        data_out = self.snk.data()
        ref = [0, pi/2, pi, -pi/2, pi/2, -pi/2, -pi/2, 0, 0, pi, pi/2, pi/2]
        ref = [i + pi/4 for i in ref]
        ref = [np.exp(1j*i) for i in ref]
        ref2 = [45, 135, -135, -45, 135, -45, -45, 45, 45, -135, -45, 135]
        ref2 = [np.exp(1j*i/180*pi) for i in ref2]
        data_out = [np.exp(1j*i) for i in data_out]

        self.assertComplexTuplesAlmostEqual(ref2, data_out, 5)
 def test_002_t(self):
     # set up fg
     pi = np.pi
     data_in = [
         0, pi / 2, pi, -pi / 2, pi / 2, -pi / 2, -pi / 2, 0, 0, pi, pi / 2,
         pi / 2
     ]
     data_in = [i + pi / 4 for i in data_in]
     self.src = blocks.vector_source_f(data_in)
     self.dqpsk = ieee802_15_4.dqpsk_mapper_ff(framelen=6, forward=False)
     self.snk = blocks.vector_sink_f(1)
     self.tb.connect(self.src, self.dqpsk, self.snk)
     self.tb.run()
     # check data
     data_out = self.snk.data()
     data_out = [np.exp(1j * i) for i in data_out]
     ref = [
         0, pi / 2, pi, -pi / 2, pi / 2, pi, -pi / 2, 0, 0, pi, pi, pi / 2
     ]
     ref = [np.exp(1j * i) for i in ref]
     # print "in:", data_in
     # print "out:", data_out
     # print "ref:", ref
     self.assertComplexTuplesAlmostEqual(ref, data_out, 5)
    def test_001_t(self):
        # set up fg
        pi = np.pi
        data_in = [
            0, pi / 2, pi, -pi / 2, pi / 2, pi, -pi / 2, 0, 0, pi, 0, pi / 2
        ]
        self.src = blocks.vector_source_f(data_in)
        self.dqpsk = ieee802_15_4.dqpsk_mapper_ff(framelen=6, forward=True)
        self.snk = blocks.vector_sink_f(1)
        self.tb.connect(self.src, self.dqpsk, self.snk)
        self.tb.run()
        # check data
        data_out = self.snk.data()
        ref = [
            0, pi / 2, pi, -pi / 2, pi / 2, -pi / 2, -pi / 2, 0, 0, pi, pi / 2,
            pi / 2
        ]
        ref = [i + pi / 4 for i in ref]
        ref = [np.exp(1j * i) for i in ref]
        ref2 = [45, 135, -135, -45, 135, -45, -45, 45, 45, -135, -45, 135]
        ref2 = [np.exp(1j * i / 180 * pi) for i in ref2]
        data_out = [np.exp(1j * i) for i in data_out]

        self.assertComplexTuplesAlmostEqual(ref2, data_out, 5)