I'm working on a project that makes use of the Ettus USRP X300 and the GNURadio environment. I have established a connection between the transmitter and the receiver of the USRP and I'm able to read data from a text file and send it over the channel via the Ettus USRP X300 board. In my grc, I used the URSP source and USRP sink blocks.

However, I now want to continuously print the signal strength or the RSSI on the terminal so I know how strong the received signal is.

The output of the USRP source block is of complex type and I've tried using the complex to mag² block to obtain the signal power. I connected this block to a file sink with dev/pts to keep printing the received signal power values but I see no output.

I would like to know if there's any other way to print the received signal power directly from the USRP source block.




1 Answer 1


Finally found a solution to this. This can be done by making use of an Embedded Python Block on GNURadio. The USRP source (with complex output) can be directly connected to the Embedded Python Block with the following code:

import numpy as np
from gnuradio import gr
import os

class blk(gr.sync_block):  # other base classes are basic_block, 
decim_block, interp_block
    def __init__(self, example_param=1.0):  # only default arguments here
        """arguments to this function show up as parameters in GRC"""
            name='Embedded Python Block',   # will show up in GRC
        self.example_param = example_param

    def work(self, input_items, output_items):
        """Print the signal power in dB to /dev/pts"""
        power_db = 10 * np.log10(np.mean(np.abs(input_items[0])**2)) 
        os.system('echo "{:.2f}" > /dev/pts/4'.format(power_db))  
        output_items[0][:] = input_items[0]  
        return len(output_items[0])

This block continuously prints the signal power in dB on the terminal. Use the 'tty' command on a terminal window to know the correct /dev/pts file. In my case, it was /dev/pts/4.

  • $\begingroup$ note that this is going to break everything else that is using the output – especially the logging facilities of GNU Radio itself. Also note that printing numbers to terminals is indeed very very slow compared to what samplerates you can get from an SDR device, and because you're spamming your output with your text, you wouldn't see the overflow indications coming from the USRP. Yes, you can do this, no, I would not recommend it! $\endgroup$ Commented Apr 11 at 12:13
  • $\begingroup$ also, you can't know you're on PTS nr. 4, so this doesn't work reliably. Calling system just to execute echo just to pipe something into a file: You really need to learn python basics! This is like code that was stolen from all the wrong places! $\endgroup$ Commented Apr 12 at 12:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .