提交 00ebd0a5 编写于 作者: M manjaro-xfce

添加基于stdio的调配解调、ADS-B接收模块

上级 3ea0525e
这里的项目是基于STDIO的项目,运行时要用 warpper_stdio进行包装,立刻接入平台。
\ No newline at end of file
#!/bin/bash
g++ -static -static-libstdc++ fmdem.cpp -o fmdem
#include <cstdio>
#include <cmath>
#ifdef WIN32
#include <io.h>
#include <fcntl.h>
#endif
#define Pi 3.14159265354
double angle(int x, int y)
{
double angle = 0;
if (x==0)
angle = (y>0)? Pi/2:-Pi/2;
else if (x >0 )
angle = atan(y*1.0/x);
else if (y >=0)
angle = atan(y*1.0/x)+Pi;
else
angle = atan(y*1.0/x)-Pi;
return angle;
}
int main()
{
#ifdef WIN32
setmode(fileno(stdout), O_BINARY);
setmode(fileno(stdin), O_BINARY);
#endif
short buf[128][2];
short out[128];
int nPts = 0;
int last_i = 0, last_q = 0;
while ((nPts = fread(buf,4,128,stdin)))
{
for (int j=0;j<nPts;++j)
{
//d(phase)/d(t) = freq
int curr_i = buf[j][0];
int curr_q = buf[j][1];
int diff_i = last_i * curr_i + last_q * curr_q;
int diff_q = last_q * curr_i - last_i * curr_q;
last_i = curr_i;
last_q = curr_q;
out[j] = angle(diff_i,diff_q)/Pi*4096;
}
fwrite(out,2,nPts,stdout);
fflush(stdout);
}
return 0;
}
#!/bin/bash
gcc -static recv_adsb.c -o recv_adsb -lm
此差异已折叠。
......@@ -165,24 +165,6 @@ bool DlgWrpStdio::cmd_stop()
{
if (m_process->state()!=QProcess::Running)
return false;
//发送信令,终止
char cmd[] = "function=quit;{ret = 0}";
subject_package_header header;
header.prefix[0] = 0x3C;
header.prefix[1] = 0x5A;
header.prefix[2] = 0x7E;
header.prefix[3] = 0x69;
header.data_length = static_cast<unsigned int>(strlen(cmd)+1);
header.path_id = 1;
header.subject_id = control_subect_id();
m_process->write((char *)&header,sizeof(subject_package_header));
m_process->write(cmd,strlen(cmd)+1);
int c = 0;
while (++c<100 && m_process->state()==QProcess::Running)
{
m_process->waitForFinished(20);
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
m_process->kill();
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册