def test_010_t(self): self.samp_rate = samp_rate = 32000 src_data = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1) src_data = [(s - 0.5 + (random.random() - 0.5) * 0.1) for s in src_data ] # add some noise and bring to [-0.5, 0.5] #print(src_data) expected_result = (0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0) #print(samples_per_symbol) mdecode = manchester_decode.manchester_decode(1, 8) src = blocks.vector_source_f(src_data, False, 1, []) snk = blocks.vector_sink_b(1, 0) thr = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.tb.connect((thr, 0), (mdecode, 0)) self.tb.connect((src, 0), (thr, 0)) self.tb.connect((mdecode, 0), (snk, 0)) self.tb.run() result_data = snk.data() #print(result_data) self.assertEqual(expected_result, result_data)
def test_001_t(self): self.samp_rate = samp_rate = 32000 src_data = (0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1) src_data = [(s - 0.5) for s in src_data] # bring to [-0.5, 0.5] expected_result = (0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0) samples_per_symbol = int(len(src_data) / len(expected_result)) #print(samples_per_symbol) mdecode = manchester_decode.manchester_decode(samples_per_symbol) src = blocks.vector_source_f(src_data, False, 1, []) snk = blocks.vector_sink_b(1, 0) thr = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.tb.connect((thr, 0), (mdecode, 0)) self.tb.connect((src, 0), (thr, 0)) self.tb.connect((mdecode, 0), (snk, 0)) self.tb.run() result_data = snk.data() #print(result_data) self.assertEqual(expected_result, result_data)