thanks for the info you provided; it was ver helpful!
I think I got the basic understanding of the message_source/sink.
I wrote my first toy code based on this:
The Tx queues 100 packets and the Rx waits until
it receives everything (broken into different number of packets)…
The Rx does not know when transmission ended
but I can check the total # of bytes received and it
coincides with that transmitted.
I hope I have not missed something big here.
I wanted to ask if there is a natural way for the code to exit
this kind of loop; so far I am doing it manually with contr-C
from gnuradio import gr
Qtx=20 src = gr.message_source(gr.sizeof_char,Qtx) self.tx_queue = src.msgq() dst = gr.message_sink(gr.sizeof_char,rx_queue,False) self.connect (src, dst)
if name == ‘main’:
payload = ‘abcdefghijklmnopqrst’
rx_queue = gr.msg_queue(Qrx)
print 'Starting the graph' fg.start() i=1 j=1 imax=100 # max number of packets to Tx tot=0 # counts number of received bytes tx_done = False while True: # process Tx side if not tx_done: msg=gr.message_from_string(payload) fg.tx_queue.insert_tail(msg) print 'Just queued the ',i,' th packet' i+=1 if i>imax: tx_done = True print 'Nothing to do at the Tx' print 'Sending the EOF message' eof_msg=gr.message(1) fg.tx_queue.insert_tail(eof_msg) #process Rx side while not rx_queue.empty_p(): rmsg = rx_queue.delete_head() tot+=rmsg.length() print 'I got mail: ',j,rmsg.type(), rmsg.length(),