<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.17.0" xml:lang="en-US">
  <compounddef id="page_ctrlport" kind="page">
    <compoundname>page_ctrlport</compoundname>
    <title>ControlPort</title>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
<sect1 id="page_ctrlport_1ctrlport_introduction">
<title>Introduction</title><para>This is the ControlPort package. It is a tool to create distributed control applications for GNU Radio. It provides blocks that can be connected to an output stream to plot the signal remotely. It also provides an API that allows blocks to export variables that can be set, monitored, and plotted remotely.</para>
<para>ControlPort-specific functions and utilities are found in the &apos;ctrlport&apos; namespace. From Python, access is done using the gnuradio.ctrlport module, imported as:</para>
<para><programlisting><codeline><highlight class="normal">from<sp/><ref refid="namespacegnuradio" kindref="compound">gnuradio</ref><sp/></highlight><highlight class="keyword">import</highlight><highlight class="normal"><sp/>ctrlport</highlight></codeline>
</programlisting></para>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_conf">
<title>Configuration</title><para>ControlPort is configured using two files. The first is the GNU Radio preferences file while the second file is specific to the type of middleware used.</para>
<para>The GNU Radio preferences file has three options. The &apos;on&apos; option is used to enable or disable the use of ControlPort, and is disabled by default. The &apos;config&apos; option allows a user to specify the middleware-specific configuration file. The &apos;edges_list&apos; is a special option that exports the list of nodes and edges of the flowgraph across ControlPort. This latter option is mainly used for redrawing the flowgraph for the Performance Counter applications.</para>
<para><programlisting><codeline><highlight class="normal">[ControlPort]</highlight></codeline>
<codeline><highlight class="normal">on<sp/>=<sp/>True</highlight></codeline>
<codeline><highlight class="normal">edges_list<sp/>=<sp/>True</highlight></codeline>
<codeline><highlight class="normal">config<sp/>=<sp/>path-to/ctrlport.conf</highlight></codeline>
</programlisting></para>
<para>The ControlPort preferences are installed by default into &apos;gnuradio-runtime.conf&apos;. These can always be overridden in the local ~/.gnuradio/config.conf file.</para>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_deps">
<title>Dependencies</title><para>ControlPort is an abstracted remote procedure call tool that. It is built on top of other middleware libraries. The following subsections explain some details about the use of the particular middleware project.</para>
<para>Currently, the only implemented middleware library is the Apache Thrift project.</para>
<sect2 id="page_ctrlport_1ctrlport_thrift">
<title>Apache Thrift</title><para>Current version support: &gt;= 0.9.2</para>
<para>Apache Thrift is a middleware layer that defines interfaces of a program using its own Thrift language. GNU Radio&apos;s interface file is:</para>
<para>gnuradio-runtime/lib/controlport/thrift/gnuradio.thrift</para>
<para>This file defines the interfaces set, get, trigger, and properties. It also defines a set of data structure Knobs to allow us to pass any type of data over the interfaces.</para>
<para>To use Thrift in ControlPort requires a minimum Thrift version of 0.9.0. If a Thrift version greater than or equal to this version is not found, the Thrift backend to ControlPort will not be installed, through ControlPort itself still will be. During cmake configuration time, it prints out information about finding Thrift and requires:</para>
<para><itemizedlist>
<listitem><para>Thrift header files by looking for thrift/Thrift.h </para>
</listitem>
<listitem><para>Thrift C++ libraries: libthrift.so </para>
</listitem>
<listitem><para>Thrift Python bindings: &quot;import thrift&quot;</para>
</listitem>
</itemizedlist>
If all of these are not satisfied, the Thrift backend will not be installed. Upon completion, cmake outputs a notification of what components will be built. You will see this if Thrift was found and can be used:</para>
<para><programlisting><codeline><highlight class="normal"><ref refid="namespacegr" kindref="compound">gr</ref>-ctrlport</highlight></codeline>
<codeline><highlight class="normal">*<sp/>thrift</highlight></codeline>
</programlisting></para>
<para>Cmake also uses the Thrift compiler (&quot;thrift&quot;) to build the C++ and Python files necessary for compiling ControlPort. It runs &quot;thrift
--gen cpp&quot; the C++ bindings in the build directory, and then it runs &quot;thrift --gen py&quot; to build the Python bindings, also in the build directory. These are used to compile the Thrift ControlPort features and are necessary files to run the Python clients. If cmake fails to produce these bindings, it should error out.</para>
<sect3 id="page_ctrlport_1ctrlport_thrift_prefs">
<title>Configuration</title><para>Thrift does not support its own concept of a configuration file, so we have built one for our purposes in GNU Radio. The &apos;config&apos; option in the ControlPort section of the preference files tells ControlPort where to find the backend-specific file format. GNU Radio&apos;s Thrift format follows the same &quot;[Section] key = value&quot; scheme used in all of its other preference files. Currently supported configuration options are:</para>
<para><programlisting><codeline><highlight class="normal">[thrift]</highlight></codeline>
<codeline><highlight class="normal">port<sp/>=<sp/>9090</highlight></codeline>
<codeline><highlight class="normal">nthreads<sp/>=<sp/>2</highlight></codeline>
<codeline><highlight class="normal">buffersize<sp/>=<sp/>1434</highlight></codeline>
<codeline><highlight class="normal">init_attempts<sp/>=<sp/>100</highlight></codeline>
</programlisting></para>
</sect3>
<sect3 id="page_ctrlport_1ctrlport_thrift_issues">
<title>Thrift: Current Issues</title><para>Thrift uses a thread pool system to handle each connection, but it will only allow up to a specified number of threads in the server. The default value is 10 threads, but the Thrift configuration file allows the user to change this value.</para>
<para>Thrift also does not find and use a free ephemeral port when launching the server. It must be told explicitly which port to launch on, which we set in the configuration file. This makes it difficult to launch multiple flowgraphs on the same machine because that will cause a port collision. Until this is fixed, a way around this is to use the environmental variable GR_CONF_THRIFT_PORT=xxx to set the port number for that specific application.</para>
<para>Efficiency issues of Thrift come from the over-the-wire formatting done by the transport protocol. It defaults to using 512 byte packets, which can lead to a lot of fragmentation of the data over the connection. The buffersize configuration allows the user to set this value to whatever number fits their network needs. The default 1434 is designed around the standard 1500 byte Ethernet frame size limit minus the TCP/IP and Ethernet header size.</para>
</sect3>
</sect2>
<sect2 id="page_ctrlport_1ctrlport_client_translation">
<title>Translation Layer for Clients</title><para>Different backends will produce different ways to interface with the system. ControlPort in the running flowgraph acts as the server by exposing interfaces to blocks. The interfaces and API in GNU Radio to communicate with ControlPort are all abstracted completely away from the backend methods and data types. That is, the code in GNU Radio&apos;s scheduler and in the blocks that expose their ControlPort interfaces will work regardless of the backend used.</para>
<para>We are building better abstractions on the clients sides now, as well. Although certain backends will support other features of discovery and services that work well with their products, GNU Radio wants to make sure that clients can access the data from the interfaces in the same way for any backend used. This abstraction is done through the GNURadioControlPortClient. This class is told which type of backend is used, and defaults to Thrift, and can be passed information about the server&apos;s endpoint such as the host name and port number to attach to. The GNURadioControlPortClient returns a &apos;radio&apos; object that represents the connection to the running flowgraph.</para>
</sect2>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_using">
<title>Using ControlPort to Export Variables</title><para>The ability to export variables from a block is inherited from <ref refid="classgr_1_1block" kindref="compound">gr::block</ref>. Then, when the flowgraph is started, the function <bold>setup_rpc()</bold> is called in turn for each block. By default, this is an empty function. A block overloads this function and defines and exports variables in it.</para>
<para>Say we have a class <bold>gr::blocks::foo</bold> that has variables <bold>a</bold> and <bold>b</bold> that we want to export. Specifically, we want to be able to read the values of both <bold>a</bold> and <bold>b</bold> and also set the value of <bold>b</bold>. The class <bold>gr::blocks::foo</bold> has setters and getters all set up. So our class implementation header file looks something like:</para>
<para><programlisting><codeline><highlight class="keyword">namespace<sp/></highlight><highlight class="normal"><ref refid="namespacegr" kindref="compound">gr</ref><sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">namespace<sp/></highlight><highlight class="normal"><ref refid="namespacegr_1_1blocks" kindref="compound">blocks</ref><sp/>{</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">class<sp/></highlight><highlight class="normal">foo_impl<sp/>:<sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal"><sp/>foo</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">private</highlight><highlight class="normal">:</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/><sp/>d_a,<sp/>d_b;</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">public</highlight><highlight class="normal">:</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>foo_impl(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>a,<sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>b);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>~foo_impl();</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>a()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>d_a;<sp/>}</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>b()</highlight><highlight class="keyword"><sp/>const<sp/></highlight><highlight class="normal">{<sp/></highlight><highlight class="keywordflow">return</highlight><highlight class="normal"><sp/>d_a;<sp/>}</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>set_a(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>a)<sp/>{<sp/>d_a<sp/>=<sp/>a;<sp/>}</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>set_b(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>b)<sp/>{<sp/>d_b<sp/>=<sp/>b;<sp/>}</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>setup_rpc();</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>work(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>noutput_items,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="types_8h_1a80a98fdffb55a4616a3078a827898dc1" kindref="member">gr_vector_const_void_star</ref><sp/>&amp;input_items,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="types_8h_1a9f99903ecddf0897227ef6e1eeca2106" kindref="member">gr_vector_void_star</ref><sp/>&amp;output_items);</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>};</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="comment">/*<sp/>namespace<sp/>blocks<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal">}<sp/></highlight><highlight class="comment">/*<sp/>namespace<sp/>gr<sp/>*/</highlight></codeline>
</programlisting></para>
<para>The source code then sets up the class and fills in <bold>setup_rpc()</bold>.</para>
<para><programlisting><codeline><highlight class="keyword">namespace<sp/></highlight><highlight class="normal"><ref refid="namespacegr" kindref="compound">gr</ref><sp/>{</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/></highlight><highlight class="keyword">namespace<sp/></highlight><highlight class="normal"><ref refid="namespacegr_1_1blocks" kindref="compound">blocks</ref><sp/>{</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>foo_impl::foo_impl(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>a,<sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>b):</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>sync_bloc(....),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>d_a(a),<sp/>d_b(b)</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>{<sp/>}</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>foo_impl::~foo_impl()</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>{<sp/>}</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>foo_impl::setup_rpc()</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>{</highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="preprocessor">#ifdef<sp/>GR_CTRLPORT</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>add_rpc_variable(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rpcbasic_sptr(</highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="classrpcbasic__register__get" kindref="compound">rpcbasic_register_get&lt;foo, float&gt;</ref>(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>alias(),<sp/></highlight><highlight class="stringliteral">&quot;a&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;foo::a,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(-2.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(2.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(0.0f),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,<sp/></highlight><highlight class="stringliteral">&quot;Get<sp/>value<sp/>of<sp/>a&quot;</highlight><highlight class="normal">,<sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096acc5682c79636a2486c194425df36d2d4" kindref="member">RPC_PRIVLVL_MIN</ref>,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1a17f36a009e810d89b9b9da710b2fd6db" kindref="member">DISPTIME</ref><sp/>|<sp/><ref refid="rpccallbackregister__base_8h_1a090796a9ee39087d8d207d31a1e6bb69" kindref="member">DISPOPTSTRIP</ref>)));</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>add_rpc_variable(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rpcbasic_sptr(</highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="classrpcbasic__register__get" kindref="compound">rpcbasic_register_get&lt;foo, float&gt;</ref>(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>alias(),<sp/></highlight><highlight class="stringliteral">&quot;b&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;foo::b,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(0.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(20.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(10.0f),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,<sp/></highlight><highlight class="stringliteral">&quot;Get<sp/>value<sp/>of<sp/>b&quot;</highlight><highlight class="normal">,<sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096acc5682c79636a2486c194425df36d2d4" kindref="member">RPC_PRIVLVL_MIN</ref>,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1a17f36a009e810d89b9b9da710b2fd6db" kindref="member">DISPTIME</ref><sp/>|<sp/><ref refid="rpccallbackregister__base_8h_1a090796a9ee39087d8d207d31a1e6bb69" kindref="member">DISPOPTSTRIP</ref>)));</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/>add_rpc_variable(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>rpcbasic_sptr(</highlight><highlight class="keyword">new</highlight><highlight class="normal"><sp/><ref refid="structrpcbasic__register__set" kindref="compound">rpcbasic_register_set&lt;foo, float&gt;</ref>(</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>alias(),<sp/></highlight><highlight class="stringliteral">&quot;b&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>&amp;foo::set_b,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(0.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(20.0f),<sp/><ref refid="namespacepmt_1a90faad6086ac00280e0cfd8bb541bd64" kindref="member">pmt::mp</ref>(10.0f),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,<sp/></highlight><highlight class="stringliteral">&quot;Set<sp/>value<sp/>of<sp/>b&quot;</highlight><highlight class="normal">,<sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096acc5682c79636a2486c194425df36d2d4" kindref="member">RPC_PRIVLVL_MIN</ref>,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1a083912edd1265872708667efecd2444b" kindref="member">DISPNULL</ref>)));</highlight></codeline>
<codeline><highlight class="normal"></highlight><highlight class="preprocessor">#endif<sp/></highlight><highlight class="comment">/*<sp/>GR_CTRLPORT<sp/>*/</highlight><highlight class="preprocessor"></highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">int</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>foo_impl::work(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>noutput_items,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="types_8h_1a80a98fdffb55a4616a3078a827898dc1" kindref="member">gr_vector_const_void_star</ref><sp/>&amp;input_items,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="types_8h_1a9f99903ecddf0897227ef6e1eeca2106" kindref="member">gr_vector_void_star</ref><sp/>&amp;output_items)</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>{<sp/>....<sp/>}</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/>}<sp/></highlight><highlight class="comment">/*<sp/>namespace<sp/>blocks<sp/>*/</highlight><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal">}<sp/></highlight><highlight class="comment">/*<sp/>namespace<sp/>gr<sp/>*/</highlight></codeline>
</programlisting></para>
<para>In the above example, we&apos;re ignoring some of the basic semantics of the class as a GNU Radio block and focus just on the call to set up the get and set functions over ControlPort. Each block has a function that allows us to add a new ControlPort interface object to a list, the <bold>add_rpc_variable</bold>. We don&apos;t care about that list anymore; that&apos;s for ControlPort to worry about. We just add new variables, either setters or getters.</para>
<para>Without dissecting every piece of the above calls, notice that we use the public class, <bold>gr::blocks::foo</bold> as the class, not the implementation class. We also use the block&apos;s alias, which GNU Radio uses as a database entry to connect a block by name to the pointer in memory. This allows ControlPort to know where the object in memory is at any given time to access the setters and getters.</para>
<para>The three PMTs specified are simply an expected minimum, maximum, and default value. None of these are strictly enforced and only serve as guides. The RPC_PRIVLVL_MIN is currently a placeholder for a privilege level setting. In many cases, reading <bold>b</bold> might be fine for everyone, but we want strong restrictions on who has the ability to set <bold>b</bold>.</para>
<para>And finally, we can specify display options to hint at the right way to display this variable when remotely plotting it. More on that in the following section.</para>
<para>Finally, note that we put #ifdefs around the code. We always want <bold>setup_rpc</bold> to be there and callable, but if ControlPort was not built for GNU Radio, we cannot register any variables with it. This is just a nicety to allow us to set up our code for use with ControlPort without requiring it.</para>
<sect2 id="page_ctrlport_1ctrlport_alt_reg">
<title>Alternative Registers</title><para>If using the concept above, <bold>setup_rpc</bold> automatically gets called when the flowgraph is started. In most instances, this is all we ever need since there&apos;s nothing interesting going on until then. However, if not using a <ref refid="classgr_1_1block" kindref="compound">gr::block</ref> or needing access before we run the flowgraph, the above method won&apos;t work (it comes down to when the block&apos;s alias has meaning).</para>
<para>There are alternate variable registration functions for the sets and gets. These take the form:</para>
<para><programlisting><codeline><highlight class="normal"><ref refid="classrpcbasic__register__get" kindref="compound">rpcbasic_register_get</ref>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>std::string&amp;<sp/>name,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>functionbase,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>T*<sp/>obj,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Tfrom<sp/>(T::*function)(),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;min,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;max,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;def,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>units_<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>desc_<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096" kindref="member">priv_lvl_t</ref><sp/>minpriv_<sp/>=<sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096acc5682c79636a2486c194425df36d2d4" kindref="member">RPC_PRIVLVL_MIN</ref>,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1aba9c0dec36f846b8a092d7d45ad4ecd3" kindref="member">DisplayType</ref><sp/>display_<sp/>=<sp/><ref refid="rpccallbackregister__base_8h_1a083912edd1265872708667efecd2444b" kindref="member">DISPNULL</ref>)</highlight></codeline>
<codeline><highlight class="normal"></highlight></codeline>
<codeline><highlight class="normal"><ref refid="structrpcbasic__register__set" kindref="compound">rpcbasic_register_set</ref>(</highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/>std::string&amp;<sp/>name,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>functionbase,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>T*<sp/>obj,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/>(T::*function)(Tto),</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;min,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;max,<sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/><ref refid="namespacepmt_1a94a208b58dc16675b02674c28784d88b" kindref="member">pmt::pmt_t</ref><sp/>&amp;def,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>units_<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keyword">const</highlight><highlight class="normal"><sp/></highlight><highlight class="keywordtype">char</highlight><highlight class="normal">*<sp/>desc_<sp/>=<sp/></highlight><highlight class="stringliteral">&quot;&quot;</highlight><highlight class="normal">,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096" kindref="member">priv_lvl_t</ref><sp/>minpriv_<sp/>=<sp/><ref refid="rpccallbackregister__base_8h_1a49bbe5b25d6264b2ebfc1ffd260cb096acc5682c79636a2486c194425df36d2d4" kindref="member">RPC_PRIVLVL_MIN</ref>,</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="rpccallbackregister__base_8h_1aba9c0dec36f846b8a092d7d45ad4ecd3" kindref="member">DisplayType</ref><sp/>display_<sp/>=<sp/><ref refid="rpccallbackregister__base_8h_1a083912edd1265872708667efecd2444b" kindref="member">DISPNULL</ref>)</highlight></codeline>
</programlisting></para>
<para>The only thing different about the above code is that instead of taking a single &apos;alias()&apos; name, which provides us access to the objects pointer, we instead provide a unique name (<bold>fucntionbase</bold>) and a pointer to the object itself (<bold>obj</bold>). These are templated functions, so the class T is known from that.</para>
<para>If using this method, the recommended way is to create a new function (not <bold>setup_rpc</bold>), register the variable using <bold>add_rpc_variable</bold> but with the different <bold>register_get/set</bold> shown here, and then call this function either in the object&apos;s constructor or make it a public member function to be called when you need it.</para>
</sect2>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_disp">
<title>Display Options</title><para>When exporting a new RPC variable over ControlPort, one argument is a display options mask. These options are useful to a remote client to tell identify activities like default plotters and initial conditions. The <bold>gr-ctrlport-monitor</bold> application uses this heavily in determining how to plot ControlPort variables.</para>
<para>The options mask is just a 32-bit value with options OR&apos;d together. Certain options are only appropriate for certain types of plots. Options on plots where that option is not available will simply be ignored.</para>
<para>The main caveat to be aware of is that the DISPXY plot type is specific to complex values. Therefore, DISPOPTCPLX is assumed.</para>
<para>These options are specified in <ref refid="rpccallbackregister__base_8h" kindref="compound">rpccallbackregister_base.h</ref> and are exposed through SWIG to live in the <bold>gr</bold> namespace.</para>
<para><bold>Plot Types</bold> <itemizedlist>
<listitem><para><bold>DISPNULL:</bold> Nothing specified. </para>
</listitem>
<listitem><para><bold>DISPTIME:</bold> Time-domain plot. </para>
</listitem>
<listitem><para><bold>DISPXY:</bold> XY or constellation plot (complex only). </para>
</listitem>
<listitem><para><bold>DISPPSD:</bold> PSD plot. </para>
</listitem>
<listitem><para><bold>DISPSPEC:</bold> Spectrogram plot. </para>
</listitem>
<listitem><para><bold>DISPRAST:</bold> Time raster plot (non-complex only)</para>
</listitem>
</itemizedlist>
<bold>Plot Options</bold> <itemizedlist>
<listitem><para><bold>DISPOPTCPLX:</bold> Signal is complex. </para>
</listitem>
<listitem><para><bold>DISPOPTLOG:</bold> Start plot in semilog-y mode (time domain only). </para>
</listitem>
<listitem><para><bold>DISPOPTSTEM:</bold> Start plot in stem mode (time domain only). </para>
</listitem>
<listitem><para><bold>DISPOPTSTRIP:</bold> Run plot as a stripchart (time domain only). </para>
</listitem>
<listitem><para><bold>DISPOPTSCATTER:</bold> Do scatter plot instead of lines (XY plot only).</para>
</listitem>
</itemizedlist>
</para>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_probes">
<title>ControlPort Probes</title><para>ControlPort provides a set of probes that can be used as sinks that pass vectors of data across ControlPort. These probes are used to sample or visualize data remotely. We can place a ControlPort probe anywhere in the flowgraph to grab the latest sample of data from the block it&apos;s connected to.</para>
<para>The main ControlPort probe to use is <bold>blocks.ctrlport_probe2_x</bold>. From GRC, this is simply &quot;CtrlPort
Probe&quot;, which can handle complex, floats, ints, shorts, and bytes. The blocks are named and given a description to identify them over ControlPort. The blocks also take a vector length for how many samples to pass back at a time. Finally, these blocks take a display hint, as described in the above section. This allows us to specify the default behavior for how to display the samples.</para>
<para>Another block that can be used is the <bold>fft.ctrlport_probe_psd</bold> to calculate the PSD and pass that over the ControlPort interface.</para>
</sect1>
<sect1 id="page_ctrlport_1ctrlport_monitors">
<title>ControlPort Monitors</title><para>There are two main ControlPort monitor applications provided with GNU Radio. Both act similarly. The first is a standard ControlPort monitor application. This connects to a running flowgraph and displays all exported interfaces in a table format. The name, unit, latest sample, and description of all interfaces are display in a row. Double-clicking will open up the default display. Right clicking any item will allow the user to select the type of plot to use to display the data.</para>
<para>When a display is active, using the buttons at the top, the subwindows can all be tiled or windowed as needed to manage the full interface. We can then drag-and-drop any other item on top of a currently running display plot.</para>
<para>To launch the ControlPort monitor application, know the IP address and port of the ControlPort endpoint established by the flowgraph and run:</para>
<para><preformatted>
gr-ctrlport-monitor &lt;ip-addr&gt; &lt;port&gt;
</preformatted></para>
<sect2 id="page_ctrlport_1perfmonitor">
<title>Performance Monitor</title><para>A second application is used to locally redraw the flowgraph and display some of the Performance Counters. In this application, the nodes are blue boxes where the size of the box is proportional to the work time and the color depth and line width are proportional to the output buffer fullness.</para>
<para>The controls at the top of the Performance Monitor application allow us to select the instantaneous, average, and variance values of the Performance Counters. And the work time and buffer fullness can be displayed as a table or bar graph.</para>
<para>To launch the Performance Monitor, run:</para>
<para><preformatted>
gr-perf-monitorx &lt;ip-addr&gt; &lt;port&gt;
</preformatted> </para>
</sect2>
</sect1>
    </detaileddescription>
    <location file="/pbulk/work/ham/gnuradio-doxygen/work/gnuradio-3.10.12.0/docs/doxygen/other/ctrlport.dox"/>
  </compounddef>
</doxygen>
