discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: (gnuradio3.8) module 'gnuradio.blocks' has no attribute 'message_sin


From: Criss Swaim
Subject: Re: (gnuradio3.8) module 'gnuradio.blocks' has no attribute 'message_sink'
Date: Thu, 25 Mar 2021 09:58:26 -0600
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

Here is a solution using an asynchronous probe:

In this application, there is a need to periodically send signals to a background task for non-realtime calculations.

            # connect the queue to the input signal
            msgq = gr.msg_queue(2)
            msg_sink = blocks.message_sink(gr.sizeof_float*num_bins, msgq, True)  # dont block
            self.connect(self, msg_sink)

            # start the update thread
            update_thread(
                num_bins=num_bins,
                update_timeout=update_timeout,
                msgq=msgq,
              ........
             )
then in the background thread, the queue is read and processed

            # read from the queue and resize to have arrays of size num bins
            raw_samps = numpy.fromstring(self._msgq.delete_head().to_string(), numpy.float32)
            raw_samps.resize(len(raw_samps) / self._num_bins, self._num_bins)

With the message_sink block no longer supported, the probe_signal_vf  block works for me:

            # setup the probe and connect to input signal
           probe = blocks.probe_signal_vf(num_bins)
           self.connect(self, probe)

            # start the update thread
            update_thread(
                num_bins=num_bins,
                update_timeout=update_timeout,
                probe = probe,
                ......
            ) 
and in the background thread:

           # read from the probe and resize to have arrays of size num bins
            raw_samps = numpy.array(self._probe.level())
            raw_samps.resize(1, self._num_bins)
This will work if your application does not need every signal passed to the background task.


Criss Swaim
cswaim@tpginc.net
cell: 505.301.5701
On 1/15/2021 2:09 AM, Marcus Müller wrote:
So, the old msg_queue infrastructure of GNU Radio has been removed, yes.

A suitable replacement are the asynchronous message passing blocks.
Depending on your use case, the conversion of your code should be
relatively straightforward - the message debug sink might even do what
you want.

Best regards,
Marcus

On 07.01.21 04:46, Ting Wu wrote:
Hi!

I recently upgraded to gnuradio 3.8 and my old code threw the following
error:

module 'gnuradio.blocks' has no attribute 'message_sink'

Is the 'message_sink' has been deprecated in the recent version of
gnuradio? If so, what should I use now for the message source and sink?
I really do not want to rewrite all the codes, so I would be really
grateful if there is a simple way to make the following code work with
the recent version of gnuradio. The code simply gets data stream from a
USRP N200 (LFRX daughterboard).

=================================================
 class my_block(gr.top_block):
    def __init__(self):
        gr.top_block.__init__(self)
        self.source = uhd.usrp_source(device_addr="",
stream_args=uhd.stream_args('sc16', 'sc16', args="scalar=1024"))

        self.source.set_samp_rate(samp_rate)
        self.source.set_gain(gain)
        self.source.set_center_freq(0)

        self.queue = gr.msg_queue()
        self.sink = blocks.message_sink(gr.sizeof_short*2, self.queue,
False)  #This line throws the error
        self.connect(self.source, self.sink)
===================================================

Thanks in advance!

Ting Wu



reply via email to

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