当前位置:网站首页>Gnuradio3.9.4 create OOT module instances

Gnuradio3.9.4 create OOT module instances

2022-07-08 01:22:00 You roll, I don't roll

Catalog

1、 Create your own block( Be careful module And block The difference between )

1.1、 establish module 

1.2、 In the created myDemux Created in block 

2、 Modify the corresponding code

2.1、 modify C++ Code

2.2、 modify yaml file

3、 Compilation and installation

4、 of bug The solution of the


This tutorial is a record based on the actual experience of the Laboratory . It is mainly recorded after modifying the source code of a module , How to create a new copy of the module to replace the original instead of overwriting ( The original module code is not modified ).

in application , We changed it gnuradio Of Header/Payload Demux Module source code , But I don't want to directly cover the original code , Therefore, you need to create a named my Header/Payload Demux Custom modules for , Create a process in this record for future reference .

Before written How to be in GR3.8 Created in OOT modular , Actually GR3.9 Created in OOT Methods and 3.8 Almost the same as , The main difference is  GR3.9 in python And C++ The binding method is different ,3.8 It's using swing,3.9 It's using pybind11, But this does not need us to consider , The program will run automatically python And C++ The binding of . So there is no difference on the whole .

This process only records the method , Don't talk . See the details as follows :

1、 Create your own block( Be careful module And block The difference between )

1.1、 establish module 

Create a new folder to store the compiled modules , Be careful not to be associated with gnuradio Same folder , Execute the following command , First create a new one called  myDemux Of module.

cd   Your folder 
gr_modtool newmod myDemux

Get into module in

cd gr-myDemux/

1.2、 In the created myDemux Created in block 

Then add block, be known as  my_header_payload_demux

[email protected]:~/USRPWorkArea/mymodule/gr-myDemux$ gr_modtool add -t general -l cpp my_header_payload_demux
GNU Radio module name identified: myDemux
Language: C++
Block/code identifier: my_header_payload_demux
Please specify the copyright holder: 
Enter valid argument list, including default arguments: 
Add Python QA code? [Y/n] y
Add C++ QA code? [y/N] n
Adding file 'lib/my_header_payload_demux_impl.h'...
Adding file 'lib/my_header_payload_demux_impl.cc'...
Adding file 'include/myDemux/my_header_payload_demux.h'...
Adding file 'python/bindings/docstrings/my_header_payload_demux_pydoc_template.h'...
Adding file 'python/bindings/my_header_payload_demux_python.cc'...
Adding file 'python/qa_my_header_payload_demux.py'...
Editing python/CMakeLists.txt...
Adding file 'grc/myDemux_my_header_payload_demux.block.yml'...
Editing grc/CMakeLists.txt...

2、 Modify the corresponding code

2.1、 modify C++ Code

Edit related documents , It is recommended to use VSCode, Why not? , Just be convenient , Other editors also work

You need to add  

gr-digital / lib / header_payload_demux_impl.cc

gr-digital / lib / header_payload_demux_impl.h

include / gnuradio / digital / header_payload_demux.h

Copy the contents of three files to the created block The corresponding position of , Then modify the corresponding source code , Pay attention to modifying some Class name Namespace namespace Include header file The content such as . Here are just a few places that are easy to ignore

1、 The original namespace :

namespace gr {
namespace digital {
......
}
}

To be changed to ( Every C++ All documents should be modified ):

namespace gr {
namespace myDemux {
......
}
}

2、 And the original  header_payload_demux_impl.cpp All of the documents  header_payload_demux Fields need to be changed to my_header_payload_demux.

3、 Just keep the predefined names in the header file as they were created

#ifndef INCLUDED_MYDEMUX_MY_HEADER_PAYLOAD_DEMUX_IMPL_H
#define INCLUDED_MYDEMUX_MY_HEADER_PAYLOAD_DEMUX_IMPL_H
.......
#endif /* INCLUDED_MYDEMUX_MY_HEADER_PAYLOAD_DEMUX_IMPL_H */

2.2、 modify yaml file

in addition , In the source code  grc / digital_header_payload_demux.block.yml Copy the contents of to the created block The corresponding position of , And pay attention to modifying all of them and  header_payload_demux The relevant content is my_header_payload_demux; modify primary label label Header/Payload Demux by  my_header_payload_demux; And then there is import The label also needs to be modified to

imports: import myDemux

in addition  cpp_templates Labeled  includes The sub tag is modified to  my_header_payload_demux.h The absolute path of ( It's easy ). Other details are easy to distinguish , All need to be revised one by one .

Then execute the following command python And Binding of header file . Be careful !! This is a necessary step , Just change it include Header file in folder ( These are all public header files ) You need to re execute this command to bind , And modify lib This step can be omitted when the header file in the folder . This step is also related to GR3.8 One obvious difference between .

gr_modtool bind [blockname]

In particular , Here because of the creation block be known as  my_header_payload_demux, So the command is as follows :

gr_modtool bind my_header_payload_demux

3、 Compilation and installation

Then back gr-myDemux File and create build Folder , Then compile .

mkdir build
cd build
cmake ../
make -j10
sudo make install
sudo ldconfig

That's all . The effect is as follows :

================== Important BUG modify ==================== 

If all the compilers pass , The errors reported when using are as follows

AttributeError: 'myDemux.myDemux_python.my_header_payload_demux' object has no attribute 'to_basic_block'

Just like shape. :AttributeError: '×××' object has no attribute 'to_basic_block' Such a mistake , This is again binding There's something wrong with the document ( Mo panic ,bind Just these questions , No other problems have been found so far ), The solution is still on the official website :

  Just need to put  python/bindings/[blockname]_python.cc Add these parameters to the corresponding positions in the file :

gr::sync_block,  //  Don't add 
gr::block,
gr::basic_block,

The effect after adding :

 ================== Important BUG END ====================  

Last , If you want to create a new module Add a new block, You need to get there first build Remove the original installation from the folder :

cd build
sudo make uninstall

And then put build Delete folder

rm -rf build

  Then build another build Folder , Wait for new block After the code is written, compile and install it with the original ~

4、 of bug The solution of the

Process related bug And solutions can refer to :

GNURadio 3.9 Use OOT Custom module problem record _Flag_ing The blog of -CSDN Blog Recently due to GR3.8 If there is a problem with the convolutional coding module in GR3.9 , Find out GR3.9 It can be used normally. , About GR3.8 Why the convolutional coding module in can't be used, let's not delve into it first , Before written GR3.8 To write OOT The process of ,GR3.9 To write OOT Follow 3.8 Not much difference , But some modifications need attention . Catalog 1、 The issue of relying on versions 2、 Every time you modify the public header file, you need to re bind binding 3、 Everything has passed the compilation , There is a problem when using 1、 The issue of relying on versions GR3.9 And GR3.8 A very important difference is python And C++ Side of interface ...https://blog.csdn.net/Flag_ing/article/details/121008197

原网站

版权声明
本文为[You roll, I don't roll]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130542480536.html