[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Discuss-gnuradio] Problem with messages and msg_queue
From: |
Eric Blossom |
Subject: |
Re: [Discuss-gnuradio] Problem with messages and msg_queue |
Date: |
Wed, 9 May 2007 12:15:13 -0700 |
User-agent: |
Mutt/1.5.9i |
On Wed, May 09, 2007 at 08:12:05PM +0200, Trond Danielsen wrote:
> Hi everyone,
>
> I've got a problem with messages and message queues. The problem is
> simply that I just cannot figure out how to use them. I tried the
> simple program that is attached to this email (test.py), and the
> result is in test.log. If anybody has the time to take a quick look at
> the code and point me in the right direction, I would be very
> thankful!
>
> Regards,
>
> --
> Trond Danielsen
This looks correct, and in fact you are receiving a payload that's 800
bytes long (== 200 * sizeof(float)), so everything looks good.
In reality, you'd want to do something with the payload:
payload = msg.to_string() # return payload as an python string
foo = struct.unpack(format, payload)
See gnuradio-core/src/python/gnuradio/blksimpl/pkt.py for a real-life example.
Eric
> #!/usr/bin/env python
>
> from gnuradio import gr
>
> class testing(gr.top_block):
> def __init__(self):
> gr.top_block.__init__(self, "testing")
>
> self.src = gr.vector_source_f( range(200), False )
>
> self.mq = gr.msg_queue()
> self.sink = gr.message_sink(gr.sizeof_float, self.mq, False)
> self.connect( self.src, self.sink )
>
> def main():
> top_block = testing()
> runtime = gr.runtime(top_block)
>
> try:
> runtime.start()
>
> print "queue"
> print top_block.mq.count()
>
> msg = top_block.mq.delete_head()
> print "msg"
> print msg.type()
> print msg.arg1()
> print msg.arg2()
> print msg.length()
>
> runtime.wait()
> except KeyboardInterrupt:
> pass
>
> if __name__ == "__main__":
> main()
>
> # vim: ai ts=4 sts=4 et sw=4
>
> connecting: vector_source_f(1):0 -> message_sink(2):0
> Setting runtime on 0x6923a0 to 0x6918c0
> start: entered
> flattening testing
> Flattening edge vector_source_f(1):0->message_sink(2):0
> Validating block: message_sink(2)
> Validating block: vector_source_f(1)
> Creating block detail for message_sink(2)
> Creating block detail for vector_source_f(1)
> Allocating new buffer for output 0
> Setting input 0 from edge vector_source_f(1):0->message_sink(2):0
> start_threads: entered
> start_threads: starting 0x6d26f0
> queue
> 0
> msg
> 0
> 4.0
> 200.0
> 800
> wait: entered
> wait: joining thread 0x6d26f0
> wait: join returned
- [Discuss-gnuradio] Problem with messages and msg_queue, Trond Danielsen, 2007/05/09
- Re: [Discuss-gnuradio] Problem with messages and msg_queue,
Eric Blossom <=
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Trond Danielsen, 2007/05/09
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Eric Blossom, 2007/05/09
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Trond Danielsen, 2007/05/10
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Eric Blossom, 2007/05/10
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Trond Danielsen, 2007/05/10
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Eric Blossom, 2007/05/10
- Re: [Discuss-gnuradio] Problem with messages and msg_queue, Trond Danielsen, 2007/05/10