C++教程

ys_linux@computer:~$ gr_modtool nm kcd
Creating out-of-tree module in ./gr-kcd... Done.
Use 'gr_modtool add' to add a new block to this currently empty module.
ys_linux@computer:~$ cd gr-kcd/
ys_linux@computer:~/gr-kcd$ ls
apps CMakeLists.txt examples include MANIFEST.md swig
cmake docs grc lib python
ys_linux@computer:~/gr-kcd$ gr_modtool add my_qpsk_demod_cb
GNU Radio module name identified: tutorial
('sink', 'source', 'sync', 'decimator', 'interpolator', 'general', 'tagged_stream', 'hier', 'noblock')
Enter block type: general
Language (python/cpp): C++
Language (python/cpp): cpp
Language: C++
Block/code identifier: my_qpsk_demod_cb
Enter valid argument list, including default arguments: int freq ,float amp
Add Python QA code? [Y/n]
Add C++ QA code? [y/N] Y
Adding file 'lib/my_qpsk_demod_cb_impl.h'...
Adding file 'lib/my_qpsk_demod_cb_impl.cc'...
Adding file 'include/tutorial/my_qpsk_demod_cb.h'...
Adding file 'lib/qa_my_qpsk_demod_cb.cc'...
Adding file 'lib/qa_my_qpsk_demod_cb.h'...
Editing swig/tutorial_swig.i...
Adding file 'python/qa_my_qpsk_demod_cb.py'...
Editing python/CMakeLists.txt...
Adding file 'grc/tutorial_my_qpsk_demod_cb.xml'...
Editing grc/CMakeLists.txt...

然后编辑代码

/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/ #ifdef HAVE_CONFIG_H
#include "config.h"
#endif #include <gnuradio/io_signature.h>
#include "cos_source_impl.h"
#include "pmt/pmt.h"
using namespace std; namespace gr {
namespace kcd { cos_source::sptr
cos_source::make(int freq ,float amp)
{ std::cout << "my_cout"<<endl; pmt::pmt_t P = pmt::from_long();
std::cout << P << std::endl;
pmt::pmt_t P2 = pmt::from_complex(gr_complex(, )); // Alternatively: pmt::from_complex(0, 1)
std::cout << P2 << std::endl;
std::cout << pmt::is_complex(P2) << std::endl; return gnuradio::get_initial_sptr
(new cos_source_impl(freq, amp));
} /*
* The private constructor
*/
cos_source_impl::cos_source_impl(int freq ,float amp)
: gr::sync_block("cos_source",
gr::io_signature::make(, , ),
gr::io_signature::make(, , sizeof(float)))
{} /*
* Our virtual destructor.
*/
cos_source_impl::~cos_source_impl()
{
} int
cos_source_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
// const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0];
float *out = (float *) output_items[]; for (int i = ;i<noutput_items;i++ )
{
// out[i] = kcd_source_sincos(i);
if (num < ) {
num++;
}
else {
num=;
}
out[i]=cos(3.1415926535898**num/);
// out[i]=noutput_items;
}
// Do <+signal processing+> // Tell runtime system how many output items we produced.
return noutput_items;
} } /* namespace kcd */
} /* namespace gr */

头文件

/* -*- c++ -*- */
/*
* Copyright 2017 <+YOU OR YOUR COMPANY+>.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/ #ifndef INCLUDED_KCD_COS_SOURCE_IMPL_H
#define INCLUDED_KCD_COS_SOURCE_IMPL_H #include <kcd/cos_source.h> namespace gr {
namespace kcd { class cos_source_impl : public cos_source
{
private:
// Nothing to declare in this block. public:
cos_source_impl(int freq ,float amp);
~cos_source_impl();
int num=;
int number=;
// Where all the action really happens
int work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
}; } // namespace kcd
} // namespace gr #endif /* INCLUDED_KCD_COS_SOURCE_IMPL_H */

修改xml

<?xml version="1.0"?>
<block>
<name>cos_source</name>
<key>kcd_cos_source</key>
<category>[kcd]</category>
<import>import kcd</import>
<make>kcd.cos_source($freq, $amp)</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>freq</name>
<key>freq</key>
<type>int</type>
</param> <param>
<name>amp</name>
<key>amp</key>
<type>float</type>
</param> <!-- 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> e.g. int, float, complex, byte, short, xxx_vector, ...</type>
</sink> --> <!-- Make one 'source' node per output. Sub-nodes:
* name (an identifier for the GUI)
* type
* vlen
* optional (set to 1 for optional inputs) -->
<source>
<name>out</name>
<type>float<!-- e.g. int, float, complex, byte, short, xxx_vector, ...--></type>
</source>
</block>
然后打包

ys_linux@computer:~/gr-tutorial$ cmake ../
$make $sudo make intall $sudo ldconfig 然后启动gnuradio

gnuradio 创建cos_source的更多相关文章

  1. gnuradio 创建动态库 libftd3xx.so

    首先还是创建好模块gr-kcd cd gr-kcd 打开CMakeLists.txt cmake_minimum_required(VERSION 2.6) project(gr-kcd CXX C) ...

  2. GNURadio For Windows编译安装脚本v1.1.1发布

    GNURadio也能在Windows上运行了,安装GNURadio时,会自动化下载一系列powershell脚本,在源里进行build.然后它依赖为64位原生二进制文件,使用Visual Studio ...

  3. 常用的gnuradio 模块

    ---恢复内容开始--- 参考:http://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsWritePythonApplications ...

  4. gnuradio 使用eclipse 编辑器记录

    第1步 - 首先安装eclipse 先去官网下载,然后解压  --->下载版本是C++/C 版---->解压--->打开--->help->eclipse marketp ...

  5. gnuradio 初次使用

    参考链接: 入门 http://www.cnblogs.com/moon1992/p/5739027.html 创建模块 http://www.cnblogs.com/moon1992/p/54246 ...

  6. 360独角兽实习,连载周记(gnuradio 低功耗蓝牙BLE 综合工具模块编写)

    (有点乱,之后会有整理) 最近在用写一套gnuradio的OOT模块,主要用来进行BLE嗅探的,github上有了一些工具,可是他们并没有很好的模块化,于是打算自己写一个,这样以后做一些其他的项目,模 ...

  7. In-Memory:在内存中创建临时表和表变量

    在Disk-Base数据库中,由于临时表和表变量的数据存储在tempdb中,如果系统频繁地创建和更新临时表和表变量,大量的IO操作集中在tempdb中,tempdb很可能成为系统性能的瓶颈.在SQL ...

  8. 创建 OVS flat network - 每天5分钟玩转 OpenStack(134)

    上一节完成了 flat 的配置工作,今天创建 OVS flat network.Admin -> Networks,点击 "Create Network" 按钮. 显示创建页 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库

    在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...

随机推荐

  1. 谈谈jQuery中的数据类型检测

    这次是分享jQuery代码中的一些简写技巧,分析jQuery是如何优化代码的,如何用最少的代码来实现jQuery. 在我们工作中也常常会遇到一些数据类型检测,一些方法调用的形式 1 var arr = ...

  2. NPOI2.2.0.0实例详解(九)—设置EXCEL单元格【时间格式】

    原文:http://blog.csdn.net/xxs77ch/article/details/50245391 using System; using System.Collections.Gene ...

  3. 库zlog的使用手册

    库官方网址: 使用手册:    http://hardysimpson.github.io/zlog/UsersGuide-CN.html#htoc11 [formats] simple = &quo ...

  4. Django REST Framework API Guide 04

    本节大纲 1.serializers 1.Serializers Serializers允许复杂的数据,像queryset和模型实例转换成源生的Python数据类型.从而可以更简单的被渲染成JSON, ...

  5. Coconuts HDU - 5925 (二维离散化求连通块的个数以及大小)

    题目链接: D - Coconuts  HDU - 5925 题目大意:首先是T组测试样例,然后给你n*m的矩阵,原先矩阵里面都是白色的点,然后再输入k个黑色的点.这k个黑色的点可能会使得原先白色的点 ...

  6. Maven SSH三大框架整合的加载流程

    <Maven精品教程视频\day02视频\03ssh配置文件加载过程.avi;> 此课程中讲 SSH三大框架整合的加载流程,还可以,初步接触的朋友可以听一听. < \day02视频\ ...

  7. js对象遍历输出顺序错乱的问题

    一.js对象遍历顺序错乱的原因 下边就来实践一下: var obj={'3':'ccc',name:'abc',age:23,school:'sdfds',class:'dfd',hobby:'dsf ...

  8. [TensorFlow笔记乱锅炖] tf.multinomial(logits, num_samples)使用方法

    tf.multinomial(logits, num_samples) 第一个参数logits可以是一个数组,每个元素的值可以简单地理解为对应index的选择概率,注意这里的概率没有规定加起来的和为1 ...

  9. ROS tf 两个常用的函数

    /** \brief Get the transform between two frames by frame ID.   * \param target_frame The frame to wh ...

  10. SpringSecurityOAuth认证配置及Token的存储

    ⒈pom依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...