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的代码优先模式下,利用这些模型类创建一个数据库.我们还将学习如何在代码中创建数据库上下文类 ...
随机推荐
- luogu P3721 [AH2017/HNOI2017]单旋
传送门 \(Spaly:\)??? 考虑在暴力模拟的基础上优化 如果要插入一个数,那么根据二叉查找树的性质,这个点一定插在他的前驱的右子树或者是后继的左子树,可以利用set维护当前树里面的数,方便查找 ...
- Sprng4之JDBC--很原始的使用方法
\[www.dev1234.com]一头扎进Spring4视频教程\一头扎进Spring4源码\[www.java1234.com]<一头扎进Spring4>第九讲 源码\Spring40 ...
- Linux iptables防火墙
查找安装包yum list | grep iptables 安装iptables yum install iptables-services 重启防火墙使配置文件生效 systemctl restar ...
- python 获取本机IP的三种方式
python获取本机IP的方式 第一种: #!/usr/bin/python import socket import fcntl import struct def get_ip_address(i ...
- JavaScript-DOM(重点)
解析过程 DOM树(一切皆是节点) DOM可以做什么 清楚DOM的结构 获取其它DOM(事件源)的三种方式 事件 事件的三要素 绑定事件的方式 JavaScript入口函数 window.onload ...
- python3-多装饰器的执行顺序
[例]: def dec1(func): print("HHHA:0====>") def one(): print("HHHA:0.1====>" ...
- Cent os 6.8添加中文字体
作者:邓聪聪 Cent os 6.8添加中文字体的相关步骤: [root@bogon ]#yum -y install fontconfig #yum安装fontconfig [root@bogon ...
- Excel 2013 表格自用技巧
参考 Excel表格的基本操作(精选36个技巧) Excel2013基本用法 关于VLOOKUP函数 目录 快速复制单元格 单元格内强制换行 锁定标题行 查找重复值 万元显示 单元格中显示001 按月 ...
- zabbix常用的python类api
zabbix自带api #!/usr/bin/python #coding:utf-8 import requests import json url = "http://192.168.9 ...
- Linux系统下安装pycharm
在 linux下打开浏览器,搜索pycharm,点击download. 下载好的文件的名称可能是 ‘pycharm-professional-2018.3.5.tar.gz’. 打开终端界面,输入命令 ...