source: flair-src/trunk/tools/FlairGCS/src/main.cpp @ 222

Last change on this file since 222 was 222, checked in by Sanahuja Guillaume, 3 years ago

allows realloc in graphs

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