def test_301(self): # Use itemsize, limit constructor src = blocks.message_source(gr.sizeof_char) dst = gr.vector_sink_b() tb = gr.top_block() tb.connect(src, dst) src.msgq().insert_tail(gr.message_from_string('01234')) src.msgq().insert_tail(gr.message_from_string('5')) src.msgq().insert_tail(gr.message_from_string('')) src.msgq().insert_tail(gr.message_from_string('6789')) src.msgq().insert_tail(gr.message(1)) # send EOF tb.run() self.assertEquals(tuple(map(ord, '0123456789')), dst.data())
def test_1 (self): data = ('hello', 'you', 'there') tx_msgq = gr.msg_queue() rx_msgq = gr.msg_queue() for d in data: tx_msgq.insert_tail(gr.message_from_string(d)) tx_msgq.insert_tail(gr.message(1)) # send EOF tb = gr.top_block() src = blocks.message_source(gr.sizeof_char, tx_msgq, "packet_length") snk = blocks.message_sink(gr.sizeof_char, rx_msgq, False, "packet_length") tb.connect(src, snk) tb.start() time.sleep(1) tb.stop() for d in data: msg = rx_msgq.delete_head() contents = msg.to_string() self.assertEqual(d, contents)