Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

OpenwebRX and ZMQ approach #100

Open
diazm opened this issue Nov 7, 2017 · 4 comments
Open

OpenwebRX and ZMQ approach #100

diazm opened this issue Nov 7, 2017 · 4 comments

Comments

@diazm
Copy link

diazm commented Nov 7, 2017

Hi, I'm trying to use OpenwebRX wih GNURadio and ZMQ PUB/SUB. My goal is to replace FIFO and all the TCP stuff for ZMQ . In my first approach I add the ZMQ PUB SINK block with address 'ipc:///tmp/fifo-pipe' to the flowgraph in GNURadio-Companion keeping the FIFO (GNURadio File sink block).
Then in csdr.py changed the variable any_chain_base = "nc -v 127.0.0.1 {nc_port} | " for any_chain_base = "zmqc SUB -rc 'ipc:///tmp/fifo-pipe' | "

Execute openwebrx.py and all I get in the browser is a white screen in FFT getting network usage, server CPU and all others status variables.

Any ideas?

@ha7ilm
Copy link
Owner

ha7ilm commented Nov 7, 2017

What does this output?

zmqc SUB -rc 'ipc:///tmp/fifo-pipe' | csdr through >/dev/null

@diazm
Copy link
Author

diazm commented Nov 8, 2017

Hi András

zmqc SUB -rc 'ipc:///tmp/fifo-pipe'

is like netcat for ZMQ. I got it from https://github.com/zacharyvoase/zmqc
but analyzing outputs from ZMQC and netcat they are slightly different.

Also I am testing with GNURadio models from CSDR library in particular with test_fft_grc.grc:

test_fft_grc

I got this output, with the expected behavior:

test_fft_grc_salida

After I try this model:
test_fft_grc_1

I got this output but the behavior is unexpected:

test_fft_grc_1_salida

I really don`t know why is a different behavior with the GNURadio ZMQ-SUB block and the ZMQC-SUB from the console.

@ha7ilm
Copy link
Owner

ha7ilm commented Nov 8, 2017

What is the data type of the output of zmqc?

csdr has some diagnostic functions like dump_f and dump_u8 that you can use to check if the type that you guess is valid. You also need to adjust the format_conversion parameter in the config accordingly. Another tool that you can use to view the raw data: od. Just make sure that you use a pager (like less) or head so that your screen isn't filled with text.

@diazm
Copy link
Author

diazm commented Nov 9, 2017

OK, I checked the output data with this small python program:

from gnuradio import analog
from gnuradio import blocks
from gnuradio import gr
from gnuradio import zeromq
import zmq
import array

socket_str = "tcp://127.0.0.1:5557"


def zmq_consumer():
    context = zmq.Context()
    results_receiver = context.socket(zmq.PULL)
    results_receiver.connect(socket_str)
    while True:
        # pull in raw binary data
        raw_data = results_receiver.recv()
        print raw_data
        # convert to an array of floats
        #float_list = array.array('f', raw_data) # struct.unpack will be faster
        # print flowgraph data
        #for signal_val in float_list:
        #    print signal_val


# build simple flowgraph that outputs a repeating ramp from 0 to 1
class simple_flowgraph(gr.top_block):
    def __init__(self):

        gr.top_block.__init__(self)

        samp_rate = 4000 #32000.0

        # generate repeating ramp from 0 to 1
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate,
            analog.GR_SAW_WAVE,
            1e3,
            1,
            0)
        self.blocks_throttle_0 = blocks.throttle(
            gr.sizeof_float*1,
            samp_rate,
            True)
        self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_float,
                                                   1,
                                                   socket_str,
                                                   100,
                                                   False,
                                                   -1)

        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, '/tmp/osmocom_fifo', False)


        ##################################################
        # Connections
        ##################################################
        self.connect(
            (self.analog_sig_source_x_0, 0),
            (self.blocks_throttle_0, 0)
        )
        self.connect(
            (self.blocks_throttle_0, 0),
            (self.zeromq_push_sink_0, 0)
        )
        self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))

# instantiate and start the flowgraph
flowgraph = simple_flowgraph()
flowgraph.start()

# start the receiver socket
zmq_consumer()

It is a GNURadio flowgraph with a signal source connected to a FIFO and to ZMQ PUSH Sink block.
The function zmq_consumer() is ZMQ PULL (not GNURadio block) that read the ZMQ PUSH block.

If you execute the code program.py | csdr dump_f and in other terminal check the FIFO cat /tmp/osmocom_fifo | csdr dump_f you will see that the ZMQ output add some kind of garbage to the real data, that I assume is the FIFO output.
Maybe I have a mistake with the raw_data variable format and that`s why the output is not correct. Any ideas?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants