1 | // %flair:license{
|
---|
2 | // This file is part of the Flair framework distributed under the
|
---|
3 | // CECILL-C License, Version 1.0.
|
---|
4 | // %flair:license}
|
---|
5 | #include <QApplication>
|
---|
6 | #include <QCleanlooksStyle>
|
---|
7 | #include <QLocale>
|
---|
8 | #include <qmetatype.h>
|
---|
9 | #include <tclap/CmdLine.h>
|
---|
10 |
|
---|
11 | #include "Manager.h"
|
---|
12 | #include "svnversion.h"
|
---|
13 |
|
---|
14 | using namespace TCLAP;
|
---|
15 | using namespace std;
|
---|
16 |
|
---|
17 | string name;
|
---|
18 | int port;
|
---|
19 |
|
---|
20 | void parseOptions(int argc, char **argv) {
|
---|
21 | try {
|
---|
22 | CmdLine cmd("Command description message", ' ', "0.1");
|
---|
23 |
|
---|
24 | ValueArg<string> nameArg("n", "name", "uav name", false, "x4-0", "string");
|
---|
25 | cmd.add(nameArg);
|
---|
26 |
|
---|
27 | ValueArg<int> portArg("p", "port", "port number", false, 9000, "int");
|
---|
28 | cmd.add(portArg);
|
---|
29 |
|
---|
30 | cmd.parse(argc, argv);
|
---|
31 |
|
---|
32 | // Get the value parsed by each arg.
|
---|
33 | name = nameArg.getValue();
|
---|
34 | port = portArg.getValue();
|
---|
35 |
|
---|
36 | } catch (ArgException &e) { // catch any exceptions
|
---|
37 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | int main(int argc, char *argv[]) {
|
---|
42 |
|
---|
43 | union {
|
---|
44 | uint32_t i;
|
---|
45 | char c[4];
|
---|
46 | } bint = {0x01020304};
|
---|
47 |
|
---|
48 | if (bint.c[0] == 1) {
|
---|
49 | printf("error, ground station is only compatible with little endian\n");
|
---|
50 | return -1;
|
---|
51 | }
|
---|
52 |
|
---|
53 | printf(SVN_REV);
|
---|
54 |
|
---|
55 | parseOptions(argc, argv);
|
---|
56 | printf("listening on port %i\n", port);
|
---|
57 |
|
---|
58 | qRegisterMetaType<const char *>("const char*");
|
---|
59 | QLocale::setDefault(QLocale::C);
|
---|
60 | QApplication app(argc, argv);
|
---|
61 | app.setStyle(new QCleanlooksStyle);
|
---|
62 |
|
---|
63 | Manager manager(QString::fromStdString(name), port);
|
---|
64 |
|
---|
65 | manager.show();
|
---|
66 |
|
---|
67 | app.exec();
|
---|
68 | }
|
---|