Problem with messages and msg_queue

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,

On Wed, May 09, 2007 at 08:12:05PM +0200, Trond D. wrote:


Trond D.

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

    self.mq = gr.msg_queue()
    print "queue"
except KeyboardInterrupt:
    pass

if name == “main”:
main()

vim: ai ts=4 sts=4 et sw=4

2007/5/9, Eric B. [email protected]:

Regards,
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

Ok, I guess I misunderstood one thing: I assumed that gr.message_sink(
gr.sizeof_float, …) would set the payload size for each packet to 4
bytes.

    runtime.wait()

Setting runtime on 0x6923a0 to 0x6918c0
start_threads: starting 0x6d26f0


Trond D.

On Wed, May 09, 2007 at 11:14:43PM +0200, Trond D. wrote:

gr.sizeof_float, …) would set the payload size for each packet to 4
bytes.

No, that would kill our performance.

Eric

On Thu, May 10, 2007 at 10:24:04AM +0200, Trond D. wrote:

Ok, I read from pkt.py that to finish a packet, I just append
gr.message(1) at the tail of the message queue, but is there a simple
way to do this if I just want to send packet of fixed size, where the
payload comes from a flow graph?

Hi Trond,

The gr.message(1) isn’t to end a packet, it’s to tell the scheduler
that there’s no more data coming.

I’m not exactly sure I’m following what you are trying to do.
However, I think that if you follow through the logic in
gnuradio-examples/python/digital/tunnel.py you’ll see a way to send
and receive packets (fixed or variable length) between python and the
flow graph.

Eric

2007/5/10, Eric B. [email protected]:

that there’s no more data coming.

I’m not exactly sure I’m following what you are trying to do.
However, I think that if you follow through the logic in
gnuradio-examples/python/digital/tunnel.py you’ll see a way to send
and receive packets (fixed or variable length) between python and the
flow graph.

Eric

Okay, I will try to describe my problem a little better. I have a
block that estimates some properties on a received signal: Frequency
and phase. Lets call the block acquisition. The acquisition block
outputs the estimates at 1kHz. Now what I want to do is grab these
estimates and use them to update the center frequency and code delay
in another block, lets call it tracking :).

I have tried to use probe_signal_f, but this does not work because the
acquisition and tracking block must be synchronized.


Trond D.

On Thu, May 10, 2007 at 05:02:21PM +0200, Trond D. wrote:

The gr.message(1) isn’t to end a packet, it’s to tell the scheduler

Okay, I will try to describe my problem a little better. I have a
block that estimates some properties on a received signal: Frequency
and phase. Lets call the block acquisition. The acquisition block
outputs the estimates at 1kHz. Now what I want to do is grab these
estimates and use them to update the center frequency and code delay
in another block, lets call it tracking :).

I have tried to use probe_signal_f, but this does not work because the
acquisition and tracking block must be synchronized.

The easy way is to put them in the same block (Yes, I know that wasn’t
the answer you were looking for.) Or you could try using a
message queue and messages between them. You don’t have to use
gr_message_sink. You could have your estimator block create mesages
(of whatever format it likes) and insert them into a message queue
that was handed to it, say in the constructor.

Eric

2007/5/10, Eric B. [email protected]:

thankful!
In reality, you’d want to do something with the payload:
Ok, I guess I misunderstood one thing: I assumed that gr.message_sink(
gr.sizeof_float, …) would set the payload size for each packet to 4
bytes.

No, that would kill our performance.

Eric

Ok, I read from pkt.py that to finish a packet, I just append
gr.message(1) at the tail of the message queue, but is there a simple
way to do this if I just want to send packet of fixed size, where the
payload comes from a flow graph?

Trond D.

2007/5/10, Eric B. [email protected]:

First of all, thank you for you patience with all the questions from a
simple user like me! I wouldn’t have got very far without the support
from this mailing list.

The easy way is to put them in the same block (Yes, I know that wasn’t
the answer you were looking for.) Or you could try using a
message queue and messages between them. You don’t have to use
gr_message_sink. You could have your estimator block create mesages
(of whatever format it likes) and insert them into a message queue
that was handed to it, say in the constructor.

Indeed it would easier if everything was in one block, but I should
mention that the acquisition block is defined at python level, and is
currently not written in C++. I would really like to keep it at this
level, both because of simplicity and for the flexibility it adds.

I do believe that the problem that I address is a fairly general one,
and something that might be easier with the new mblock. But from what
I could see, mblocks are currently only available from C++, or am I
missing something?


Trond D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs