uhd_continous.cpp 1.7 KB
Newer Older
D
dev 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
/*
 * Copyright 2015 Ettus Research LLC
 * Copyright 2018 Ettus Research, a National Instruments Company
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <QCoreApplication>
#include <QTextStream>
#include "cmdlineparser.h"
#include "tb_interface.h"
#include <QFile>
#ifdef Q_OS_LINUX
#include <unistd.h>
#endif
using namespace TASKBUS;
using namespace std;

int do_iio(const cmdlineParser & args);

int  main(int argc, char * argv[])
{
    QCoreApplication a(argc, argv);
    init_client();
#ifdef OFFLINEDEBUG
    FILE * old_stdin, *old_stdout;
    auto ars = debug("D:\\pid1008",&old_stdin,&old_stdout);
    const  cmdlineParser args (ars);
#else
    const cmdlineParser args (argc,argv);
#endif

    int ret = 0;
    QTextStream stmerr(stderr);
    //每个模块要响应 --information参数,打印自己的功能定义字符串。或者提供一个json文件。
    if (args.contains("information"))
    {
        QFile fp(":/uhd_usrp_continous."+QLocale::system().name()+".json");
        if (!fp.open(QIODevice::ReadOnly))
        {
            fp.setFileName(":/uhd_usrp_continous.json");
            fp.open(QIODevice::ReadOnly);
        }
        if (fp.isOpen())
        {
            QByteArray arr = fp.readAll();
            arr.push_back('\0');
            puts(arr.constData());
            fflush(stdout);
        }
        ret = -1;
    }
    else if (args.contains("function"))//正常运行模式
    {
		fprintf(stderr,"Entering Loop...\n");
        //用于接收消息的线程
        ret = do_iio(args);
    }
    else
    {
        stmerr<<"Error:Function does not exits.\n";
        ret = -1;
    }
    return ret;




}