discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] Sending Data/Messages to GNU Radio via Python App


From: Paul Boven
Subject: Re: [Discuss-gnuradio] Sending Data/Messages to GNU Radio via Python Application
Date: Mon, 16 Sep 2019 15:08:15 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

Hi,

On 08/09/2019 21:29, Rajen Goradia wrote:
I am trying to make use of the ZMQ blocks in GNU Radio to act as a server and have a separate python client application send data/messages to GNU Radio. I was successful in getting data out of GNU Radio and using a separate python application such as using the “ZMQ PUSH Sink” block in GNU Radio and using the zmq library in Python (context.socket(zmq.PULL) function) but I was unable to reverse the procedure. Has anybody successfully tried doing this, either with or without using the zmq library or the ZMQ blocks in GNU Radio? Please let me know and thank you for looking.

Happen to have just done this a few weeks ago, to compensate for doppler shift on 21cm (Hydrogen line) observations. What worked for me is listed below. This should work with Python 2 and GR 3.7 as well, but I ended up using GNU Radio 3.8 because astropy requires python 3. The code sends a 'freq' message, which you can feed to e.g. the command port of a Frequency XLAT FIR filter, see the attached image.

#!/usr/bin/python3
# Note: use Python 2 for older versions of GR
import pmt
import zmq
import time

# Open a ZeroMQ publisher socket on localhost, port 5555
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://127.0.0.1:5555")

doppler = 0.1

while(1):
  msg = pmt.cons(pmt.intern("freq"), pmt.from_double(doppler))
  sb = pmt.serialize_str(msg)
  socket.send(sb)
  doppler = doppler + 0.1
  time.sleep(1)

# Code ends here

Regards, Paul Boven.



Attachment: Flowgraph-ZMQ.png
Description: PNG image


reply via email to

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