User:Muaddib: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Understanding XMLRPC Blocks==
<div style="float:right">
This tutorial presents the GNU Radio XMLRPC blocks. There are two blocks in this collection: [[XMLRPC_Client|'''XMLRPC Client''']] and [[XMLRPC_Server|'''XMLRPC Server''']]. Both blocks have IP address/port fields while the Client block also has callback and variable fields. The blocks use the Python XMLRPC module and use a subset of the full XMLRPC spec.
{{Template:BeginnerTutorials}}
</div>


XMLRPC is an '''XML'''-based '''R'''emote '''P'''rotocol '''C'''ontrol mechanism that does just that. It uses HTTP transport and allows a client to use SET commands to change parameters on a server or use GET commands to obtain the value of parameters on the server.  
{| class="wikitable"
|+ Install Quickstart<br>(Refer to the rest of this page for more OS and installation options)
! Linux
||
# [https://releases.ubuntu.com/20.04/ Install Ubuntu 20.04] (either as a VM or natively)
# <code>sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.9</code>
# <code>sudo apt-get update</code>
# <code>sudo apt-get install gnuradio</code>
||v3.9.5
|-
! Windows
||
# Install the latest [https://github.com/ryanvolz/radioconda/releases Radioconda installer]
# Launch "GNU Radio Companion" from the Start menu
||v3.10.0
|-
! macOS
||
# [https://brew.sh/ Install Homebrew]
# <code>brew install gnuradio</code>
||v3.9.3
|}


To understand better how GNURadio implements XMLRPC, look at the block documentation linked in the paragraph above.


To understand the XMLRPC protocol and Python implementation in detail, the reference links below are a good starting point.
= Types of Installation Methods =


==Reference Links==
The recommended way to install GNU Radio on most platforms is using already available binary packages. Find your platform below in the [[#From_Binaries|From Binaries]] section for instructions on how to get GNU Radio through your regular package manager (e.g. [[#Ubuntu_PPA_Installation|Ubuntu PPA Installation]]), or visit the [[CondaInstall|Conda Installation]] page for instructions on how to use the Conda package manager to install GNU Radio on any Linux distribution, macOS, or Windows. For some platforms there are no binaries provided by available package managers or the GNU Radio project. In these cases please contact the maintainer of the package manager or the GNU Radio project to find a sensible way to provide binaries for your platform.
http://xmlrpc.com


https://docs.python.org/3.8/library/xmlrpc.html
GNU Radio can be installed with these 3 methods:
# '''[[#From_Binaries|From Binaries]]''' (recommended for beginners)
# '''[[#From_Source|From source]]''' (for those who want full control)
# '''[[#Using_PyBOMBS|Using PyBOMBS]]''' (for those who want it built from source and/or installed to a specific directory using a script)


==Prerequisites==
= From Binaries =
* [[Guided_Tutorial_GRC|Intro to GR usage: GRC and flowgraphs]]


* [[Understanding_ZMQ_Blocks|Understanding ZMQ Blocks]]
== Linux ==


==Introduction: ''What does XMLRPC do in GNURadio and Why Should I Care?''==
Most distributions contain a package named <code>gnuradio</code> or similar in their standard repositories. For most use cases it is enough to install this package and start developing.
'''WHAT''': In GNURadio placing the XMLRPC Server block in a flowgraph will create an XMLRPC server that exposes all the variables in the flowgraph on the specified IP Address and Port. This allows a client to change them at runtime. The XMLRPC Client block allows the user to create a flowgraph that can control any of the parameters in a flowgraph that has the XMLRPC Server block.


'''WHY''': In many cases, we want to adjust the variables of a GNURadio flowgraph at runtime. We usually do this by adding QT GUI Widget block (range, push button, etc). But what if you want to have the same control interface, but in a different flowgraph? XMLRPC will allow you to control all of a flowgraph's variables from a second flowgraph using HTTP. In fact, the second flowgraph doesn't even have to be on the same computer! Therefore, XMLRPC can be used to add runtime control of any flowgraph running on a remote system like a Raspberry PI, headless server or otherwise.
The development of GNU Radio can be fast-paced, and binaries provided by your distribution may be outdated. '''Do check if the version you're installing is up to date! Sometimes old versions are not updated in the packaging systems.''' If you find a bug in a older GNU Radio version, please check if the bug still exists in the newer version of GNU Radio before filing a new issue.


==Contents of Tutorial==
If the version shipped in your distribution is outdated please contact the corresponding maintainer to update it in the packaging system.


'''GNURadio XMLRPC Examples'''
Here are examples of how to install GNU Radio in various Linux distributions. <b>Click the link under &quot;Distribution&quot; for how to install dependencies.</b>


*We will start with running the basic client/server example flowgraphs from the GNU Radio source tree ([https://github.com/gnuradio/gnuradio/tree/maint-3.9/gr-blocks/examples/xmlrpc gr-blocks/examples/xmlrpc]).
{|class="wikitable" style="margin: auto; width: 90%;"
!scope="col"|Distribution
!scope="col"|Command
|-
| [[UbuntuInstall|Debian/Ubuntu and derivates]]
| <pre># apt install gnuradio</pre>
|-
| [[FedoraInstall|Fedora]]
| <pre># dnf install gnuradio</pre>
|-
| RHEL/CentOS
| <pre># yum install gnuradio</pre>
|-
| [[ArchInstall|Archlinux]]
| <pre># pacman -S gnuradio</pre>
|-
| [[GentooInstall|Gentoo Linux]]
| <pre># emerge net-wireless/gnuradio</pre>
|-
| [[SuseInstall|Suse Linux]]
|
|-
|}


'''GNURadio XMLRPC Examples with added ZMQ Streaming Data Visualization'''
On other distributions, simply use the appropriate package management command to install the <code>gnuradio</code> package and then please add it to this list. If you need newer versions or have a different platform please contact the package maintainer of your distribution or raise your issue on the mailing list.


*Here we will modify the examples to include ZMQ streaming so we can visualize the remote flowgraph's datastream in our XMLRPC Client flowgraph.
=== Ubuntu PPA Installation ===
For Ubuntu, the latest builds (both released and pulled from master branch) are maintained as PPAs on [https://launchpad.net/~gnuradio launchpad].  Be sure to uninstall any previously installed versions of gnuradio first.


'''GNURadio XMLRPC Remote Control Over IP Network'''
To access the current released version (3.10), add the gnuradio/gnuradio-releases ppa (removing other gnuradio ppas if already configured)


*Next, we will run the server/client pair over an IP network using 2 separate computers. (Requires 2 hosts on the same network with GNURadio 3.9+ installed)
<pre>$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases</pre>


'''GNURadio XMLRPC Advanced Usage Example'''
To access the 3.9 released version, add the gnuradio/gnuradio-releases-3.9 ppa (removing other gnuradio ppas if already configured)


*(OPTIONAL) As a bonus step we will run a project that implements a remote, headless wideband RF receiver and stream the data to a Remote Controller for control and visualization.
<pre>$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.9</pre>


==GNURadio XMLRPC Examples==
To access the 3.8 released version, add the gnuradio/gnuradio-releases-3.8 ppa (removing other gnuradio ppas if already configured)


Open the [https://github.com/gnuradio/gnuradio/blob/maint-3.9/gr-blocks/examples/xmlrpc/siggen_xmlrpc_server.grc siggen_xmlrpc_server.grc] flowgraph.
<pre>$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.8</pre>


Shown here:
To access the 3.7 released version (legacy), add the gnuradio/gnuradio-releases-3.7 ppa (removing other gnuradio ppas if already configured)


[[File:Xmlrpc_server.png]]
<pre>$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.7</pre>


Open the [https://github.com/gnuradio/gnuradio/blob/maint-3.9/gr-blocks/examples/xmlrpc/siggen_controller_xmlrpc_client.grc siggen_controller_xmlrpc_client.grc] flowgraph
Then, update the apt sources, and install gnuradio
<pre>$ sudo apt-get update</pre>
<pre>$ sudo apt install gnuradio</pre>


Shown here:
'''Attention:''' Do '''NOT''' try to install further packages like `gr-osmosdr` via Ubuntu's package management (i.e. using "apt"). Ubuntu will try to install a potentially incompatible version and your system will be in an undefined state.


[[File:Xmlrpc_client.png]]


'''Note on 3.10 packaging dependency'''
For some distributions you may need to install the python module 'packaging' using pip (which may also need to be installed).


First, Run the Siggen Server Flowgraph
$ sudo apt install python3-pip
$ pip install packaging


Your GUI window should look like this:
==== Modtool on Ubuntu ====
NOTE: On released builds for Ubuntu 18.04 (bionic), there is an issue using gr_modtool after GNU Radio has been installed from the PPA.  This is due to byte-compiled code that remains in the modtool templates after installation.  To work around this issue:


[[File:Xmlrpc_server_before.png]]
<pre>$ cd /usr/share/gnuradio/modtool/templates/gr-newmod
$ sudo py3clean .</pre>


Next, run the Siggen Controller flowgraph
This issue does not appear for Ubuntu 19 and later packages


Your GUI window should look like this:
=== Fedora COPR Installation ===


<controller.jpg>
**NOTE: FEDORA COPR not currently maintained**


Arrange both GUI windows so you can see them at the same time.
Packages are available for Fedora 29, 30, 31 hosted under COPR:


In the Siggen Controller Flowgraph Move the Frequency Slider slightly to the left and observe the Siggen Server time/frequency display. You should see the frequency changing as shown here:
https://copr.fedorainfracloud.org/coprs/gnuradio/


[[File:Xmlrpc_server_after.png]]
1. Add the repository:


That's it, you've just remote controlled a flowgraph over a network socket!
-- For the latest released version:
<pre>$ sudo dnf copr enable gnuradio/gnuradio-releases </pre>
-- For the latest pull from git master:
<pre>$ sudo dnf copr enable gnuradio/gnuradio-master </pre>


Close both GUI windows and continue to the next tutorial.
2. Install GNU Radio
<pre>$ sudo dnf install gnuradio </pre>


==GNURadio XMLRPC Examples with ZMQ Streaming Data Visualization==
=== Raspberry Pi ===
Make sure you are familiar with ZMQ streaming from the [[Understanding_ZMQ_Blocks|ZMQ tutorials]].


*Create a copy ('save as') of both XMLRPC example flowgraphs and name them:
There is a pre-built 32 bit SDR flavored Raspberry Pi OS distro, [https://github.com/luigifcruz/pisdr-image PiSDR] that includes GNU Radio and other SDR utilities.  There are also instructions for [[InstallingGRFromSource_on_Raspberry_Pi]].


    "siggen_xmlrpc_server_streaming.grc"
== Windows ==
    "siggen_controller_xmlrpc_client_streaming.grc"


(don't forget to change the names in the 'ID' of the 'Options' block to match the new .grc filenames)
See the [[CondaInstall|Conda install guide]] or [https://github.com/ryanvolz/radioconda radioconda] to install GNU Radio 3.8 or newer on Windows.<br />


*In the Streaming Server Flowgraph, copy the throttle and GUI display blocks, then paste them into the Streaming Controller flowgraph.  
If you need to install GNU Radio from source refer to the [[WindowsInstall|Windows install guide]].


[[File:Xmlrpc_client_streaming_add_GUI.png]]
'''Note''': GNU Radio support on Windows is improving significantly but remains less tested and there are known problems and even significant bugs which affect regular usage of GNU Radio Companion. Please report bugs on the [https://github.com/gnuradio/gnuradio/issues GitHub Issues page] and if you have Windows development experience please consider investigating some of the [https://github.com/gnuradio/gnuradio/issues?q=is%3Aopen+is%3Aissue+label%3AWindows known issues].


*Now delete the GUI blocks from the Server Flowgraph and add a ZMQ Pub Sink block. Connect the output of the 'Throttle' block to the input of the ZMQ Pub Sink where the GUI blocks used to be connected.
== Mac OS X ==


    ZMQ PUB SINK PARAMETERS:
Refer to the [[MacInstall|Mac OS X install guide page]].
        'Address': tcp://127.0.0.1:5000
        'Pass Tags': 'Yes'
        All others default


*Change the 'Generate Options' in the Server flowgraph to 'No GUI'. This will allow us to run the flowgraph on our localhost or a remote host as a 'headless' flowgraph.
= From Source =


[[File:Xmlrpc_server_streaming_add_ZMQ.png]]
Binary installation should be sufficient for most users, and certainly for anyone who is new to GNU Radio. However, if you have special requirements, want the latest version, or the binary packages are not working for you, you may want to install GNU Radio from source.


=== Notes ===


*In the Streaming Client flowgraph.  
* By default GNU Radio will be installed in the <code>/usr/local</code> directory.  See notes about [[InstallingGR#Common_cmake_flags|-DCMAKE_INSTALL_PREFIX]] to install it elsewhere.
* Running and developing out-of-tree modules does not require GNU Radio to be installed from source.
* <b>If you want to use GNU Radio with a USRP, you FIRST must clone and install UHD</b>. See the [https://kb.ettus.com/Building_and_Installing_the_USRP_Open-Source_Toolchain_(UHD_and_GNU_Radio)_on_Linux UHD Installation Page] for more info, <b>OR</b> follow the instructions in [[InstallingGRFromSource_on_Raspberry_Pi#Load_prerequisites|Install UHD from source]].
* To install on a Raspberry Pi, see [[InstallingGRFromSource on Raspberry Pi]].
* To build from source from within a conda environment, see [[CondaInstall#Building GNU Radio from source within a conda environment|the conda install guide]].


Change the sample rate to match the Streaming Server Flowgraph (32ksps)
=== For GNU Radio 3.10, 3.9, and Main Branch ===


Add a ZMQ Sub Source block to the  flowgraph and connect it to the input port of both the 'QT GUI Time Sink' and 'QT GUI Frequency Sink' GUI blocks.
This section describes how to install GNU Radio 3.10, 3.9, and the Main branch from source code.


[[File:Xmlrpc_client_streaming_add_ZMQ.png]]
==== Installing Dependencies ====


    ZMQ SUB SOURCE PARAMETERS:
Refer to [[UbuntuInstall#Install_Dependencies|this page for your specific Linux distro]] to find how to install dependencies. For example, on Ubuntu 20.04 [[UbuntuInstall#Focal_Fossa_.2820.04.29_through_Impish_Indri_.2821.10.29|use this command]].
        'Address': tcp://127.0.0.1:5000
        'Pass Tags': 'Yes'
        All others default


*RUN IT!
==== Installing Volk ====
From GRC:
Click the run button on the 'siggen_xmlrpc_server_streaming' flowgraph. A blank terminal window will open (don't worry its doing it's job).


Click the run button on the 'siggen_xmlrpc_controller_client_streaming' flowgraph. A GUI window will open with the same time/frequency display as before, but in the same graph with the GUI Range 'frequency' slider.  
Since Volk is no longer considered as a submodule of GNU Radio (GNU Radio commit #80c04479da962d048d41165081b026aafdaa0316),<br> you <b>MUST FIRST</b> install Volk, and then install GNU Radio.  


In the Controller GUI:
The basic idea is the same, but instead of building Volk along with GNU Radio, you need to clone and build it separately. For this example, we will start in the home directory. You can, of course, use any directory you wish and the results will be the same.
Adjust the slider as before and observe the frequency changing.  


[[File:Xmlrpc_client_streaming_complete.png]]
* <code>cd</code>
* <code>git clone --recursive https://github.com/gnuradio/volk.git</code>
* <code>cd volk</code>
* <code>mkdir build</code>
* <code>cd build</code>
<b>Note:</b> In the following command, you can add <code>-DCMAKE_INSTALL_PREFIX=XXX</code> to install Volk into the PREFIX <code>XXX</code>; if not specified, then the PREFIX is <code>/usr/local</code>. See other CMake options in [[#Common_cmake_flags|Common cmake flags]].<br>
* <code>cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../</code>
* <code>make</code>
* <code>make test</code>
* <code>sudo make install</code>


You are now both remote controlling and viewing streaming data over a network connection!
If you're running Linux, then always remember to do the following command after installing any library:
* <code>sudo ldconfig</code>


==GNURadio XMLRPC Remote Control Over IP Network==
==== Installing GNU Radio ====


* <code>cd</code>
* <code>git clone https://github.com/gnuradio/gnuradio.git</code>
* <code>cd gnuradio</code>
<b>Note:</b> If you want to build the <code>maint-3.10</code> or <code>maint-3.9</code> branch rather than the default <code>main</code> branch, enter:
<code>git checkout maint-3.10</code> and then<br>
* <code>mkdir build</code>
* <code>cd build</code>
<b>Note:</b> In the following command, you can add <code>-DCMAKE_INSTALL_PREFIX=XXX</code> to install GNU Radio into the PREFIX <code>XXX</code>; if not specified, then the PREFIX is <code>/usr/local</code>. See other CMake options in [[#Common_cmake_flags|Common cmake flags]].<br>
* <code>cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../</code>
* <code>make -j3</code> (e.g. if you want to use 3 CPU cores during the build.  To use 8 do -j8, to use 1, leave out the -j flag.)
<b>Note:</b> In the following command, it is very possible that not all tests pass. Generally any error is a sign of a missing dependency such as the Python interface to ZMQ or NumPy or SciPy, none of which are required for building GNU Radio but are required for testing.
* <code>make test</code>
* <code>sudo make install</code>
If you're running Linux, then always remember to do the following command after installing any library:
* <code>sudo ldconfig</code>
If you encounter "Cannot import gnuradio" error, then go to [[ModuleNotFoundError#B._Finding_the_Python_library|Finding the Python library]] to set your PYTHONPATH and LD_LIBRARY_PATH.<br><b>After setting these environment variables, you need to do</b> <code>sudo ldconfig</code> <b>again</b> for the Linux dynamic library loader to find the just-installed GNU Radio libraries.<br>
If you have installed in a custom path with <code>-DCMAKE_INSTALL_PREFIX=XXX</code>, you will need to add that path to $PATH in order to find gnuradio-companion.


*Extending this example to two hosts using one of two methods.
=== For GNU Radio 3.8 or Earlier ===
Assume our Streaming Server machine is Host A and our Streaming Client machine is Host B.


'''NOTE: These tutorials are focused on functionality not security. Understanding of the IP mechanisms used in this tutorial fall on the user. Know your network!'''
==== Installing Dependencies ====


Refer to [[InstallingGR#Linux|this page for your specific Linux distro]] to find how to install dependencies.  For example, on Ubuntu 20.04 [[UbuntuInstall#Focal_Fossa_.2820.04.29_through_Impish_Indri_.2821.10.29|use this command]].


*'''METHOD 1'''
==== Installing GNU Radio ====
Changing the IP Addresses in both flowgraphs:
For this example, we will start in the home directory; you can, of course, use any directory you wish and the results will be the same.


*Streaming Server Flowgraph (Host A)
* <code>cd</code>
* <code>git clone https://github.com/gnuradio/gnuradio.git</code>
* <code>cd gnuradio</code>


ZMQ Pub Sink
<b>Note:</b> In the following command, change <code>maint-3.8</code> to some other branch or tag if you want to build a different version of GNU Radio; see [https://github.com/gnuradio/gnuradio/tags tags] for tagged releases including pre-releases ("rc"). For  [https://github.com/gnuradio/gnuradio/branches branches], it's generally wise to stick with "master" (the default after cloning), and, currently: <code>maint-3.7</code> or <code>maint-3.8</code>. Here we checkout the <code>maint-3.8</code> branch, which contains the latest 3.8 release plus any fixes or augmentations to it that will be in the next 3.8 release.
Address <IP Address of Host B -OR- '0.0.0.0'>


XMLRPC Server <IP Address of Host A -OR- '0.0.0.0'>
* <code>git checkout maint-3.8</code>
* <code>git submodule update --init --recursive</code>
* <code>mkdir build</code>
* <code>cd build</code>


*Streaming Client Flowgraph (Host B)
<b>Note:</b> In the following command, you can add <code>-DCMAKE_INSTALL_PREFIX=XXX</code> to install GNU Radio into the PREFIX <code>XXX</code>; if not specified, then the PREFIX is <code>/usr/local</code>. See other CMake options in [[#Common_cmake_flags|Common cmake flags]].<br>


ZMQ Sub Source
* <code>cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../</code>
Address <IP Address of host A>
* <code>make -j3</code> (e.g. if you want to use 3 CPU cores during the build.  To use 8 do -j8, to use 1 leave out the -j flag.)
* <code>sudo make install</code>


XMLRPC Client Block (frequency)
If you're running Linux, then always remember to do the following command after installing any library:
Address <IP Address of host A>
* <code>sudo ldconfig</code>


*'''METHOD 2'''
Go to [[ModuleNotFoundError#B._Finding_the_Python_library|Finding the Python library]] to set your PYTHONPATH and LD_LIBRARY_PATH.<br><b>After setting these environment variables, you need to do</b> <code>sudo ldconfig</code> <b>again</b> for the Linux dynamic library loader to find the just-installed GNU Radio libraries.<br>
SSH Port Forwarding (more information can be found [https://www.ssh.com/academy/ssh/tunneling/example here]
If you have installed in a custom path with <code>-DCMAKE_INSTALL_PREFIX=XXX</code>, you will need to add that path to $PATH in order to find gnuradio-companion.
Using SSH Port Forwarding, a user can keep everything the same in the flowgraphs. We are using port 8000 for XMLRPC and Port 5000 for our ZMQ Streaming Data.
Simply run the following command from Host B:
    ssh -L 8000:localhost:8000 -L 5000:localhost:5000 <username>@<IP Address of Host A>


This SSH command effectively shares any traffic on ports 8000 and 5000 between the two hosts.
==== For Ubuntu 18.04 ====


==GNURadio XMLRPC ZMQ Advanced Usage Example==
An easy way to install GNU Radio 3.8 on many Ubuntu systems is to use the following commands (note that this skips the setup for UHD hardware):
'''Remote Spectrum Monitoring Example using Hardware'''


This portion of the tutorial uses two open source projects that implement the concepts shown above to provide wideband remote spectrum monitoring over a low data rate IP connection.
* <code>sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins python3-zmq python3-scipy python3-pip python3-gi-cairo</code>
* <code>pip3 install git+https://github.com/pyqtgraph/pyqtgraph@develop</code>
* <code>pip3 install numpy scipy</code>
* <code>echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc</code>
* <code>echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc</code>
* <code>echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.profile</code>
* <code>echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.profile</code>
* <code>cd ~/</code>
* <code>git clone --recursive https://github.com/gnuradio/gnuradio</code>
* <code>cd gnuradio</code>
* <code>git checkout maint-3.8</code>
* <code>mkdir build</code>
* <code>cd build</code>
* <code>git pull --recurse-submodules=on</code>
* <code>git submodule update --init</code>
* <code>cmake -DENABLE_GR_UHD=OFF ..</code>
* <code>make -j $(nproc --all)</code>
* <code>sudo make install</code>
* <code>sudo ldconfig</code>


This tutorial assumes you have one of the following Software Defined Radios:
Once this is done, reboot your computer and GNU Radio should be all set for you.
*Ettus Research USRP
*Lime Micro LimeSDR
*RTL-SDR


This tutorial can be run from the same computer, but is intended to be used on two separate machines.
== Common cmake flags ==
Both machines require GNURadio 3.9+ and the proper driver for the radio. In the case of the USRP, UHD is required. For either the LimeSDR or the RTLSDR, GNURadio 3.9+ includes SoapySDR drivers for both.


Clone the following two repositories on the remote host:
* <code>-DENABLE_GR_XXX=ON</code> This enables (or disables for =OFF) the GNU Radio component named XXX. You might not need all of them, and this way, you can compile quicker.
* <code>-DCMAKE_INSTALL_PREFIX=XXX</code> Install your stuff to XXX.
* <code>-DCMAKE_BUILD_TYPE=Debug</code> This causes gcc to add debug symbols to all binaries. Useful for debugging (otherwise, it decreases efficiency!)
* <code>-DPYTHON_EXECUTABLE=/usr/bin/python{2,3}</code> This selects the Python version and executable to be used during build time and will determine which Python libraries will be used for building the Python bindings.
<p>For a list of additional cmake flags, as well as minimum versions of dependencies, see [https://www.gnuradio.org/doc/doxygen/build_guide.html]</p>


*https://github.com:muaddib1984/stillsuit
= Using PyBOMBS =


*https://github.com:muaddib1984/arrakis
PyBOMBS is good at building GNU Radio, UHD, and various Out of Tree (OOT) modules from source and then installing into a specified user directory rather than in the system files. PyBOMBS detects the user's Operating System and loads all of the prerequisites in the first stage of the build.


Clone only the arrakis repository on the local host:
The PyBOMBS documentation is in the PyBOMBS [https://github.com/gnuradio/pybombs#pybombs README].


*https://github.com:muaddib1984/arrakis
= VMs and Live Images =
Over the years a number of Live Images and VMs have been created.  There are currently no official versions but here are some current options:
*[https://github.com/bastibl/instant-gnuradio Instant GNU Radio] A customizable, programmatically generated VM and live environment for GNU Radio.
*[[UbuntuVM]] An Ubuntu 20.04 virtual machine image with GNU Radio 3.8.2.0, Fosphor, GQRX, and several other useful pieces of software. (Created using Instant GNU Radio)




'''REMOTE HOST'''
= OK, it's installed, what now? =
*Attach one of the SDR's listed above to your remote host. Ensure your radio is connected to the host by running either:
For USRP
<pre>uhd_find_devices</pre>
For LimeSDR/RTLSDR
<pre>SoapyUTILS --find</pre>


*From your local host, open an SSH tunnel with IP Forwarding to the remote host:
If the installation worked without any trouble, you're ready to use GNU Radio! If you have no idea how to do that, the best place to start is with the [[Tutorials]].
<br><code>ssh -L 5001:localhost:5001 -L 8001:localhost:8001 -L 8000:localhost:8000 <username>@<hostname|IP Address></code>
*Now you are connected via SSH to the remote terminal.


*If you prefer to have only one terminal window open, from the SSH terminal, run:
Optionally, you may run <code>volk_profile</code> on your terminal to help libvolk to determine the optimal kernels (may speed up GNU Radio).
<br><code>cd path/to/stillsuit</code>
<br><code>./<uhd|lime|rtl>_stillsuit.py &</code> (this will allow you to run the second application from the same terminal)


*If you prefer to have two terminals, you can open a second SSH session, but leave off the '-L' arguments since we already have the ports forwarded in the first shell.
[[Category:Installation]]
*With two terminals, you can also omit the "&" in the previous command.
[[Category:Guide]]
 
*Whether in one or two terminal windows run:
 
<br><code>cd path/to/arakkis</code>
<br><code>space_folder.py</code> note: If you are using an RTLSDR, pass the -s argument to space_folder.py with a value of 2.5e6 like this <br><code>space_folder.py -s 2.5e6</code>
 
 
'''LOCAL HOST'''
*Now open a terminal window on your local machine and run:
 
<br><code>cd path/to/arrakis</code>
<br><code>./guild_navigator.py</code> note: If you are using an RTLSDR, pass the -s argument to guild_navigator.py with a value of 2.5e6 like this <br><code>guild_navigator.py -s 2.5e6</code>
 
*You should see a frequency plot updating at a fairly slow rate.
*To make the frequency plot update faster, change the vectors per second dropdown menu to 8.
*To make the spectrum more stable visually, change the 'Average/Raw' dropdown to 'AVERAGED'.
*If using a USRP/Lime, you can adjust the sampling rate to 40MHz (performance will be dependent on your remote host's processing power.)
*Finally, tune the frequency to 98000000.0 Hz in the frequency window (FM Radio).
 
Your plot should look something like this:
 
[[File:guild_navigator_fm.png]]
 
To measure the data usage from one host to another install an application like 'iftop'
<br><code>sudo apt install iftop</code>
and run it like this:
<br><code>sudo iftop -i lo -P</code>
Port 5000 will have the throughput usage and look similar to this with the above settings:
<pre>
            191Mb        381Mb        572Mb        763Mb    954Mb
└────────────┴─────────────┴─────────────┴─────────────┴─────────────
localhost:5001      => localhost:59814      2.01Mb  2.06Mb  2.01Mb
</pre>
 
This is a powerful capability because we are getting a very human readable frequency plot of live RF Spectrum, while only using a small amount of network data to get it from the remote host!
Furthermore, XMLRPC is allowing us to '''remotely''' adjust all of the parameters of the SDR at runtime!

Revision as of 20:56, 19 February 2022

Beginner Tutorials

Introducing GNU Radio

  1. What is GNU Radio?
  2. Installing GNU Radio
  3. Your First Flowgraph

Flowgraph Fundamentals

  1. Python Variables in GRC
  2. Variables in Flowgraphs
  3. Runtime Updating Variables
  4. Signal Data Types
  5. Converting Data Types
  6. Packing Bits
  7. Streams and Vectors
  8. Hier Blocks and Parameters

Creating and Modifying Python Blocks

  1. Creating Your First Block
  2. Python Block With Vectors
  3. Python Block Message Passing
  4. Python Block Tags

DSP Blocks

  1. Low Pass Filter Example
  2. Designing Filter Taps
  3. Sample Rate Change
  4. Frequency Shifting
  5. Reading and Writing Binary Files

SDR Hardware

  1. RTL-SDR FM Receiver
  2. B200-B205mini FM Receiver
Install Quickstart
(Refer to the rest of this page for more OS and installation options)
Linux
  1. Install Ubuntu 20.04 (either as a VM or natively)
  2. sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.9
  3. sudo apt-get update
  4. sudo apt-get install gnuradio
v3.9.5
Windows
  1. Install the latest Radioconda installer
  2. Launch "GNU Radio Companion" from the Start menu
v3.10.0
macOS
  1. Install Homebrew
  2. brew install gnuradio
v3.9.3


Types of Installation Methods

The recommended way to install GNU Radio on most platforms is using already available binary packages. Find your platform below in the From Binaries section for instructions on how to get GNU Radio through your regular package manager (e.g. Ubuntu PPA Installation), or visit the Conda Installation page for instructions on how to use the Conda package manager to install GNU Radio on any Linux distribution, macOS, or Windows. For some platforms there are no binaries provided by available package managers or the GNU Radio project. In these cases please contact the maintainer of the package manager or the GNU Radio project to find a sensible way to provide binaries for your platform.

GNU Radio can be installed with these 3 methods:

  1. From Binaries (recommended for beginners)
  2. From source (for those who want full control)
  3. Using PyBOMBS (for those who want it built from source and/or installed to a specific directory using a script)

From Binaries

Linux

Most distributions contain a package named gnuradio or similar in their standard repositories. For most use cases it is enough to install this package and start developing.

The development of GNU Radio can be fast-paced, and binaries provided by your distribution may be outdated. Do check if the version you're installing is up to date! Sometimes old versions are not updated in the packaging systems. If you find a bug in a older GNU Radio version, please check if the bug still exists in the newer version of GNU Radio before filing a new issue.

If the version shipped in your distribution is outdated please contact the corresponding maintainer to update it in the packaging system.

Here are examples of how to install GNU Radio in various Linux distributions. Click the link under "Distribution" for how to install dependencies.

Distribution Command
Debian/Ubuntu and derivates
# apt install gnuradio
Fedora
# dnf install gnuradio
RHEL/CentOS
# yum install gnuradio
Archlinux
# pacman -S gnuradio
Gentoo Linux
# emerge net-wireless/gnuradio
Suse Linux

On other distributions, simply use the appropriate package management command to install the gnuradio package and then please add it to this list. If you need newer versions or have a different platform please contact the package maintainer of your distribution or raise your issue on the mailing list.

Ubuntu PPA Installation

For Ubuntu, the latest builds (both released and pulled from master branch) are maintained as PPAs on launchpad. Be sure to uninstall any previously installed versions of gnuradio first.

To access the current released version (3.10), add the gnuradio/gnuradio-releases ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases

To access the 3.9 released version, add the gnuradio/gnuradio-releases-3.9 ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.9

To access the 3.8 released version, add the gnuradio/gnuradio-releases-3.8 ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.8

To access the 3.7 released version (legacy), add the gnuradio/gnuradio-releases-3.7 ppa (removing other gnuradio ppas if already configured)

$ sudo add-apt-repository ppa:gnuradio/gnuradio-releases-3.7

Then, update the apt sources, and install gnuradio

$ sudo apt-get update
$ sudo apt install gnuradio

Attention: Do NOT try to install further packages like `gr-osmosdr` via Ubuntu's package management (i.e. using "apt"). Ubuntu will try to install a potentially incompatible version and your system will be in an undefined state.


Note on 3.10 packaging dependency For some distributions you may need to install the python module 'packaging' using pip (which may also need to be installed).

$ sudo apt install python3-pip
$ pip install packaging

Modtool on Ubuntu

NOTE: On released builds for Ubuntu 18.04 (bionic), there is an issue using gr_modtool after GNU Radio has been installed from the PPA. This is due to byte-compiled code that remains in the modtool templates after installation. To work around this issue:

$ cd /usr/share/gnuradio/modtool/templates/gr-newmod
$ sudo py3clean .

This issue does not appear for Ubuntu 19 and later packages

Fedora COPR Installation

    • NOTE: FEDORA COPR not currently maintained**

Packages are available for Fedora 29, 30, 31 hosted under COPR:

https://copr.fedorainfracloud.org/coprs/gnuradio/

1. Add the repository:

-- For the latest released version:

$ sudo dnf copr enable gnuradio/gnuradio-releases 

-- For the latest pull from git master:

$ sudo dnf copr enable gnuradio/gnuradio-master 

2. Install GNU Radio

$ sudo dnf install gnuradio 

Raspberry Pi

There is a pre-built 32 bit SDR flavored Raspberry Pi OS distro, PiSDR that includes GNU Radio and other SDR utilities. There are also instructions for InstallingGRFromSource_on_Raspberry_Pi.

Windows

See the Conda install guide or radioconda to install GNU Radio 3.8 or newer on Windows.

If you need to install GNU Radio from source refer to the Windows install guide.

Note: GNU Radio support on Windows is improving significantly but remains less tested and there are known problems and even significant bugs which affect regular usage of GNU Radio Companion. Please report bugs on the GitHub Issues page and if you have Windows development experience please consider investigating some of the known issues.

Mac OS X

Refer to the Mac OS X install guide page.

From Source

Binary installation should be sufficient for most users, and certainly for anyone who is new to GNU Radio. However, if you have special requirements, want the latest version, or the binary packages are not working for you, you may want to install GNU Radio from source.

Notes

For GNU Radio 3.10, 3.9, and Main Branch

This section describes how to install GNU Radio 3.10, 3.9, and the Main branch from source code.

Installing Dependencies

Refer to this page for your specific Linux distro to find how to install dependencies. For example, on Ubuntu 20.04 use this command.

Installing Volk

Since Volk is no longer considered as a submodule of GNU Radio (GNU Radio commit #80c04479da962d048d41165081b026aafdaa0316),
you MUST FIRST install Volk, and then install GNU Radio.

The basic idea is the same, but instead of building Volk along with GNU Radio, you need to clone and build it separately. For this example, we will start in the home directory. You can, of course, use any directory you wish and the results will be the same.

Note: In the following command, you can add -DCMAKE_INSTALL_PREFIX=XXX to install Volk into the PREFIX XXX; if not specified, then the PREFIX is /usr/local. See other CMake options in Common cmake flags.

  • cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
  • make
  • make test
  • sudo make install

If you're running Linux, then always remember to do the following command after installing any library:

  • sudo ldconfig

Installing GNU Radio

Note: If you want to build the maint-3.10 or maint-3.9 branch rather than the default main branch, enter: git checkout maint-3.10 and then

  • mkdir build
  • cd build

Note: In the following command, you can add -DCMAKE_INSTALL_PREFIX=XXX to install GNU Radio into the PREFIX XXX; if not specified, then the PREFIX is /usr/local. See other CMake options in Common cmake flags.

  • cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
  • make -j3 (e.g. if you want to use 3 CPU cores during the build. To use 8 do -j8, to use 1, leave out the -j flag.)

Note: In the following command, it is very possible that not all tests pass. Generally any error is a sign of a missing dependency such as the Python interface to ZMQ or NumPy or SciPy, none of which are required for building GNU Radio but are required for testing.

  • make test
  • sudo make install

If you're running Linux, then always remember to do the following command after installing any library:

  • sudo ldconfig

If you encounter "Cannot import gnuradio" error, then go to Finding the Python library to set your PYTHONPATH and LD_LIBRARY_PATH.
After setting these environment variables, you need to do sudo ldconfig again for the Linux dynamic library loader to find the just-installed GNU Radio libraries.
If you have installed in a custom path with -DCMAKE_INSTALL_PREFIX=XXX, you will need to add that path to $PATH in order to find gnuradio-companion.

For GNU Radio 3.8 or Earlier

Installing Dependencies

Refer to this page for your specific Linux distro to find how to install dependencies. For example, on Ubuntu 20.04 use this command.

Installing GNU Radio

For this example, we will start in the home directory; you can, of course, use any directory you wish and the results will be the same.

Note: In the following command, change maint-3.8 to some other branch or tag if you want to build a different version of GNU Radio; see tags for tagged releases including pre-releases ("rc"). For branches, it's generally wise to stick with "master" (the default after cloning), and, currently: maint-3.7 or maint-3.8. Here we checkout the maint-3.8 branch, which contains the latest 3.8 release plus any fixes or augmentations to it that will be in the next 3.8 release.

  • git checkout maint-3.8
  • git submodule update --init --recursive
  • mkdir build
  • cd build

Note: In the following command, you can add -DCMAKE_INSTALL_PREFIX=XXX to install GNU Radio into the PREFIX XXX; if not specified, then the PREFIX is /usr/local. See other CMake options in Common cmake flags.

  • cmake -DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=/usr/bin/python3 ../
  • make -j3 (e.g. if you want to use 3 CPU cores during the build. To use 8 do -j8, to use 1 leave out the -j flag.)
  • sudo make install

If you're running Linux, then always remember to do the following command after installing any library:

  • sudo ldconfig

Go to Finding the Python library to set your PYTHONPATH and LD_LIBRARY_PATH.
After setting these environment variables, you need to do sudo ldconfig again for the Linux dynamic library loader to find the just-installed GNU Radio libraries.
If you have installed in a custom path with -DCMAKE_INSTALL_PREFIX=XXX, you will need to add that path to $PATH in order to find gnuradio-companion.

For Ubuntu 18.04

An easy way to install GNU Radio 3.8 on many Ubuntu systems is to use the following commands (note that this skips the setup for UHD hardware):

  • sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins python3-zmq python3-scipy python3-pip python3-gi-cairo
  • pip3 install git+https://github.com/pyqtgraph/pyqtgraph@develop
  • pip3 install numpy scipy
  • echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.bashrc
  • echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
  • echo 'export PYTHONPATH=/usr/local/lib/python3/dist-packages:usr/local/lib/python2.7/site-packages:$PYTHONPATH' >> ~/.profile
  • echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.profile
  • cd ~/
  • git clone --recursive https://github.com/gnuradio/gnuradio
  • cd gnuradio
  • git checkout maint-3.8
  • mkdir build
  • cd build
  • git pull --recurse-submodules=on
  • git submodule update --init
  • cmake -DENABLE_GR_UHD=OFF ..
  • make -j $(nproc --all)
  • sudo make install
  • sudo ldconfig

Once this is done, reboot your computer and GNU Radio should be all set for you.

Common cmake flags

  • -DENABLE_GR_XXX=ON This enables (or disables for =OFF) the GNU Radio component named XXX. You might not need all of them, and this way, you can compile quicker.
  • -DCMAKE_INSTALL_PREFIX=XXX Install your stuff to XXX.
  • -DCMAKE_BUILD_TYPE=Debug This causes gcc to add debug symbols to all binaries. Useful for debugging (otherwise, it decreases efficiency!)
  • -DPYTHON_EXECUTABLE=/usr/bin/python{2,3} This selects the Python version and executable to be used during build time and will determine which Python libraries will be used for building the Python bindings.

For a list of additional cmake flags, as well as minimum versions of dependencies, see [1]

Using PyBOMBS

PyBOMBS is good at building GNU Radio, UHD, and various Out of Tree (OOT) modules from source and then installing into a specified user directory rather than in the system files. PyBOMBS detects the user's Operating System and loads all of the prerequisites in the first stage of the build.

The PyBOMBS documentation is in the PyBOMBS README.

VMs and Live Images

Over the years a number of Live Images and VMs have been created. There are currently no official versions but here are some current options:

  • Instant GNU Radio A customizable, programmatically generated VM and live environment for GNU Radio.
  • UbuntuVM An Ubuntu 20.04 virtual machine image with GNU Radio 3.8.2.0, Fosphor, GQRX, and several other useful pieces of software. (Created using Instant GNU Radio)


OK, it's installed, what now?

If the installation worked without any trouble, you're ready to use GNU Radio! If you have no idea how to do that, the best place to start is with the Tutorials.

Optionally, you may run volk_profile on your terminal to help libvolk to determine the optimal kernels (may speed up GNU Radio).