source: flair-src/branches/sanscv/tools/FlairGCS/src/main.cpp@ 412

Last change on this file since 412 was 324, checked in by Sanahuja Guillaume, 5 years ago

removing opencv dependency

File size: 2.0 KB
Line 
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 <QTextCursor>
9#include <qmetatype.h>
10#include <tclap/CmdLine.h>
11#include <execinfo.h>
12#include <signal.h>
13
14#include "Manager.h"
15#include "compile_info.h"
16
17using namespace TCLAP;
18using namespace std;
19
20string name;
21int port;
22
23void parseOptions(int argc, char **argv) {
24 try {
25 CmdLine cmd("Command description message", ' ', "0.1");
26
27 ValueArg<string> nameArg("n", "name", "uav name", false, "x4-0", "string");
28 cmd.add(nameArg);
29
30 ValueArg<int> portArg("p", "port", "port number", false, 9000, "int");
31 cmd.add(portArg);
32
33 cmd.parse(argc, argv);
34
35 // Get the value parsed by each arg.
36 name = nameArg.getValue();
37 port = portArg.getValue();
38
39 } catch (ArgException &e) { // catch any exceptions
40 cerr << "error: " << e.error() << " for arg " << e.argId() << endl;
41 }
42}
43
44void seg_fault(int sig __attribute__((unused))) {
45 void *bt[32];
46 int nentries;
47
48 fprintf(stderr,"Segmentation fault:\n");
49 /* Dump a backtrace of the frame which caused the segfault: */
50 nentries = backtrace(bt, sizeof(bt) / sizeof(bt[0]));
51 backtrace_symbols_fd(bt, nentries, fileno(stdout));
52
53 exit(1);
54}
55
56int main(int argc, char *argv[]) {
57
58 union {
59 uint32_t i;
60 char c[4];
61 } bint = {0x01020304};
62
63 if (bint.c[0] == 1) {
64 fprintf(stderr,"error, ground station is only compatible with little endian\n");
65 return -1;
66 }
67
68 compile_info("FlairGCS");
69
70 // catch segfault
71 signal(SIGSEGV, seg_fault);
72
73 parseOptions(argc, argv);
74 fprintf(stderr,"listening on port %i\n", port);
75
76 qRegisterMetaType<const char *>("const char*");
77 qRegisterMetaType<UDTSOCKET>("UDTSOCKET");
78 qRegisterMetaType<QTextCursor>("QTextCursor");
79 QLocale::setDefault(QLocale::C);
80 QApplication app(argc, argv);
81 app.setStyle(new QCleanlooksStyle);
82
83 Manager manager(QString::fromStdString(name), port);
84
85 manager.show();
86
87 app.exec();
88}
Note: See TracBrowser for help on using the repository browser.