- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在实现线路编码 block ,因为 GnuRadio 中的选择有限。我已经使用有限状态机 (FSM) 完成了 NRZ (L\M\S) 的实现和测试,它们似乎工作正常。现在,我正在尝试以 L 作为基线开始实现曼彻斯特 (L\M\S)。波形见下图摘自NASA深空网络遥测数据解码(208)
有限状态机的构造如下所示。我决定使用 FSM,因为在我看来,它是实现线路代码的一种非常标准化的方式。
下面是用于测试实现的 gnuradio 流程图。测试是通过将 BPSK 信号(使用 CCSDS Reed-Solomon + 扰码器)发送到能够接收信号和处理遥测数据的外部设备来进行的。此实现已通过 NRZ-L\M\S 成功测试。 CCSDS 帧从文件中读取、解压缩并发送到 OOT block debug_linecode_bp 以进行曼彻斯特编码(曼彻斯特-L 的代码 0)。曼彻斯特编码之后是 OOT block debug_pulseshape_pam_2 block ,它将滤波器抽头和每个符号的样本数作为参数。接下来是一个 OOT block debug_bpsk_modulator,它执行简单的 BPSK 映射(Inphase = in[i],quadrature = 0)。 头文件的代码如下所示
#ifndef INCLUDED_BASEBAND_DEBUG_LINECODE_BP_IMPL_H
#define INCLUDED_BASEBAND_DEBUG_LINECODE_BP_IMPL_H
#include <baseband/debug_linecode_bp.h>
namespace gr {
namespace baseband {
class debug_linecode_bp_impl : public debug_linecode_bp
{
private:
char last_state;
int d_code;
void fsm_decode_state(char state, unsigned char &bit0, unsigned char &bit1);
void fsm_encode_state(int code, unsigned char input, char last_state, char &next_state);
public:
debug_linecode_bp_impl(int code);
~debug_linecode_bp_impl();
// 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 baseband
} // namespace gr
#endif /* INCLUDED_BASEBAND_DEBUG_LINECODE_BP_IMPL_H */
这是实现文件
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "debug_linecode_bp_impl.h"
#include <iostream>
using namespace std;
namespace gr {
namespace baseband {
debug_linecode_bp::sptr
debug_linecode_bp::make(int code)
{
return gnuradio::get_initial_sptr
(new debug_linecode_bp_impl(code));
}
/*
* The private constructor
*/
debug_linecode_bp_impl::debug_linecode_bp_impl(int code)
: gr::sync_interpolator("debug_linecode_bp",
gr::io_signature::make(1, 1, sizeof(unsigned char)),
gr::io_signature::make(1, 1, sizeof(unsigned char)), 2),
d_code(code),last_state('a')
{}
/*
* Our virtual destructor.
*/
debug_linecode_bp_impl::~debug_linecode_bp_impl()
{
}
void
debug_linecode_bp_impl::fsm_decode_state(char state, unsigned char &bit0, unsigned char &bit1)
{
switch(state)
{
case 'a':
bit0 = 0x00;
bit1 = 0x00;
break;
case 'b':
bit0 = 0x00;
bit1 = 0x01;
break;
case 'c':
bit0 = 0x01;
bit1 = 0x01;
break;
case 'd':
bit0 = 0x01;
bit1 = 0x00;
break;
}
}
void
debug_linecode_bp_impl::fsm_encode_state(int code, unsigned char input, char last_state, char &next_state)
{
switch(code)
{
case 0://Biphae-L
switch(last_state)
{
case 'a': //Illegal state
next_state = 'b';
cout << "Illegal state [a] encountered" << endl;
break;
case 'b':
next_state = (input & 0x01) ? 'd' : 'b';
break;
case 'c': //Illegal state
next_state = 'b';
cout << "Illegal state [b] encountered" << endl;
break;
case 'd':
next_state = (input & 0x01) ? 'd' : 'b';
break;
}
break;
case 1://Biphase-S
switch(last_state)
{
case 'a':
next_state = (input & 0x01) ? 'c' : 'd';
break;
case 'b':
next_state = (input & 0x01) ? 'a' : 'b';
break;
case 'c':
next_state = (input & 0x01) ? 'a' : 'b';
break;
case 'd':
next_state = (input & 0x01) ? 'c' : 'd';
break;
}
break;
case 2://Biphase-M
switch(last_state)
{
case 'a':
next_state = (input & 0x01) ? 'd' : 'c';
break;
case 'b':
next_state = (input & 0x01) ? 'b' : 'a';
break;
case 'c':
next_state = (input & 0x01) ? 'b' : 'a';
break;
case 'd':
next_state = (input & 0x01) ? 'd' : 'c';
break;
}
break;
}
}
int
debug_linecode_bp_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
char next_state;
unsigned char bit0;
unsigned char bit1;
for (int i = 0; i < noutput_items/2; i++) {
fsm_encode_state(d_code,in[i],last_state, next_state);
fsm_decode_state(next_state, bit0, bit1);
for (int j = 0; j < 2; j++) {
out[i + j] = bit0;
out[i + j + 1] = bit1;
}
last_state = next_state;
}
// Tell runtime system how many output items we produced.
return noutput_items;
}
} /* namespace baseband */
} /* namespace gr */
到目前为止,测试还没有成功。我用来从这个流程图接收信号的设备甚至无法挑选一个数据包。我的结论是错误来自曼彻斯特编码器。非常欢迎对上述代码的任何想法。
谢谢。
最佳答案
一段时间后,我找到了代码中的错误。实际上,问题出在我复制输出的方式上。我所要做的就是删除内部 for 循环并使用 memcpy 直接复制输出。这就是功函数现在的样子
int
debug_linecode_bp_impl::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const unsigned char *in = (const unsigned char *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
char next_state;
unsigned char bit0;
unsigned char bit1;
vector<unsigned char> bits;
for (int i = 0; i < noutput_items/2; i++) {
fsm_encode_state(d_code,in[i],last_state, next_state);
fsm_decode_state(next_state, bit0, bit1);
bits.push_back(bit0);
bits.push_back(bit1);
memcpy(out,bits.data(),2);
bits.clear();
out+=2;
last_state = next_state;
}
// Tell runtime system how many output items we produced.
return noutput_items;
}
关于c++ - 在 GNU Radio 中使用有限状态机实现 Manchester-L (Biphase-L),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49030085/
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我刚刚开始使用 Arduino,对更多高级内容几乎一无所知。这看起来很简单。现在我是一个通常喜欢将两个设备集成在一起的人,所以我想知道我是否可以使用计算机的键盘或连接到 Arduino 板上的两个硬件
Hadoop上是否有支持 vector 机的实现? 我正在寻找使我能够训练然后在Hadoop之上测试SVM模型的代码。 最佳答案 有人正在使用BSP在Apache Hama之上进行实现,该实现基本上是
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我想用 Java 编写一个“智能监视器”,它会在它检测到即将出现的性能问题时发出警报。我的 Java 应用正在将结构化格式的数据写入日志文件: | | 因此,例如,如果我有一个执行时间为 812
我在 Cappuccino 中遇到这种错误 TypeError: Result of expression '_2b' [undefined] is not an object. TypeError:
我想编写一个简单的 bean 机程序。该程序将接受用户输入的球数和槽数,并计算每个球的路径。每个槽中的球数也将打印为直方图。 我尽力让代码保持简短和简洁,但我能做到的最好的长度是 112 行。当我运行
我正在开发一个 Plone 模板。目前我正在对模板实现搜索。模板上有一个表单提交到同一模板,即同一页面。 我需要启用页面的某些部分,即结果 DIV,仅当页面中的表单已提交时。我不确定如何检查页面是否已
我是机器学习的新手。我正在使用 opencv 开源库做一个项目。我的问题是我没有机器学习方面的经验。我从不同的图像中提取了特征并对其进行了评估,现在我想使用 SVM 对这些图像中的对象进行分类,但我不
我有一个来自自定义抽象对象的数据集和一个自定义距离函数。是否有任何好的 SVM 库允许我训练我的自定义对象(不是 2d 点)和我的自定义距离函数? 我在 this similar stackoverf
我正在尝试编写 SVM 或 KNN 程序来对文本文档进行分类。我掌握了两者的概念,但我希望看到一些很好的代码示例,它们专门演示了如何将文本/单词表示为 vector 。有人知道好的教程/文章/讲座/任
我想知道支持 vector 机 (SVM) 对于大型/超大型数据集(5-15M+ 行)具有非线性决策边界(例如高斯核)? 我知道两种特殊的方法:一方面,这个使用随机梯度下降等的调查: http://c
我试图在 Raspberry Pi 中使用 python 控制连续伺服(DF15RSMG),但连续伺服无法停止。代码如下: import RPi.GPIO as GPIO import time
我们在 .net 中有银行项目。在那个项目中我们需要实现存折打印。 - 存折背面会有磁条。 - 当客户将存折插入自助服务终端时,自助服务终端将生成 ISO 8583 信息。 - 为响应此消息,CBS(
我想使用 svm 分类器进行面部表情检测。我知道 opencv 有一个 svm api,但我不知道训练分类器的输入应该是什么。到现在看了很多论文,都是说人脸特征检测后训练分类器。 到目前为止我做了什么
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
为了学习 ArchLinux,我在 VirtualBox 机器上安装并使用了 ArchLinux。它运行完美。现在我在我的电脑上安装了 Docker(Windows 环境)。在安装 Docker 的过
我找不到很多相关信息,但是我知道可以通过命令提示符electron-packager .创建一个 Electron 应用。但是,可以通过 Node 快速路由在前端执行它吗? 所以我想做这样的事情: r
我正在使用 MS Visual Studio 2008、OpenCV、C++ 和 SVM 继续我的 OCR 项目。我生成了一个超过 2000 个机印字符样本的数据集。当我用线性核测试时,我总是得到 9
我通过UART接口(interface)(RX-TX,GND-GND)将伺服(TowerPro sg90)连接到32伺服 Controller (this one)。 卖家提供了如何连接和控制我的伺服
我是一名优秀的程序员,十分优秀!