Gnuradio Programming
Gnuradio Programming
Manolis Surligas
[email protected]
Computer Science Department, University of Crete
Extending GNU Radio
1
GNU Radio OOT-modules
Advantages:
• Easily maintained by individual developers
3
OOT module structure
4
GNU Radio block types
5
Synchronous Blocks (1:1)
6
Interpolation Blocks (1:N)
7
Decimation Blocks (N:1)
8
Basic Blocks (M:N)
• All other block types are derived from the basic block
9
IO Signatures
10
IO Signatures
gr::io_signature::make(2, 2, sizeof(gr_complex));
Example 1: Declare exactly 2 ports, the first with float items and
the second with items consisting form 64 complex numbers
gr::io_signature::make2(2, 2, sizeof(float),
64 * sizeof(gr_complex));
11
Items Processing
int
work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
int
general_work(int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
14
Retrieve IO ports buffers
15
Access input and output items
17
Build system
• GNU Radio and OOT modules use the CMake build system
19
Creating a block from the beginning
• When asked choose sync block as the block type and cpp
for the implementation language
20
Creating a block from the beginning
• As this block does not provide any setter and getter, there
is no need to change the
include/fosscomm2018/complex_clamp.h file
21
Creating a block from the beginning
public:
complex_clamp_impl(const float threshold);
~complex_clamp_impl();
22
Creating a block from the beginning
23
Creating a block from the beginning
int
complex_clamp_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
int i;
24
Creating a block from the beginning
...
for(i = 0; i < noutput_items; i++){
out[i] = in[i];
if(in[i].real() > d_threshold){
out[i].real(d_threshold);
}
<?xml version="1.0"?>
<block>
<name>complex_clamp</name>
<key>fosscomm2018_complex_clamp</key>
<category>fosscomm2018</category>
<import>import fosscomm2018</import>
<make>fosscomm2018.complex_clamp($threshold)</make>
<!-- Make one 'param' node for every Parameter you want settable from the GUI.
Sub-nodes:
* name
* key (makes the value accessible as $keyname, e.g. in the make node)
* type -->
<param>
<name>Threshold</name>
<key>threshold</key>
<type>real</type>
</param>
...
</block>
26
Creating a block from the beginning
<?xml version="1.0"?>
<block>
...
<!-- Make one 'sink' node per input. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<sink>
<name>in</name>
<type>complex</type>
</sink>