discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Usage of Message Queues


From: Martin Lülf
Subject: Re: [Discuss-gnuradio] Usage of Message Queues
Date: Sat, 23 Feb 2013 19:24:54 +0100
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130215 Thunderbird/17.0.3

Am 23.02.2013 17:09, schrieb Hanz:
Thank you much for your answer. Indeed, its a shared pointer. I now figured
out, the the only way to get the data is via .to_string().


So my thought was, that all the messages then should contain one byte (with
one bit information). At the end, my code looks like that:

tb = top_block()
        tb.start()

        while 1:

                        point=tb.sink_queue.delete_head()
                        point=point.to_string()
                        print len(point)

The first curiosity is, that the length variates from 2 up to 2048. Can
somebody explain why? The next question is, how to i convert the "bitvalue"
of the string to an actual char?


Hi,

your code setup with the blocks and connects looks fine to me.

Although I have not checked the details of msg_sink I would expect it to process blocks of incomming bytes into messages. So a message can contain an abritrary amount of bytes in it (I think that is why your length varies). Once again speaking for the C++ interface with the method length() you will get the number of elements that this message contains. Then you can usually access the message's data through a call to the msg() function which returns a pointer to a byte array containing the bytes. This will be wrapped to some python code, so check the return type of msg() and try to process this returned data instead of to_string() if you are interested in the data itself. So I think your code should look something like this (not tested, please check agains the actual Python interface documented with Sphinx or Python docstrings):

message=tb.sink_queue.delete_head()
data=message.msg()
length=message.length()

for i in xrange(length) :
        byte=data[i]

Hope this gives you an idea on how to use the interface.

Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]