gnuradio 创建cos_source
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的更多相关文章
- gnuradio 创建动态库 libftd3xx.so
首先还是创建好模块gr-kcd cd gr-kcd 打开CMakeLists.txt cmake_minimum_required(VERSION 2.6) project(gr-kcd CXX C) ...
- GNURadio For Windows编译安装脚本v1.1.1发布
GNURadio也能在Windows上运行了,安装GNURadio时,会自动化下载一系列powershell脚本,在源里进行build.然后它依赖为64位原生二进制文件,使用Visual Studio ...
- 常用的gnuradio 模块
---恢复内容开始--- 参考:http://gnuradio.org/redmine/projects/gnuradio/wiki/TutorialsWritePythonApplications ...
- gnuradio 使用eclipse 编辑器记录
第1步 - 首先安装eclipse 先去官网下载,然后解压 --->下载版本是C++/C 版---->解压--->打开--->help->eclipse marketp ...
- gnuradio 初次使用
参考链接: 入门 http://www.cnblogs.com/moon1992/p/5739027.html 创建模块 http://www.cnblogs.com/moon1992/p/54246 ...
- 360独角兽实习,连载周记(gnuradio 低功耗蓝牙BLE 综合工具模块编写)
(有点乱,之后会有整理) 最近在用写一套gnuradio的OOT模块,主要用来进行BLE嗅探的,github上有了一些工具,可是他们并没有很好的模块化,于是打算自己写一个,这样以后做一些其他的项目,模 ...
- In-Memory:在内存中创建临时表和表变量
在Disk-Base数据库中,由于临时表和表变量的数据存储在tempdb中,如果系统频繁地创建和更新临时表和表变量,大量的IO操作集中在tempdb中,tempdb很可能成为系统性能的瓶颈.在SQL ...
- 创建 OVS flat network - 每天5分钟玩转 OpenStack(134)
上一节完成了 flat 的配置工作,今天创建 OVS flat network.Admin -> Networks,点击 "Create Network" 按钮. 显示创建页 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第二章:利用模型类创建视图、控制器和数据库
在这一章中,我们将直接进入项目,并且为产品和分类添加一些基本的模型类.我们将在Entity Framework的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
随机推荐
- Coursera, Big Data 1, Introduction (week 1/2)
Status: week 2 done. Week 1, 主要讲了大数据的的来源 - 机器产生的数据,人产生的数据(比如社交软件上的update, 一般是unstructed data), 组织产生的 ...
- Linux和进程内存模型
一.Linux和进程内存模型 jvm是一个进程的身份运行在linux系统上,了解linux和进程的内存关系,是理解jvm和Linux内存关系的基础. 硬件.系统.进程三个层面的内存之间的概要关系 1. ...
- Django REST framework 第一章 Serialization
此章节将会介绍多种构成REST framework的重要模块,在每个部分如何一起配合上提供一个综合的全方面的了解. 准备 同样的创建一个新项目,创建一个新的app,将rest_framework跟新建 ...
- 《前端福音,vue.js 之豆瓣电影组件大揭秘-video》
{{ message }} 小胡子语法 在 Vue 中被称之为双花括号插值表达式 ---------------- http://todomvc.com/ TodoMVC是一款开源的JavaScr ...
- Css - 精灵图
Css - 精灵图css sprite 一个页面文档上总是会有N多的图标小图片,它们都是以背景图的方式嵌入文档,每个小图片需要一个url的css属性,每个url都指向一个服务器地址的链接,每个链接都代 ...
- linux查看日志
若想在linux下查询某个时间段的log,用sed命令示例如下: $ sed -n '/2017-11-11 11:00:00/,/2017-11-11 11:11:11/p' error.log ...
- qtcreator 快捷键常用
F1 查看帮助F2 跳转到函数定义(和Ctrl+鼠标左键一样的效果)Shift+F2 声明和定义之间切换F4 头文件和源文件之间切换Ctrl+1 ...
- 数字图像处理的Matlab实现(4)—灰度变换与空间滤波
第3章 灰度变换与空间滤波(2) 3.3 直方图处理与函数绘图 基于从图像亮度直方图中提取的信息的亮度变换函数,在诸如增强.压缩.分割.描述等方面的图像处理中扮演着基础性的角色.本节的重点在于获取.绘 ...
- 用ARX自定义实体
本文介绍了构造自定义实体的步骤.必须继承的函数和必须注意的事项 1.新建一个从AcDbEntity继承的类,如EntTest,必须添加的头文件: "stdarx.h",&quo ...
- CodeForces 937D 936B Sleepy Game 有向图判环,拆点,DFS
题意: 一种游戏,2个人轮流控制棋子在一块有向图上移动,每次移动一条边,不能移动的人为输,无限循环则为平局,棋子初始位置为$S$ 现在有一个人可以同时控制两个玩家,问是否能使得第一个人必胜,并输出一个 ...