[DISCLAIMER: I'm messing around in the 10011 svn trunk, so I expect certain things don't work.] I was playing with the message queues, trying to really figure them out. I wrote something that goes to files like this: topb = gr.top_block() modu = blks2.gmsk_mod() pktb = blks2.mod_pkts( modulator=modu ) file = gr.file_sink(gr.sizeof_gr_complex, "test.dat") topb.connect(pktb, file) topb.start() pktb.send_pkt("testing") pktb.send_pkt("lo?") pktb.send_pkt("") pktb.send_pkt(eof=True) topb.wait() And pull things back out like this: topb = gr.top_block() file = gr.file_source(gr.sizeof_gr_complex, "test.dat", False) modu = blks2.gmsk_demod() pktb = blks2.demod_pkts( demodulator=modu, callback=rx, threshold=12 ) topb.connect(file, pktb) topb.run() Question 1: Notice that I send_pkt("")? It seems the last message never gets de-queued (ever); which also happens with the svn ofdm stuff apparently. So I send a blank message before the eof. Is that a bug? or is that just a quark of the flow graph setup? I'm trying to get this working without a modulator, not for any practical reasons, but just understand pkt.py a little better (hopefully). I'm queuing the messages this way (which I pretty much ripped out of pkt.py): class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) self._ac = packet_utils.default_access_code self.src = gr.message_source(gr.sizeof_char, 2) self.snk = gr.file_sink(gr.sizeof_char, "test.dat") self.connect(self.src, self.snk) def send(self,payload): pkt = packet_utils.make_packet(payload, 2, 1, self._ac, True, 0) msg = gr.message_from_string(pkt) self.src.msgq().insert_tail(msg) def eof(self): self.src.msgq().insert_tail(gr.message(1)) And I'm grabbing them back out of the file this way: class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) self._ac = packet_utils.default_access_code self.src = gr.file_source(gr.sizeof_char, "test.dat", False) self.pktq = gr.msg_queue() self.correlator = gr.correlate_access_code_bb(self._ac, 12) self.framer_sink = gr.framer_sink_1(self.pktq) self.connect(self.src, self.correlator, self.framer_sink) def main(): tb = my_top_block() tb.run() print "going to try to read a message from the file" msg = tb.pktq.delete_head() ok, payload = packet_utils.unmake_packet(msg.to_string(), int(msg.arg1())) print "%r %s" % (ok, payload) I ripped the thread watcher stuff out of pkt.py also, but it was clear to me that delete_head() wasn't ever returning before program exit, so I moved that to main() and ditched the thread watcher things altogether. I have added a file sink right after the correlator and confirmed that the bytes definitely pass through it. With or without threads, delete_head() never returns, meaning (I think) that my packet queue never receives messages from the correlator. Question 2: Why does the packet queue receive correlated messages correctly in pkt.py, but not in my simpler flow graph with no modulator? I'm clearly missing something really simple, but I've spent enough time on it to know I'm not going to figure it out easily. -- If riding in an airplane is flying, then riding in a boat is swimming. 107 jumps, 43.5 minutes of freefall, 83.4 freefall miles.
on 2008-11-18 17:20