编译、编写自己的信号处理模块珠海:叶少聪我们在编写USRP模块的时候,一般都是使用GNURADIO模板,把模板修改一个名字,然后在函数中编写自己的程序,这样就可以独立运行了,但是目前的GNURADIO模板是3.3.0版本,这个版本增加了CppUnit测试代码,目录结构也跟以往不太一样,刚开始的时候,修改还真有困难,今天做了一个小实验,记录了这次使用模板的全过程:解压3.3版本的代码到目录中,并将目录改成自己需要的名称linux-3a23:/home/shaocong_ye/project#gzip-cgr-howto-write-a-block-3.3.0.tar.gzlinux-3a23:/home/shaocong_ye/project#tar-vxfgr-howto-write-a-block-3.3.0.tarlinux-3a23:/home/shaocong_ye/project#mvgr-howto-write-a-block-3.3.0mathbaselinux-3a23:/home/shaocong_ye/project#cdmathbase然后删除多余的文件linux-3a23:/home/shaocong_ye/project/mathbase#rmlib/howto_square2_ff.hlinux-3a23:/home/shaocong_ye/project/mathbase#rmlib/howto_square2_ff.cclinux-3a23:/home/shaocong_ye/project/mathbase#rmswig/howto_square2_ff.i再把文件名改成自己需要的linux-3a23:/home/shaocong_ye/project/mathbase#mvlib/qa_howto.hlib/qa_mathbase.hlinux-3a23:/home/shaocong_ye/project/mathbase#mvlib/qa_howto_square_ff.hlib/qa_mathbase_sqrt_ff.hlinux-3a23:/home/shaocong_ye/project/mathbase#mvlib/qa_howto_square_ff.cclib/qa_mathbase_sqrt_ff.cclinux-3a23:/home/shaocong_ye/project/mathbase#mvlib/qa_howto.cclib/qa_mathbase.cclinux-3a23:/home/shaocong_ye/project/mathbase#mvlib/howto_square_ff.hlib/mathbase_sqrt_ff.hlinux-3a23:/home/shaocong_ye/project/mathbase#mvlib/howto_square_ff.cclib/mathbase_sqrt_ff.cclinux-3a23:/home/shaocong_ye/project/mathbase#mvgrc/howto_square_ff.xmlgrc/mathbase_sqrt_ff.xmllinux-3a23:/home/shaocong_ye/project/mathbase#mvapps/howto_square.grcapps/mathbase_sqrt.grclinux-3a23:/home/shaocong_ye/project/mathbase#mvapps/howto_square.pyapps/mathbase_sqrt.pylinux-3a23:/home/shaocong_ye/project/mathbase#mvswig/howto.iswig/mathbase.ilinux-3a23:/home/shaocong_ye/project/mathbase#mvswig/howto_square_ff.iswig/mathbase_sqrt_ff.ilinux-3a23:/home/shaocong_ye/project/mathbase#mvpython/qa_howto.pypython/qa_mathbase.py查找到有square2字符串的文件,删除这些行(因为这个与我们的目标代码无关,如果有关,就需要留下)find.-print|xargsgrepsquare2根据上面操作,查找到的文件,删除与square2有关的的行./grc/Makefile.am:howto_square2_ff.xml./grc/Makefile.in:howto_square2_ff.xml./lib/mathbase_sqrt_ff.h:*\sahowto_square2_ffforaversionthatsubclassesgr_sync_block../lib/Makefile.am:howto_square2_ff.h./lib/Makefile.am:howto_square2_ff.cc./lib/Makefile.am:qa_howto_square2_ff.cc./lib/Makefile.am:qa_howto_square2_ff.h./lib/qa_mathbase.cc:#includeqa_howto_square2_ff.h./lib/qa_mathbase.cc:s-addTest(qa_howto_square2_ff::suite());./lib/Makefile.in:qa_howto_square2_ff.lo./lib/Makefile.in:howto_square2_ff.lo./lib/Makefile.in:howto_square2_ff.h./lib/Makefile.in:howto_square2_ff.cc./lib/Makefile.in:qa_howto_square2_ff.cc./lib/Makefile.in:qa_howto_square2_ff.h./lib/Makefile.in:@AMDEP_TRUE@@am__include@@am__quote@./$(DEPDIR)/howto_square2_ff.Plo@am__quote@./lib/Makefile.in:@AMDEP_TRUE@@am__include@@am__quote@./$(DEPDIR)/qa_howto_square2_ff.Plo@am__quote@./swig/mathbase.i:#includehowto_square2_ff.h./swig/mathbase.i:%includehowto_square2_ff.i./swig/Makefile.am:howto_square2_ff.i./swig/Makefile.in:howto_square2_ff.i./swig/Makefile.in:@PYTHON_TRUE@howto_square2_ff.i./python/qa_mathbase.py:deftest_002_square2_ff(self):./python/qa_mathbase.py:sqr=howto_swig.square2_ff()替换所有文件中的square和howto字符串为自己需要的字符串,其中howto代表模块名称,square代表功能模块find.-print|xargsperl-pi-e's/square/sqrt/g'find.-print|xargsperl-pi-e's/howto/mathbase/g'最后编译就是了./bootstrap./configure--prefix=/usrmakemakecheck检测结果如下:linux-3a23:/home/shaocong_ye/project/mathbase#makecheckMakingcheckinconfigmake[1]:Enteringdirectory`/home/shaocong_ye/project/mathbase/config'make[1]:Nothingtobedonefor`check'.make[1]:Leavingdirectory`/home/shaocong_ye/project/mathbase/config'Makingcheckinlibmake[1]:Enteringdirectory`/home/shaocong_ye/project/mathbase/lib'makecheck-TESTSmake[2]:Enteringdirectory`/home/shaocong_ye/project/mathbase/lib'..OK(2tests)PASS:test_all=============1testpassed=============make[2]:Leavingdirectory`/home/shaocong_ye/project/mathbase/lib'make[1]:Leavingdirectory`/home/shaocong_ye/project/mathbase/lib'Makingcheckinswigmake[1]:Enteringdirectory`/home/shaocong_ye/project/mathbase/swig'makecheck-ammake[2]:Enteringdirectory`/home/shaocong_ye/project/mathbase/swig'make[2]:Nothingtobedonefor`check-am'.make[2]:Leavingdirectory`/home/shaocong_ye/project/mathbase/swig'make[1]:Leavingdirectory`/home/shaocong_ye/project/mathbase/swig'Makingcheckinpythonmake[1]:Enteringdirectory`/home/shaocong_ye/project/mathbase/python'makecheck-TESTSmake[2]:Enteringdirectory`/home/shaocong_ye/project/mathbase/python'/home/shaocong_ye/project/mathbase/lib:/home/shaocong_ye/project/mathbase/lib/.libs:/home/shaocong_ye/project/mathbase/swig:/home/shaocong_ye/project/mathbase/swig/.libs:/home/shaocong_ye/project/mathbase/python:/usr/lib/python2.6/site-packages:/usr/lib/python2.6/site-packages:.----------------------------------------------------------------------Ran1testin0.002sOKPASS:run_tests=============1testpassed=============make[2]:Leavingdirectory`/home/shaocong_ye/project/mathbase/python'make[1]:Leavingdirectory`/home/shaocong_ye/project/mathbase/python'Makingcheckingrcmake[1]:Enteringdirectory`/home/shaocong_ye/project/mathbase/grc'm