在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例C/C++网络编程 → ACARS解码程序

ACARS解码程序

C/C++网络编程

下载此实例
  • 开发语言:C/C++
  • 实例大小:1.35M
  • 下载次数:10
  • 浏览次数:282
  • 发布时间:2020-08-08
  • 实例类别:C/C++网络编程
  • 发 布 人:KingKongOne
  • 文件格式:.zip
  • 所需积分:2
 相关标签: acars decoder

实例介绍

【实例简介】acars数据解码程序

【实例目录】

acarsdec

├── CMakeLists.txt
├── README.md
├── acars.c
├── acars.txt
├── acarsdec.c
├── acarsdec.h
├── air.c
├── alsa.c
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   │   ├── 3.16.1
│   │   │   ├── CMakeCCompiler.cmake
│   │   │   ├── CMakeDetermineCompilerABI_C.bin
│   │   │   ├── CMakeSystem.cmake
│   │   │   └── CompilerIdC
│   │   │       ├── CMakeCCompilerId.c
│   │   │       ├── a.out
│   │   │       └── tmp
│   │   ├── CMakeDirectoryInformation.cmake
│   │   ├── CMakeOutput.log
│   │   ├── CMakeTmp
│   │   ├── Makefile.cmake
│   │   ├── Makefile2
│   │   ├── TargetDirectories.txt
│   │   ├── acarsdec.dir
│   │   │   ├── C.includecache
│   │   │   ├── DependInfo.cmake
│   │   │   ├── acars.c.o
│   │   │   ├── acarsdec.c.o
│   │   │   ├── build.make
│   │   │   ├── cJSON.c.o
│   │   │   ├── cmake_clean.cmake
│   │   │   ├── depend.internal
│   │   │   ├── depend.make
│   │   │   ├── flags.make
│   │   │   ├── label.c.o
│   │   │   ├── link.txt
│   │   │   ├── msk.c.o
│   │   │   ├── output.c.o
│   │   │   ├── progress.make
│   │   │   └── rtl.c.o
│   │   ├── cmake.check_cache
│   │   └── progress.marks
│   ├── Makefile
│   ├── acarsdec
│   ├── cmake_install.cmake
│   ├── run.sh
│   └── scan.sh
├── cJSON.c
├── cJSON.h
├── label.c
├── msk.c
├── output.c
├── rtl.c
├── sdrplay.c
├── soundfile.c
├── syndrom.h
└── test.wav

7 directories, 52 files


【核心代码】


/*
* Copyright (c) 2015 Thierry Leconte
*
*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License version 2
* published by the Free Software Foundation.
*
* This program 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 Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <getopt.h>
#include <sched.h>
#include <unistd.h>
#include <limits.h>
#ifdef HAVE_LIBACARS
#include <libacars/version.h>
#endif
#include "acarsdec.h"
extern void build_label_filter(char *arg);

channel_t channel[MAXNBCHANNELS];
unsigned int nbch;

char *idstation = NULL;
int inmode = 0;
int verbose = 0;
int outtype = OUTTYPE_STD;
int netout = NETLOG_NONE;
int airflt = 0;
int mdly=600;
int hourly = 0;
int daily = 0;

#ifdef WITH_RTL
int gain = 1000;
int ppm = 0;
#endif
#ifdef WITH_AIR
int gain = 18;
#endif
#ifdef WITH_SDRPLAY
int lnaState = 2;
int GRdB = 20;
int ppm = 0;
#endif
char *Rawaddr = NULL;
char *logfilename = NULL;

static void usage(void)
{
fprintf(stderr,
"Acarsdec/acarsserv 3.5 Copyright (c) 2017 Thierry Leconte\n");
#ifdef HAVE_LIBACARS
fprintf(stderr, "(libacars %s)\n", LA_VERSION);
#endif
fprintf(stderr,
"\nUsage: acarsdec [-v] [-o lv] [-t time] [-A] [-n ipaddr:port] [-l logfile [-H|-D]]");
#ifdef WITH_ALSA
fprintf(stderr, " -a alsapcmdevice |");
#endif
#ifdef WITH_SNDFILE
fprintf(stderr, " -f inputwavfile |");
#endif
#ifdef WITH_RTL
fprintf(stderr,
" [-g gain] [-p ppm] -r rtldevicenumber f1 [f2] ... [fN]");
#endif
#ifdef WITH_AIR
fprintf(stderr,
"[-g linearity_gain] -s f1 [f2] ... [fN]");
#endif
#ifdef WITH_SDRPLAY
fprintf (stderr, " [-L lnaState] [-G GRdB] [-p ppm] -s f1 [f2] .. [fN]");
#endif
fprintf(stderr, "\n\n");
fprintf(stderr, " -v\t\t\t: verbose\n");
fprintf(stderr,
" -A\t\t\t: don't display uplink messages (ie : only aircraft messages)\n");
fprintf(stderr,
"\n -o lv\t\t\t: output format : 0 : no log, 1 : one line by msg, 2 : full (default) , 3 : monitor , 4 : msg JSON, 5 : route JSON\n");
fprintf(stderr,
"\n -t time\t\t: set forget time (TTL) in seconds for monitor mode (default=600s)\n");
fprintf(stderr,
" -l logfile\t\t: append log messages to logfile (Default : stdout).\n");
fprintf(stderr,
" -H\t\t\t: rotate log file once every hour\n");
fprintf(stderr,
" -D\t\t\t: rotate log file once every day\n");
fprintf(stderr,
" -n ipaddr:port\t\t: send acars messages to addr:port on UDP in planeplotter compatible format\n");
fprintf(stderr,
" -N ipaddr:port\t\t: send acars messages to addr:port on UDP in acarsdec native format\n");
fprintf(stderr,
" -j ipaddr:port\t\t: send acars messages to addr:port on UDP in acarsdec json format\n");
fprintf(stderr,
" -i stationid\t\t: station id used in acarsdec network format.\n");
fprintf(stderr,
" -b filter\t\t: filter output by label (ex: -b \"H1:Q0\" : only output messages with label H1 or Q0)\n\n");

#ifdef WITH_ALSA
fprintf(stderr,
" -a alsapcmdevice\t: decode from soundcard input alsapcmdevice (ie: hw:0,0)\n");
#endif
#ifdef WITH_SNDFILE
fprintf(stderr,
" -f inputwavfile\t: decode from a wav file at %d sampling rate\n",INTRATE);
#endif
#ifdef WITH_RTL
fprintf(stderr,
" -g gain\t\t: set rtl preamp gain in tenth of db (ie -g 90 for 9db). By default use AGC\n");
fprintf(stderr, " -p ppm\t\t\t: set rtl ppm frequency correction\n");
fprintf(stderr,
" -r rtldevice f1 [f2]...[f%d]\t: decode from rtl dongle number or S/N rtldevice receiving at VHF frequencies f1 and optionally f2 to f%d in Mhz (ie : -r 0 131.525 131.725 131.825 )\n", MAXNBCHANNELS, MAXNBCHANNELS);
#endif
#ifdef WITH_AIR
fprintf(stderr,
" -g linearity_gain\t: set linearity gain [0-21] default : 18\n");
fprintf(stderr,
" -s f1 [f2]...[f%d]\t: decode from airspy receiving at VHF frequencies f1 and optionally f2 to f%d in Mhz (ie : -s 131.525 131.725 131.825 )\n", MAXNBCHANNELS, MAXNBCHANNELS);
#endif
#ifdef WITH_SDRPLAY
fprintf (stderr,
"-L lnaState: set the lnaState (depends on the device)\n"\
"-G Gain reducction in dB's, range 20 .. 59 (-100 is autogain)\n"\
" -s f1 [f2]...[f%d]\t: decode from sdrplay receiving at VHF frequencies f1 and optionally f2 to f%d in Mhz (ie : -s 131.525 131.725 131.825 )\n", MAXNBCHANNELS, MAXNBCHANNELS);
#endif

fprintf(stderr,
"\nUp to %d channels may be simultaneously decoded\n", MAXNBCHANNELS);
exit(1);
}

static void sighandler(int signum)
{
fprintf(stderr, "receive signal %d exiting\n", signum);
exit(1);
}

#if __APPLE__

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX 255
#endif

#ifndef program_invocation_name
#define program_invocation_name "fastcgi"
#endif

#endif

int main(int argc, char **argv)
{
int c;
int res, n;
struct sigaction sigact;
char sys_hostname[HOST_NAME_MAX 1];
char *lblf=NULL;

gethostname(sys_hostname, sizeof(sys_hostname));
idstation = strndup(sys_hostname, 32);

res = 0;
while ((c = getopt(argc, argv, "HDvarfsRo:t:g:Ap:n:N:j:l:c:i:L:G:b:")) != EOF) {

switch (c) {
case 'v':
verbose = 1;
break;
case 'o':
outtype = atoi(optarg);
break;
case 't':
mdly = atoi(optarg);
break;
case 'b':
lblf=optarg;
break;
#ifdef WITH_ALSA
case 'a':
res = initAlsa(argv, optind);
inmode = 1;
break;
#endif
#ifdef WITH_SNDFILE
case 'f':
res = initSoundfile(argv, optind);
inmode = 2;
break;
#endif
#ifdef WITH_RTL
case 'r':
res = initRtl(argv, optind);
inmode = 3;
break;
case 'p':
ppm = atoi(optarg);
break;
case 'g':
gain = atoi(optarg);
break;
#endif
#ifdef WITH_SDRPLAY
case 's':
res = initSdrplay (argv, optind);
inmode = 5;
break;
case 'p':
ppm = atoi(optarg);
break;
case 'L':
lnaState = atoi(optarg);
break;
case 'G':
GRdB = atoi(optarg);
break;
#endif
#ifdef WITH_AIR
case 's':
res = initAirspy(argv, optind);
inmode = 4;
break;
case 'g':
gain = atoi(optarg);
break;
#endif
case 'n':
Rawaddr = optarg;
netout = NETLOG_PLANEPLOTTER;
break;
case 'N':
Rawaddr = optarg;
netout = NETLOG_NATIVE;
break;
case 'j':
Rawaddr = optarg;
netout = NETLOG_JSON;
break;
case 'A':
airflt = 1;
break;
case 'l':
logfilename = optarg;
break;
case 'H':
hourly = 1;
break;
case 'D':
daily = 1;
break;
case 'i':
free(idstation);
idstation = strndup(optarg, 32);
break;

default:
usage();
}
}

if (inmode == 0) {
fprintf(stderr, "Need at least one of -a|-f|-r|-R options\n");
usage();
}

if (res) {
fprintf(stderr, "Unable to init input\n");
exit(res);
}

if(hourly && daily) {
fprintf(stderr, "Options: -H and -D are exclusive\n");
exit(1);
}

build_label_filter(lblf);

res = initOutput(logfilename, Rawaddr);
if (res) {
fprintf(stderr, "Unable to init output\n");
exit(res);
}

sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGQUIT, &sigact, NULL);

for (n = 0; n < nbch; n ) {
channel[n].chn = n;

res = initMsk(&(channel[n]));
if (res)
break;
res = initAcars(&(channel[n]));
if (res)
break;
}

if (res) {
fprintf(stderr, "Unable to init internal decoders\n");
exit(res);
}

if (verbose)
fprintf(stderr, "Decoding %d channels\n", nbch);

/* main decoding */
switch (inmode) {
#ifdef WITH_ALSA
case 1:
res = runAlsaSample();
break;
#endif
#ifdef WITH_SNDFILE
case 2:
res = runSoundfileSample();
break;
#endif
#ifdef WITH_RTL
case 3:
res = runRtlSample();
break;
#endif
#ifdef WITH_AIR
case 4:
res = runAirspySample();
break;
#endif
#ifdef WITH_SDRPLAY
case 5:
res = runSdrplaySample ();
break;
#endif
default:
res = -1;
}

for (n = 0; n < nbch; n )
deinitAcars(&(channel[n]));

fprintf(stderr, "exiting ...\n");
exit(res);

}


标签: acars decoder

实例下载地址

ACARS解码程序

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

第 1 楼 司徒云翳 发表于: 2021-12-11 16:55 55
下完怎么运行

支持(0) 盖楼(回复)

发表评论

(您的评论需要经过审核才能显示)

查看所有1条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警