i made python block and want to add it to module in gnuradio, i open the directory of the module and use gr_motool add -t source filename.py. the tool created the .cc file and .h but as templates no processing done in the files. so can anyone advise me to add python block?
on 2013-03-13 12:01
on 2013-03-13 12:19
On Wed, Mar 13, 2013 at 5:57 AM, Mohammed Ramadan <eng_mo7med2005@yahoo.com>wrote: > i made python block and want to add it to module in gnuradio, i open the > directory of the module and use gr_motool add -t source filename.py. the > tool created the .cc file and .h but as templates no processing done in the > files. > so can anyone advise me to add python block? > > There's a great tutorial here: http://gnuradio.org/redmine/projects/gnuradio/wiki... The gr_modtool work flow is that gr_modtool generates a lot of the required boilerplate code used by GR and then you edit those files with your signal processing code. Notice there's section on python blocks in the tutorial (Tutorial #3). It sounds like you've already got your signal processing code done. I would suggest copying what you have in to the boiler plate code generated by gr_modtool. An alternative is importing what you already have and edit the work: function to call what you already have. Make sure you tell gr_modtool that you want to generate a python block with the -l switch. Going through that tutorial will be the single most useful thing in learning how to make a new block.
on 2013-03-13 12:31
Hi Mohammed, Nathan just beat me to it and as he said, this link explains more about gr_modtool: http://gnuradio.org/redmine/projects/gnuradio/wiki... gr_modtool makes the template for you to paste your code into. Here's my methodology on how I do it: 1) $ gr_modtool newmod (type in your project name) 2) $ cd gr-<project name> 3) $ gr_modtool add (you need to make a dummy c++ block before you can build the project and therefore to make a python template. pick 'sync' without any qa files. see: http://gnuradio.org/redmine/issues/522 for explanation) 4) $ gr_modtool add -l python (this is where you make the python template, if in doubt pick the 'sync' block) 5) $ mkdir build && cd build && cmake ../ && make (look at the errors and you will see that the '<+' and '+>' need to be removed from the files in order for it to compile. When make works, 'sudo make install' will put your new project into action. don't forget to reload GRC or hit the blue refresh button at the top. the GRC templates need to be edited too in order for them to turn into GRC icons) Once you can compile the templates successfully, modify the files that gr_modtool created by pasting in your code. Good luck :) Mike -- Mike Jameson M0MIK BSc Radio Communications Technology Specialist Email: mike@scanoo.com Web: http://www.scanoo.com
on 2013-03-14 08:29
The best way to mke a new block is by following tutorial here: http://gnuradio.org/redmine/projects/gnuradio/wiki.... you can easily make duumy block from this tutorial. i also made square dummy block from this tutorial.by making your block available in gnuardio you have to create the xml files whose procedure is also given in this tutorial. --- On Wed, 3/13/13, Mohammed Ramadan <eng_mo7med2005@yahoo.com> wrote: From: Mohammed Ramadan <eng_mo7med2005@yahoo.com> Subject: [Discuss-gnuradio] adding python block to gnuradio To: discuss-gnuradio@gnu.org Date: Wednesday, March 13, 2013, 10:57 AM i made python block and want to add it to module in gnuradio, i open the directory of the module and use gr_motool add -t source filename.py. the tool created the .cc file and .h but as templates no processing done in the files. so can anyone advise me to add python block? -----Inline Attachment Follows-----
on 2013-03-14 08:59
1. step:
bynkln@ubuntu:~$ gr_modtool.py create qpsk
Module directory is "./gr-qpsk".
Creating directory...
Copying howto example...
Unpacking...
Replacing occurences of 'howto' to 'qpsk'... Done.
Use 'gr_modtool add' to add a new block to this currently empty module.
bynkln@ubuntu:~$ gr_modtool.py add
No GNU Radio module found in the given directory. Quitting.
2. step:
bynkln@ubuntu:~$ cd gr-qpsk
3. step:
bynkln@ubuntu:~/gr-qpsk$ gr_modtool.py add
Operating in directory .
GNU Radio module name identified: qpsk
Enter code type: sync
Language: C++
Enter name of block/code (without module name prefix): QPSK
Block/code identifier: QPSK
Enter valid argument list, including default arguments: int val1, double
val2=0
Add Python QA code? [Y/n] n
Add C++ QA code? [Y/n] y
Traversing lib...
Adding file 'QPSK_impl.h'...
Adding file 'QPSK_impl.cc'...
Adding file 'QPSK.h'...
Adding file 'qa_QPSK.cc'...
Adding file 'qa_QPSK.h'...
Traversing swig...
Editing swig/qpsk_swig.i...
Traversing grc...
Adding file 'qpsk_QPSK.xml'...
Editing grc/CMakeLists.txt...
4. step:
bynkln@ubuntu:~/gr-qpsk$ gr_modtool.py add -l python
Operating in directory .
GNU Radio module name identified: qpsk
Enter code type: sync
Language: Python
Enter name of block/code (without module name prefix): QPSK
Block/code identifier: QPSK
Enter valid argument list, including default arguments: int val1, double
val2=0
Add Python QA code? [Y/n] y
Traversing python...
Adding file 'QPSK.py'...
Adding Python QA...
Adding file 'qa_QPSK.py'...
Editing python/CMakeLists.txt...
Traversing grc...
Adding file 'qpsk_QPSK.xml'...
Editing grc/CMakeLists.txt...
before 5th step i had removed <+ your compan.. +> then
5. step:
bynkln@ubuntu:~/gr-qpsk$ mkdir build && cd build && cmake ../ && make
-- The CXX compiler identification is GNU 4.7.2
-- The C compiler identification is GNU 4.7.2
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Build type not specified: defaulting to release.
-- Boost version: 1.49.0
-- Found the following Boost libraries:
-- filesystem
-- system
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")
-- checking for module 'gruel'
-- found gruel, version 3.6.4
-- Found GRUEL: /usr/local/lib/libgruel.so
-- checking for module 'gnuradio-core'
-- found gnuradio-core, version 3.6.4
-- Found GNURADIO_CORE: /usr/local/lib/libgnuradio-core.so
-- checking for module 'cppunit'
-- found cppunit, version 1.12.1
-- Found CPPUNIT: /usr/lib/libcppunit.so;dl
-- Found SWIG: /usr/bin/swig2.0 (found version "2.0.7")
-- Found PythonLibs: /usr/lib/python3.2/config/libpython3.2.so (found
version "2.7.3")
-- Found PythonInterp: /usr/bin/python (found version "2.7.3")
-- Found Doxygen: /usr/bin/doxygen (found version "1.8.1.2")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bynkln/gr-qpsk/build
Scanning dependencies of target gnuradio-qpsk
[ 5%] Building CXX object
lib/CMakeFiles/gnuradio-qpsk.dir/QPSK_impl.cc.o
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc: In constructor
gr::qpsk::QPSK_impl::QPSK_impl(int, double):
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:30: error: expected
primary-expression before < token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:32: error: MIN_IN was not
declared in this scope
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:39: error: expected
primary-expression before > token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:40: error: expected
primary-expression before , token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:42: error: expected
primary-expression before < token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:44: error: MAX_IN was not
declared in this scope
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:51: error: expected
primary-expression before > token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:52: error: expected
primary-expression before , token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:62: error: expected
primary-expression before < token
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:64: error: expected
primary-expression before float
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:64: error: expected ) before
float
/home/bynkln/gr-qpsk/lib/QPSK_impl.cc:67:3: error: expected { before }
token
make[2]: *** [lib/CMakeFiles/gnuradio-qpsk.dir/QPSK_impl.cc.o] Error 1
make[1]: *** [lib/CMakeFiles/gnuradio-qpsk.dir/all] Error 2
make: *** [all] Error 2
bynkln@ubuntu:~/gr-qpsk/build$
*then gived to me error like this, again... what shoul i do, thank you.*
2013/3/13 Mike Jameson <mike@scanoo.com>
on 2013-03-14 09:14
On Thu, Mar 14, 2013 at 2:58 AM, Serhat BOYNUKALIN <serhatboynukalin@gmail.com> wrote: > bynkln@ubuntu:~$ gr_modtool.py add > No GNU Radio module found in the given directory. Quitting. As the error message indicates this last command didn't do anything. > Enter code type: sync > Adding file 'qa_QPSK.cc'... > bynkln@ubuntu:~/gr-qpsk$ gr_modtool.py add -l python > Adding Python QA... > Adding file 'qa_QPSK.py'... > Editing python/CMakeLists.txt... > Traversing grc... > Adding file 'qpsk_QPSK.xml'... > Editing grc/CMakeLists.txt... > > before 5th step i had removed <+ your compan.. +> then From http://gnuradio.org/redmine/projects/gnuradio/wiki... The C++ code (part 1) "gr_modtool hints at where you have to change code by adding <++> symbols." > -- Check for working C compiler: /usr/bin/gcc > -- found gruel, version 3.6.4 > -- Found Doxygen: /usr/bin/doxygen (found version "1.8.1.2") > /home/bynkln/gr-qpsk/lib/QPSK_impl.cc:42:42: error: expected primary-expression before < token > bynkln@ubuntu:~/gr-qpsk/build$ > > > then gived to me error like this, again... what shoul i do, thank you. Look at those line numbers that give errors. You need to replace the "<++ hint ++>" with actual C++ code. As a side note, unless you're doing something fancy there's already a QPSK modulator/demodulator that comes with GR as a python hier_block. It's in gr-digital/python/psk.py . -Nathan
on 2013-03-14 10:11
How should i add or replace c++ code and python code could you explain it with an example, and i knew there is psk.py code but need to show it at the GRC as a block.
on 2013-03-15 03:28
You simply open that file in text editor and change the lines that cause trouble.
on 2013-03-15 03:31
it is possible to add qpsk as a block to grc just using python code? 2013/3/14 Nemanja Savic <vlasinac@gmail.com>
on 2013-03-15 03:34
On Thu, Mar 14, 2013 at 4:27 AM, Serhat BOYNUKALIN <serhatboynukalin@gmail.com> wrote: > it is possible to add qpsk as a block to grc just using python code? > It's already there. Search for PSK Modulator. M is the variable to change the modulation order. 4 will give you PSK. > > 2013/3/14 Nemanja Savic <vlasinac@gmail.com> >> >> How should i add or replace c++ code and python code could you explain it with an >> example I can't stress this enough. If you want to learn how to create a new block you should go through the tutorial. http://gnuradio.org/redmine/projects/gnuradio/wiki... The tutorial shows you what the changed code should look like for a very simple block. It's a very good tutorial and it won't take you more than an hour, which is probably more time than you've spent trying to fix problems that you wouldn't have if you go through the tutorial.
on 2013-03-15 03:40
In the terminal transcript you provided, you created an block without a name, and after that you created a python block. One of the errors comes from the first block. I am not sure where you have found this sequence of actions, but the only thing you should to to create a new signal processing block is to firsr, define a module, which you have done, second, add a new signal processign block (in python or C++), EDIT the files created by gr_modtool in order to implement the behaviour of your block, third: do make and make test to see whether your block really does what you wanted, make xml file for GRC and finaly do make install, and you will be able to use it. On Thu, Mar 14, 2013 at 10:27 AM, Serhat BOYNUKALIN <
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.