mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 22:16:33 +00:00
46 lines
1.2 KiB
C++
46 lines
1.2 KiB
C++
#include <QCommandLineParser>
|
|
#include <QCoreApplication>
|
|
#include <QThread>
|
|
#include "config.hpp"
|
|
#include "localControl.hpp"
|
|
#include "remoteControl.hpp"
|
|
#include "serialCommand.hpp"
|
|
#include "serialPort.hpp"
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
QCoreApplication app(argc, argv);
|
|
QCommandLineParser parser;
|
|
parser.addHelpOption();
|
|
parser.addVersionOption();
|
|
QCommandLineOption lOption(QStringList() << "l", "Use local mode");
|
|
parser.addOption(lOption);
|
|
QCommandLineOption pOption(QStringList() << "p", "Use serial port", "value");
|
|
parser.addOption(pOption);
|
|
parser.process(app);
|
|
bool useRemoteMode = true;
|
|
if (parser.isSet(lOption)) {
|
|
useRemoteMode = false;
|
|
}
|
|
QString useSerialPort;
|
|
if (parser.isSet(pOption)) {
|
|
useSerialPort = parser.value(pOption);
|
|
}
|
|
|
|
SerialPort serialPort(useSerialPort);
|
|
SerialCommand serialCommand;
|
|
Config::setInitalValues(&serialPort, &serialCommand);
|
|
|
|
// Remote mode will read commands from pipe
|
|
if (useRemoteMode == true) {
|
|
qDebug() << "Creating new RemoteControl object";
|
|
new RemoteControl();
|
|
}
|
|
else {
|
|
qDebug() << "Creating new LocalControl object";
|
|
new LocalControl();
|
|
}
|
|
|
|
return app.exec();
|
|
}
|