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. IT界的一些朗朗上口的名言

    序 中国有很多古代警世名言,朗朗上口,凝聚了很多故事与哲理.硅谷的互联网公司里头也有一些这样的名言,凝聚了很多公司价值观和做事的方法,对于很多程序员来说,其影响潜移默化.这里收集了一些,如下. Sta ...

  2. 🍓 JRoll、React滑动删除 🍓

    import React, { Component } from 'react'; import '../src/css/reset.css'; import '../src/css/delete.c ...

  3. 强网杯2018 Web签到

    Web签到 比赛链接:http://39.107.33.96:10000 比赛的时候大佬对这题如切菜一般,小白我只能空流泪,通过赛后看别人的wp,我知道了还有这种操作. 这个赛题分为3层 第一层 Th ...

  4. 列举两种不同类型的Java标识注释,并解释它们之间的区别。

    列举两种不同类型的Java标识注释,并解释它们之间的区别.

  5. java--GC Root有哪些

    GC管理的主要区域是Java堆,一般情况下只针对堆进行垃圾回收.方法区.JVM栈和Native栈不被GC所管理,因而选择这些非堆区的对象作为GC roots,被GC roots引用的对象不被GC回收. ...

  6. 代码编辑器 - Visual Studio Code

    vscode的视图 1.Explorer 资源管理器 打开的编辑器:打开的正在编辑的文件,单击文件会覆盖前一个打开的文件tab,双击可使打开的文件并列显示 vue-server:你自己新建的项目目录, ...

  7. 使用jQuery重置(reset)表单的方法

    由于JQuery中,提交表单是像下面这样的: 代码如下: $('#yigeform').submit() 所以,想当然的认为,重置表单,当然就是像下面这样子喽: 代码如下: $('#yigeform' ...

  8. Effective C++ 笔记

    无参构造函数如何暴躁的构造. 先来看看标准的raw_memory : *sizeof(int)); // create int raw memory int *intVars = static_cas ...

  9. Learning Discriminative Features with Class Encoder

    近来论文看了许多,但没多少时间总结下来.今天暂时记录一篇比较旧的论文,选择理由是 Discriminative features. 做图像说白了就是希望有足够有判别性的特征,这样在分类或者匹配.检索的 ...

  10. eMMC基础技术9:分区管理

    [转]http://www.wowotech.net/basic_tech/emmc_partitions.html 0.前言 eMMC 标准中,将内部的 Flash Memory 划分为 4 类区域 ...