Skip to content
Snippets Groups Projects
Commit 014cd429 authored by burneykb's avatar burneykb
Browse files
parents 07f7d32f 88ad63f0
No related branches found
No related tags found
No related merge requests found
Showing
with 1128 additions and 22 deletions
test.log
\ No newline at end of file
test.log
groundStation/gui/build*
.gdb_history
......@@ -34,7 +34,7 @@ FECOBJECTS = $(FECSOURCES:$(FESRCDIR)/%.c=$(OBJDIR)/%.o)
OBJECTS=$(CLIOBJECTS) $(BECOBJECTS) $(BECPPOBJECTS) $(FECOBJECTS)
# Default target
all: quad logs objdir backend cli $(SYMLINKS)
all: quad logs objdir backend cli $(SYMLINKS) frontend.a
quad:
$(MAKE) -C ../quad
......@@ -44,6 +44,9 @@ $(SYMLINKS): $(CLIBINARY)
vrpn: vrpn/build
frontend.a: $(FECOBJECTS)
ar rvs frontend.a $(wildcard $(OBJDIR)/frontend_*.o)
cli: $(CLIOBJECTS) $(FECOBJECTS)
$(GCC) $(CFLAGS) $^ -o $(CLIBINARY) $(INCLUDES) $(LIBS)
......@@ -78,4 +81,4 @@ clean_logs:
clean:
rm -rf $(OBJDIR)/ $(BEBINARY) $(CLIBINARY) $(SYMLINKS)
debug:
\ No newline at end of file
debug:
#-------------------------------------------------
#
# Project created by QtCreator 2017-02-23T15:03:45
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MicroCART
TEMPLATE = app
LIBS += ../../frontend.a
INCLUDEPATH += ../../src/frontend/
SOURCES += main.cpp\
mainwindow.cpp \
wrappers.c \
trackerworker.cpp \
controlworker.cpp
HEADERS += mainwindow.h \
wrappers.h \
trackerworker.h \
controlworker.h
FORMS += mainwindow.ui
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.2.2, 2017-03-24T14:09:55. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{9578df81-eac2-4831-8e1a-80abf90f9c0f}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{199b6d60-acb7-4eec-805c-8e68ddaba3f6}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/MicroCART_17-18/groundStation/gui/build-MicroCART-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jake/MicroCART_17-18/groundStation/gui/build-MicroCART-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MicroCART</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jake/MicroCART_17-18/groundStation/gui/MicroCART/MicroCART.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">MicroCART.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">16</value>
</data>
<data>
<variable>Version</variable>
<value type="int">16</value>
</data>
</qtcreator>
#include "controlworker.h"
controlworker::controlworker(QObject *parent) :
QObject(parent)
{
}
#ifndef CONTROLWORKER_H
#define CONTROLWORKER_H
#include <QObject>
#include "frontend_common.h"
class controlworker : public QObject
{
Q_OBJECT
public:
explicit controlworker(QObject *parent = 0);
signals:
public slots:
private:
struct backend_conn * conn;
};
#endif // CONTROLWORKER_H
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include <QThread>
#include <QTimer>
#include "wrappers.h"
#include "trackerworker.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
backendPid(0),
backendPipe(-1)
{
ui->setupUi(this);
/* Create a thread for workers */
QThread* workerThread = new QThread(this);
/* Create a worker to update the tracker */
TrackerWorker * trackerWorker = new TrackerWorker();
/* Move it to the worker thread. This means that slots of this worker
* will run in the worker thread, and not block the UI */
trackerWorker->moveToThread(workerThread);
/* Connect tracker worker */
connect(trackerWorker, SIGNAL (finished(float, float, float, float, float, float)),
this, SLOT (updateTracker(float, float, float, float, float, float)));
/* Connect and disconnect from backend when signals emitted */
connect(this, SIGNAL (connectWorkers()), trackerWorker, SLOT (connectBackend()));
connect(this, SIGNAL (disconnectWorkers()), trackerWorker, SLOT (disconnectBackend()));
/* Create other workers and add them to the worker thread, then connect them */
/* Now we can activate the slots of the workers with impunity and not block the UI thread */
/* Connect refresh button and refresh timer to tracker worker */
QTimer * trackerTimer = new QTimer(this);
connect(trackerTimer, SIGNAL(timeout()), trackerWorker, SLOT(process()));
connect(findChild<QPushButton *>("pbRefresh"), SIGNAL (clicked()), trackerWorker, SLOT (process()));
/* Start the things */
trackerTimer->start(300);
workerThread->start();
/* Create a timer to poll stdout and populate virtual console */
QTimer * consoleTimer = new QTimer(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::updateConsole()
{
if (backendPipe != -1) {
char buf[256];
size_t len = 0;
len = readBackend(backendPipe, buf, len);
printf("%d\n", len);
if (len > 0) {
printf("From pipe: %s", buf);
QLineEdit * con = findChild<QLineEdit *>("vConsole");
con->setText(con->text().append(buf));
}
}
}
void MainWindow::updateTracker(float x, float y, float z, float p, float r, float yaw)
{
findChild<QLineEdit *>("xLineEdit")->setText(QString::number(x));
findChild<QLineEdit *>("yLineEdit")->setText(QString::number(y));
findChild<QLineEdit *>("zLineEdit")->setText(QString::number(z));
findChild<QLineEdit *>("pLineEdit")->setText(QString::number(p));
findChild<QLineEdit *>("rLineEdit")->setText(QString::number(r));
findChild<QLineEdit *>("yLineEdit_2")->setText(QString::number(yaw));
}
void MainWindow::on_pbStart_clicked()
{
this->backendPid = startBackend(findChild<QLineEdit *>("backendPath")->text().toStdString().c_str(), &backendPipe);
findChild<QPushButton *>("pbStart")->setEnabled(false);
findChild<QPushButton *>("pbStop")->setEnabled(true);
backendState = 1;
}
void MainWindow::on_pbConnect_clicked()
{
findChild<QPushButton *>("pbStart")->setEnabled(false);
findChild<QPushButton *>("pbConnect")->setEnabled(false);
findChild<QPushButton *>("pbStop")->setEnabled(true);
emit(connectWorkers());
backendState = 1;
}
void MainWindow::on_pbStop_clicked()
{
emit(disconnectWorkers());
if (backendPid) {
stopBackend(backendPid, backendPipe);
backendPipe = -1;
backendPid = 0;
}
findChild<QPushButton *>("pbStart")->setEnabled(true);
findChild<QPushButton *>("pbConnect")->setEnabled(true);
findChild<QPushButton *>("pbStop")->setEnabled(false);
backendState = 0;
}
void MainWindow::on_chooseBackend_clicked()
{
QString backendPath = QFileDialog::getOpenFileName(this,
tr("Path to Backend Executable"));
findChild<QLineEdit *>("backendPath")->setText(backendPath);
}
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
signals:
void connectWorkers();
void disconnectWorkers();
private slots:
void on_pbStart_clicked();
void on_pbConnect_clicked();
void on_pbStop_clicked();
void on_chooseBackend_clicked();
void updateTracker(float x, float y, float z, float p, float r, float yaw);
void updateConsole();
private:
Ui::MainWindow *ui;
pid_t backendPid;
int backendPipe;
int backendState;
};
#endif // MAINWINDOW_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>798</width>
<height>581</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>801</width>
<height>471</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="backend">
<attribute name="title">
<string>Connection</string>
</attribute>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>761</width>
<height>341</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbConnect">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbStop">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Stop/Disconnect</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="chooseBackend">
<property name="text">
<string>Choose Backend</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="backendPath"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTextEdit" name="vConsole">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="status">
<attribute name="title">
<string>Quad Status</string>
</attribute>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>-1</x>
<y>9</y>
<width>451</width>
<height>226</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="xLabel">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="xLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="yLabel">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="yLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="zLabel">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="zLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="pLabel">
<property name="text">
<string>P</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="pLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="rLabel">
<property name="text">
<string>R</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="rLineEdit">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="yLabel_2">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="yLineEdit_2">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2"/>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="controlGraph">
<attribute name="title">
<string>Controller Graph</string>
</attribute>
<widget class="QWidget" name="verticalLayoutWidget_2">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>771</width>
<height>421</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="graphImage">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Node:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="nodeSelect">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Param:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="paramSelect"/>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="paramValue">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="pbControlRefresh">
<property name="text">
<string>Refresh Controller Graph</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>
<widget class="QPushButton" name="pbRefresh">
<property name="geometry">
<rect>
<x>10</x>
<y>480</y>
<width>88</width>
<height>34</height>
</rect>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>798</width>
<height>30</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
#include "trackerworker.h"
#include <QThread>
#include "frontend_common.h"
#include "frontend_tracker.h"
TrackerWorker::TrackerWorker() :
QObject(), conn(NULL)
{
}
TrackerWorker::~TrackerWorker()
{
disconnectBackend();
}
void TrackerWorker::connectBackend()
{
conn = ucart_backendConnect();
}
void TrackerWorker::disconnectBackend()
{
if (conn) {
ucart_backendDisconnect(conn);
conn = NULL;
}
}
void TrackerWorker::process()
{
if (conn) {
struct frontend_tracker_data td;
frontend_track(conn, &td);
emit finished(td.height, td.lateral, td.longitudinal, td.pitch, td.roll, td.yaw);
}
}
#ifndef TRACKERWORKER_H
#define TRACKERWORKER_H
#include <QObject>
#include "frontend_common.h"
#include "frontend_tracker.h"
class TrackerWorker : public QObject
{
Q_OBJECT
public:
TrackerWorker();
~TrackerWorker();
signals:
void finished(float, float, float, float, float, float);
public slots:
void process();
void connectBackend();
void disconnectBackend();
private:
struct backend_conn * conn;
};
#endif // TRACKERWORKER_H
#include "wrappers.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <unistd.h>
#include <signal.h>
#include <err.h>
#include <stdlib.h>
size_t readBackend(int fd, char * buf, size_t maxlen)
{
int len = read(fd, buf, maxlen);
if (len < 0) {
len = 0;
}
return len;
}
int stopBackend(int pid, int pipefd)
{
close(pipefd);
kill(pid, SIGTERM);
int status;
wait(&status);
return status;
}
int startBackend(const char * backend, int * pipefd)
{
/* Create a pipe */
int pipe_fds[2];
if (pipe(pipe_fds)) {
warn("Failed to open pipe, cannot start backend!");
return -1;
}
int pid = fork();
if (!pid) {
/* Child closes read end of pipe */
close(pipe_fds[0]);
write(pipe_fds[1], "From child", 11);
/* dup write end of pipe to stdout (FD 1), closing old stdout */
//dup2(pipe_fds[1], 1);
//dup2(pipe_fds[1], 2);
write(2, "Child stderr\n", 13);
printf("Child stdout\n");
/* Don't need whatever FD is in pipe_fds[1] anymore, since it is stdout now */
close(pipe_fds[1]);
execl(backend, "BackEnd", NULL);
exit(0);
}
/* Return the read end of the pipe in pipefd pointer */
*pipefd = pipe_fds[0];
/* Parent closes write end of the pipe */
close(pipe_fds[1]);
return pid;
}
#ifndef WRAPPERS_H
#define WRAPPERS_H
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdio.h>
int startBackend(const char * backend, int * pipefd);
int stopBackend(int pid, int pipefd);
size_t readBackend(int fd, char * buf, size_t maxlen);
#ifdef __cplusplus
}
#endif
#endif // WRAPPERS_H
......@@ -2,6 +2,10 @@
#define _FRONTEND_COMMON_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
struct backend_conn;
/* Start connection to quad */
......@@ -44,4 +48,7 @@ struct frontend_node_data {
char *name;
};
#endif /* __FRONTEND_COMMON_H */
\ No newline at end of file
#ifdef __cplusplus
}
#endif
#endif /* __FRONTEND_COMMON_H */
......@@ -11,14 +11,22 @@
*
* Returns 0 on success, 1 on error
*
* node_data and num_nodes are out-pointers.
* node_data must be a pointer to NULL
* num_nodes must be a pointer to zero
*
* Note : node_data may be resized inside this function.
* That is why you must pass in a strcut ... **
*/
int frontend_getnodes(
struct backend_conn * conn,
struct frontend_node_data ** node_data,
size_t * num_nodes) {
if ((node_data == NULL) || (num_nodes == NULL)) {
return 1;
}
if ((*node_data != NULL) || (*num_nodes != 0)) {
return 1;
}
char msg[64] = "";
int written;
......@@ -122,4 +130,14 @@ int frontend_addnode(
}
return 0;
}
\ No newline at end of file
}
void frontend_free_node_data(
struct frontend_node_data *nd,
size_t num_nodes)
{
for (size_t i = 0; i < num_nodes; i++) {
free(nd[i].name);
}
free(nd);
}
......@@ -8,8 +8,10 @@
*
* Returns 0 on success, 1 on error
*
* Note : node_data may be resized inside this function.
* That is why you must pass in a strcut ... **
* node_data and num_nodes are out pointers
* node_data must point to a NULL pointer
* num_nodes must point to zero
*
*/
int frontend_getnodes(
struct backend_conn * conn,
......@@ -25,4 +27,9 @@ int frontend_addnode(
struct backend_conn * conn,
struct frontend_node_data * node_data);
#endif /* __FRONTEND_NODES_H */
\ No newline at end of file
/* Free a node_data array */
void frontend_free_node_data(
struct frontend_node_data * nd,
size_t num_nodes);
#endif /* __FRONTEND_NODES_H */
......@@ -3,6 +3,10 @@
#include "frontend_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Struct containing pos/att data */
struct frontend_tracker_data {
double height;
......@@ -24,4 +28,8 @@ struct frontend_tracker_data {
int frontend_track(struct backend_conn * conn,
struct frontend_tracker_data *data);
#endif /* __FRONTEND_TRACKER_H */
\ No newline at end of file
#ifdef __cplusplus
}
#endif
#endif /* __FRONTEND_TRACKER_H */
#include "queue.h"
int queue_init(struct Queue *q, volatile unsigned char *buff, unsigned int max_size) {
int queue_init(struct Queue *q, volatile unsigned char *buff, unsigned int max_size_plus1) {
q->buff = buff;
q->max_size = max_size + 1;
q->start = max_size;
q->max_size_plus1 = max_size_plus1;
q->start = max_size_plus1 - 1;
q->end = 0;
return 0;
}
......@@ -13,7 +13,7 @@ struct Queue * queue_malloc(unsigned int max_size) {
if (buff == NULL) return NULL;
struct Queue *q = malloc(sizeof(struct Queue));
if (q == NULL) return NULL;
queue_init(q, buff, max_size);
queue_init(q, buff, max_size + 1);
return q;
}
......@@ -28,7 +28,7 @@ int queue_add(struct Queue *q, unsigned char c) {
}
q->buff[q->end] = c;
q->end += 1;
q->end %= q->max_size;
q->end %= q->max_size_plus1;
return 0;
}
......@@ -37,17 +37,17 @@ int queue_remove(struct Queue *q, unsigned char *c) {
return -1;
}
q->start += 1;
q->start %= q->max_size;
q->start %= q->max_size_plus1;
*c = q->buff[q->start];
return 0;
}
int queue_size(struct Queue *q) {
return (q->max_size + q->end - q->start - 1) % q->max_size;
return (q->max_size_plus1 + q->end - q->start - 1) % q->max_size_plus1;
}
int queue_full(struct Queue *q) {
return q->start == q->end;;
return q->start == q->end;
}
int queue_empty(struct Queue *q) {
......@@ -57,7 +57,7 @@ int queue_empty(struct Queue *q) {
void queue_print(struct Queue *q) {
int i;
printf("buffer: (size: %d, full: %d, empty: %d)\n", queue_size(q), queue_full(q), queue_empty(q));
for (i = 0; i < q->max_size; i += 1) {
for (i = 0; i < q->max_size_plus1; i += 1) {
char c = (char) q->buff[i];
if (c == 0) c = '-';
printf("%c", c);;
......
......@@ -6,13 +6,13 @@
struct Queue {
volatile unsigned char *buff;
unsigned int max_size;
unsigned int max_size_plus1;
unsigned int start;
unsigned int end;
};
int queue_init(struct Queue *q, volatile unsigned char *buff, unsigned int max_size);
int queue_init(struct Queue *q, volatile unsigned char *buff, unsigned int max_size_plus1);
struct Queue * queue_malloc(unsigned int max_size);
void queue_free(struct Queue *q);
int queue_add(struct Queue *q, unsigned char c);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment