Search code examples
gnuradiognuradio-companion

GNU Radio Companion: how can I convert float stream to be printed to console?


I have an input to a Threshold block, which I have verified is working with a QT GUI number sink.

QT GUI number sink

I want to print the output of the Threshold block to console, preferably using the Message Debug block.

However, the output of the Threshold block is a float stream, which doesn't match the input of the Message Debug block.

Is there a way to convert a float stream into message, or am I going down the wrong hole?

My general aim is: when the input exceeds a certain threshold, print to console. Another program will monitor the console and when there is a print out, this triggers another action. I'm also not sure how to output ONLY when the threshold is exceeded, but one problem at a time.


Solution

  • I'm also not sure how to output ONLY when the threshold is exceeded, but one problem at a time.

    Yes, but that problem is a blocker: Std output is a shared thing across all things in the GNU Radio process, so you can't generally guarantee exclusivity.

    Let's not go down that route!

    Instead, use something designed for exactly for this kind of things decades ago in UNIX!

    Named pipes. These are FIFOs that you can handle like files.

    So, use a file source to write to a FIFO, and pipe that FIFO into your other program.

    It's really simple:

    • mkfifo /path/to/where/you/want/to/named/pipe
    • add a file sink that writes to /path/to/where/you/want/to/named/pipe
    • either make your other software open that /path/to/where/you/want/to/named/pipe, or do something like other_program < /path/to/where/you/want/to/named/pipe (that actually makes the standard (==console-equivalent) input of your other program what you write to that file sink)