User:Muaddib: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
No edit summary
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Understanding XMLRPC Blocks==
-Conditional Variables
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.
  -using variable values as triggers with conditionals
  -dynamic file naming with timestamps
  -Push-Button I/Q Field Recorder
-python file interaction
  -keyword search for files
  -I/Q File Rolodex for Fast Post-Analysis


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.
-Slow Motion I/Q File Playback
 
  -adjustable throttle
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.
 
==Reference Links==
http://xmlrpc.com
 
https://docs.python.org/3.8/library/xmlrpc.html
 
==Prerequisites==
* [[Guided_Tutorial_GRC|Intro to GR usage: GRC and flowgraphs]]
 
* [[Understanding_ZMQ_Blocks|Understanding ZMQ Blocks]]
 
==Introduction: ''What does XMLRPC do in GNURadio and Why Should I Care?''==
'''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.
 
==Contents of Tutorial==
 
GNURadio XMLRPC Examples
 
*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]).
 
GNURadio XMLRPC Examples with ZMQ Streaming Data Visualization
 
*Here we will modify the examples to include ZMQ streaming so we can visualize the remote flowgraph's datastream in our XMLRPC Client flowgraph.
 
GNURadio XMLRPC Remote Control Over IP Network
 
*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)
 
GNURadio XMLRPC Advanced Usage Example
 
*(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.
 
==Simple Example==
 
Open the [https://github.com/gnuradio/gnuradio/blob/maint-3.9/gr-blocks/examples/xmlrpc/siggen_xmlrpc_server.grc siggen_xmlrpc_server.grc] flowgraph.
 
Shown here:
 
[[File:Xmlrpc_server.png]]
 
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
 
Shown here:
 
[[File:Xmlrpc_client.png]]
 
 
First, Run the Siggen Server Flowgraph
 
Your GUI window should look like this:
 
[[File:Xmlrpc_server_before.png]]
 
Next, run the Siggen Controller flowgraph
 
Your GUI window should look like this:
 
<controller.jpg>
 
Arrange both GUI windows so you can see them at the same time.
 
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:
 
[[File:Xmlrpc_server_after.png]]
 
That's it, you've just remote controlled a flowgraph over a network socket!
 
Close both GUI windows and continue to the next tutorial.
 
==GNURadio XMLRPC Examples with ZMQ Streaming Data Visualization==
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:
 
    "siggen_xmlrpc_server_streaming.grc"
    "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)
 
*In the Streaming Server, copy the throttle and GUI display blocks, then paste them into the Streaming Controller flowgraph.
 
[[File:Xmlrpc_client_streaming_add_GUI.png]]
 
*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.
 
    ZMQ PUB SINK PARAMETERS:
        '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.
 
[[File:Xmlrpc_server_streaming_add_ZMQ.png]]
 
 
*In the Streaming Client flowgraph.
 
Change the sample rate to match the Streaming Server flowgraph (32ksps)
 
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.
 
[[File:Xmlrpc_client_streaming_add_ZMQ.png]]
 
    ZMQ SUB SOURCE PARAMETERS:
        'Address': tcp://127.0.0.1:5000
        'Pass Tags': 'Yes'
        All others default
 
*RUN IT!
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.
 
In the Controller GUI:
Adjust the slider as before and observe the frequency changing.
 
[[File:Xmlrpc_client_streaming_complete.png]]
 
You are now both remote controlling and viewing streaming data over a network connection!
 
==GNURadio XMLRPC Remote Control Over IP Network==
 
==GNURadio XMLRPC Advanced Usage Example==
*audio output to ZMQ

Latest revision as of 01:23, 21 February 2022

-Conditional Variables

 -using variable values as triggers with conditionals
 -dynamic file naming with timestamps
 -Push-Button I/Q Field Recorder

-python file interaction

 -keyword search for files
 -I/Q File Rolodex for Fast Post-Analysis

-Slow Motion I/Q File Playback

 -adjustable throttle