def test_00(self): expected_result = ( 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff) # Filter taps to expand the data to oversample by 8 # Just using a RRC for some basic filter shape taps = filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21) src = blocks.vector_source_b(expected_result) frame = digital.simple_framer(4) unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) expand = filter.interp_fir_filter_fff(8, taps) b2f = blocks.char_to_float() mult2 = blocks.multiply_const_ff(2) sub1 = blocks.add_const_ff(-1) op = digital.simple_correlator(4) dst = blocks.vector_sink_b() self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand) self.tb.connect(expand, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)
def test_char_to_float_scale(self): src_data = (1, 2, 3, 4, 5) expected_data = (0.5, 1.0, 1.5, 2.0, 2.5) src = blocks.vector_source_b(src_data) op = blocks.char_to_float(scale=2.0) dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
def test_char_to_float_identity(self): src_data = (1, 2, 3, 4, 5) expected_data = (1.0, 2.0, 3.0, 4.0, 5.0) src = blocks.vector_source_b(src_data) op = blocks.char_to_float() dst = blocks.vector_sink_f() self.tb.connect(src, op, dst) self.tb.run() self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
def xtest_ccsds_27 (self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6) src = blocks.vector_source_b(src_data) enc = fec.encode_ccsds_27_bb() b2f = blocks.char_to_float() add = blocks.add_const_ff(-0.5) mul = blocks.multiply_const_ff(2.0) dec = fec.decode_ccsds_27_fb() dst = blocks.vector_sink_b() self.tb.connect(src, enc, b2f, add, mul, dec, dst) self.tb.run() dst_data = dst.data() self.assertEqual(expected, dst_data)
def xtest_ccsds_27(self): src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6) src = blocks.vector_source_b(src_data) enc = fec.encode_ccsds_27_bb() b2f = blocks.char_to_float() add = blocks.add_const_ff(-0.5) mul = blocks.multiply_const_ff(2.0) dec = fec.decode_ccsds_27_fb() dst = blocks.vector_sink_b() self.tb.connect(src, enc, b2f, add, mul, dec, dst) self.tb.run() dst_data = dst.data() self.assertEqual(expected, dst_data)
def test_00(self): expected_result = (0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff) # Filter taps to expand the data to oversample by 8 # Just using a RRC for some basic filter shape taps = filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21) src = blocks.vector_source_b(expected_result) frame = digital.simple_framer(4) unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) expand = filter.interp_fir_filter_fff(8, taps) b2f = blocks.char_to_float() mult2 = blocks.multiply_const_ff(2) sub1 = blocks.add_const_ff(-1) op = digital.simple_correlator(4) dst = blocks.vector_sink_b() self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand) self.tb.connect(expand, op, dst) self.tb.run() result_data = dst.data() self.assertEqual(expected_result, result_data)