/QMK-Groundstation/trunk/Classes/cConnection.cpp |
---|
0,0 → 1,138 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#include "cConnection.h" |
cConnection::cConnection() |
{ |
TTY = new ManageSerialPort(); |
b_isOpen = false; |
} |
void cConnection::slot_newDataReceived(const QByteArray &dataReceived) |
{ |
const char *RXt; |
RXt = dataReceived.data(); |
int a = 0; |
while (RXt[a] != '\0') |
{ |
if (RXt[a] == '\r') |
{ |
while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#')) |
{ |
RxData.String.remove(0,1); |
} |
if (ToolBox::check_CRC(RxData.String)) |
{ |
RxData.Input = RxData.String.toLatin1().data(); |
emit(newData(RxData)); |
// emit(showTerminal(1, RxData.String)); |
} |
else |
{ |
emit(showTerminal(2, RxData.String)); |
} |
RxData.String = QString(""); |
} |
else |
{ |
RxData.String = RxData.String + QString(RXt[a]); |
} |
a++; |
} |
} |
bool cConnection::isOpen() |
{ |
return b_isOpen; |
} |
bool cConnection::Close() |
{ |
TTY->close(); |
disconnect(TTY, SIGNAL(newDataReceived(const QByteArray &)), this, 0); |
return b_isOpen; |
} |
bool cConnection::Open(QString Address) |
{ |
TTY->setPort(Address); //Port |
TTY->setBaudRate(BAUD57600); //BaudRate |
TTY->setDataBits(DATA_8); //DataBits |
TTY->setParity(PAR_NONE); //Parity |
TTY->setStopBits(STOP_1); //StopBits |
TTY->setFlowControl(FLOW_OFF); //FlowControl |
TTY->setTimeout(0, 10); |
TTY->enableSending(); |
TTY->enableReceiving(); |
TTY->open(); |
if (TTY->isOpen()) |
{ |
connect(TTY, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &))); |
TTY->receiveData(); |
b_isOpen = true; |
} |
return b_isOpen; |
} |
bool cConnection::send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) |
{ |
if (b_isOpen) |
{ |
QByteArray Temp; |
QString TX_Data; |
if (CMD != '#') |
{ |
TX_Data = ToolBox::Encode64(Data, Length); |
TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
if (Resend) |
{ |
// LastSend = TX_Data; |
// TickerEvent[0] = true; |
} |
Temp = QByteArray(TX_Data.toUtf8()); |
} |
else |
{ |
for (unsigned int a = 0; a < Length; a++) |
{ |
Temp[a] = Data[a]; |
} |
} |
TTY->sendData(Temp); |
emit(showTerminal(3, TX_Data)); |
} |
return true; |
} |
/QMK-Groundstation/trunk/Classes/cConnection.h |
---|
0,0 → 1,51 |
/*************************************************************************** |
* Copyright (C) 2009 by Manuel Schrape * |
* manuel.schrape@gmx.de * |
* * |
* This program is free software; you can redistribute it and/or modify * |
* it under the terms of the GNU General Public License as published by * |
* the Free Software Foundation; either version 2 of the License. * |
* * |
* This program is distributed in the hope that it will be useful, * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* GNU General Public License for more details. * |
* * |
* You should have received a copy of the GNU General Public License * |
* along with this program; if not, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
#ifndef CCONNECTION_H |
#define CCONNECTION_H |
#include <QObject> |
#include "ToolBox.h" |
#include "../global.h" |
#include "../SerialPort/ManageSerialPort.h" |
class cConnection : public QObject |
{ |
Q_OBJECT |
public: |
cConnection(); |
bool isOpen(); |
bool Open(QString Address); |
bool Close(); |
bool send_Cmd(char CMD, int Address, char Data[150],unsigned int Length, bool Resend = true); |
private: |
ManageSerialPort *TTY; |
bool b_isOpen; |
sRxData RxData; |
private slots: |
void slot_newDataReceived(const QByteArray &dataReceived); |
signals: |
void newData(sRxData RxData); |
void showTerminal(int Typ, QString Text); |
}; |
#endif // CCONNECTION_H |
/QMK-Groundstation/trunk/Forms/mktool.cpp |
---|
17,6 → 17,8 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
***************************************************************************/ |
// TODO: Wiederholungssenden wieder einbauen |
#include <QtGui> |
#include <QLineEdit> |
60,7 → 62,7 |
tab_Main->removeTab(6); |
// Tab mit Wegpunkte-Elementen verbergen |
tab_Main->removeTab(5); |
// tab_Main->removeTab(5); |
// Settings-Tab hinzufügen. |
f_Settings = new wdg_Settings( this ); |
99,7 → 101,6 |
Compass->setScaleTicks(0, 0, 3); |
Compass->setScale(36, 5, 0); |
// Compass->setNeedle(new QwtCompassMagnetNeedle(QwtCompassMagnetNeedle::ThinStyle)); |
Compass->setNeedle(new QwtDialSimpleNeedle(QwtDialSimpleNeedle::Arrow, true, Qt::red, QColor(Qt::gray).light(130))); |
Compass->setPalette(newPalette); |
Compass->setMaximumSize(QSize(MeterSize, MeterSize)); |
196,8 → 197,10 |
Ticker = new QTimer(this); |
// Seriell-Port |
serialPort = new ManageSerialPort; |
// serialPort = new ManageSerialPort; |
Conn = new cConnection(); |
// neuer Logger |
logger = new Logger(Settings, &Mode); |
205,7 → 208,7 |
f_LCD = new dlg_LCD(this); |
// Senden erlauben (Warum auch immer) |
AllowSend = true; |
// AllowSend = true; |
Server = new cServer(); |
224,8 → 227,9 |
{ |
connect(Dec, SIGNAL(clicked()), this, SLOT(slot_Test())); |
// Seriel-Port Empfang |
connect(serialPort, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_newDataReceived(const QByteArray &))); |
// Daten Senden / Empfangen |
connect(Conn, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData))); |
connect(Conn, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString))); |
// Serielle Verbundung öffnen / schließen |
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort())); |
274,6 → 278,9 |
connect(pb_Update, SIGNAL(clicked()), this, SLOT(slot_pb_Update())); |
connect(pb_HexFile, SIGNAL(clicked()), this, SLOT(slot_pb_HexFile())); |
// Wegpunkt-Befehl |
connect(pb_FlyTo, SIGNAL(clicked()), this, SLOT(slot_pb_SendWaypoint())); |
// CVS-Record starten / stoppen |
connect(ac_RecordCSV, SIGNAL(triggered()), this, SLOT(slot_RecordLog())); |
344,7 → 351,7 |
{ |
Plot[a] = new QwtPlotCurve(Settings->Analog1.Label[a]); |
Plot[a]->setPen(QPen(QColor(Def_Colors[a]))); |
Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased); |
// Plot[a]->setRenderHint(QwtPlotItem::RenderAntialiased); |
if (Settings->Analog1.PlotView[a]) |
Plot[a]->attach(qwtPlot); |
352,19 → 359,91 |
qwtPlot->replot(); |
} |
void MKTool::slot_Test() |
{ |
/* |
sRxData RX; |
} |
RX.String = IN->text(); |
RX.Input = IN->text().toLatin1().data(); |
void MKTool::parse_TargetKML() |
{ |
QString Tmp = te_KML->toPlainText().simplified(); |
QStringList List; |
new_RXData(RX); |
*/ |
if ((Tmp.contains("<kml xmlns=\"http://earth.google.com/kml/2.2\">")) && (Tmp.contains("<coordinates>"))) |
{ |
List = Tmp.split("<coordinates>"); |
List = List[1].split(","); |
le_TarLong->setText(ToolBox::get_Float((List[0].toDouble() * 10000000), 10000000)); |
le_TarLat->setText(ToolBox::get_Float((List[1].toDouble() * 10000000), 10000000)); |
} |
} |
void MKTool::slot_pb_SendWaypoint() |
{ |
if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0)) |
{ |
QMessageBox msgB; |
QString msg; |
msgB.setText("Fehler: Es konnten keine GPS-Daten vom Mikrokopter empfangen werden"); |
msgB.exec(); |
return; |
} |
//erstelle einen Wegpunkt, den die NaviCtrl auswerten kann |
Waypoint_t desired_pos; |
bool ok_lat, ok_lon; |
//eingegebene Daten holen |
double desired_long, desired_lat; |
desired_long = le_TarLong->text().toDouble(&ok_lon); |
desired_lat = le_TarLat->text().toDouble(&ok_lat); |
if (ok_lon && desired_long < 100) |
desired_long *= 10000000+0.5; |
if (ok_lat && desired_lat < 100) |
desired_lat *= 10000000+0.5; |
//fülle Wegpunkt-Daten |
desired_pos.Position.Altitude = 0; |
desired_pos.Position.Longitude = int32_t(desired_long); |
desired_pos.Position.Latitude = int32_t(desired_lat); |
desired_pos.Position.Status = NEWDATA; |
desired_pos.Heading = -1; |
desired_pos.ToleranceRadius = 1; |
desired_pos.HoldTime = 60; |
desired_pos.Event_Flag = 0; |
desired_pos.reserve[0] = 0; // reserve |
desired_pos.reserve[1] = 0; // reserve |
desired_pos.reserve[2] = 0; // reserve |
desired_pos.reserve[3] = 0; // reserve |
//...und sende ihn an die NaviCtrl |
int max_radius = 10000; |
if (ok_lat && ok_lon && |
abs(Navi.Current.Longitude - desired_pos.Position.Longitude) < max_radius && |
abs(Navi.Current.Latitude - desired_pos.Position.Latitude) < max_radius) |
{ |
Conn->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
} |
else |
{ |
QMessageBox msgB; |
QString msg; |
msg += "Bitte die Eingabe ueberpruefen!\n"; |
msg += "Die Werte muessen sich in der Naehe der aktuellen Koordinaten befinden\n"; |
msg += "(Lon: "; |
msg += ToolBox::get_Float(Navi.Current.Longitude,10000000); |
msg += ", "; |
msg += "Lat: "; |
msg += ToolBox::get_Float(Navi.Current.Latitude,10000000); |
msg += ")"; |
msgB.setText(msg); |
msgB.exec(); |
} |
} |
void MKTool::slot_ac_Hardware() |
{ |
QAction *Action = (QAction*)sender(); |
388,7 → 467,7 |
TX_Data[3] = 0xAA; |
TX_Data[4] = 0x00; |
TX_Data[5] = '\r'; |
send_Data('#', ADDRESS_NC, TX_Data, 6, false); |
Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
ToolBox::Wait(SLEEP); |
} |
396,7 → 475,7 |
{ |
lb_Status->setText(tr("Schalte um auf FlightCtrl.")); |
TX_Data[0] = 0; |
send_Data('u', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
} |
else |
if (rb_SelMag->isChecked()) |
403,7 → 482,7 |
{ |
lb_Status->setText(tr("Schalte um auf MK3MAG.")); |
TX_Data[0] = 1; |
send_Data('u', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false); |
} |
else |
if (rb_SelNC->isChecked()) |
415,12 → 494,12 |
TX_Data[3] = 0xAA; |
TX_Data[4] = 0x00; |
TX_Data[5] = '\r'; |
send_Data('#', ADDRESS_NC, TX_Data, 6, false); |
Conn->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false); |
} |
ToolBox::Wait(SLEEP); |
// qDebug("Select RB Hardware"); |
send_Data('v', ADDRESS_ALL, TX_Data, 0, true); |
Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
} |
// Ticker-Event |
432,6 → 511,17 |
else |
TickerDiv = true; |
if (cb_ClipBoard->isChecked()) |
{ |
QString s_OLD = te_KML->toPlainText(); |
te_KML->clear(); |
te_KML->paste(); |
if (s_OLD != te_KML->toPlainText()) |
{ |
parse_TargetKML(); |
} |
} |
for (int a = 0; a < MaxTickerEvents; a++) |
{ |
if (TickerEvent[a] == true) |
442,12 → 532,12 |
if (TickerDiv) |
{ |
QByteArray Temp(LastSend.toUtf8()); |
serialPort->sendData(Temp); |
// serialPort->sendData(Temp); |
} |
break; |
case 1 : |
TX_Data[0] = 0; |
send_Data('p', ADDRESS_FC, TX_Data, 0, false); |
Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
break; |
case 2 : |
if (f_LCD->cb_LCD->isChecked()) |
459,7 → 549,7 |
} |
TX_Data[0] = LCD_Page; |
TX_Data[1] = 0; |
send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
break; |
case 3 : |
466,12 → 556,12 |
if (ac_FastDebug->isChecked()) |
{ |
TX_Data[0] = Settings->Data.Debug_Fast / 10; |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
else |
{ |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
break; |
} |
576,7 → 666,7 |
f_LCD->show(); |
TX_Data[0] = 0; |
TX_Data[1] = 0; |
send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
Ticker->setInterval(500); |
TickerEvent[2] = true; |
589,7 → 679,7 |
TX_Data[1] = Motor2; |
TX_Data[2] = Motor3; |
TX_Data[3] = Motor4; |
send_Data('t', ADDRESS_FC, TX_Data, 4, false); |
Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
} |
void MKTool::slot_ac_Config() |
737,7 → 827,7 |
lb_Status->setText(tr("Fordere langsame NaviDaten an.")); |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
} |
761,7 → 851,7 |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
} |
send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
void MKTool::slot_ac_FastDebug() // DONE 0.71g |
778,7 → 868,7 |
lb_Status->setText(tr("Fordere langsame DebugDaten an.")); |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
} |
807,7 → 897,7 |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
} |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
void MKTool::slot_ac_About() |
819,7 → 909,7 |
{ |
lb_Status->setText(tr("Analoglabels auslesen.")); |
TX_Data[0] = 0; |
send_Data('a', ADDRESS_ALL, TX_Data, 1, true); |
Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
} |
void MKTool::slot_ac_StartServer() |
925,7 → 1015,7 |
Update = new QProcess(); |
if (serialPort->isOpen()) |
if (Conn->isOpen()) |
{ |
slot_OpenPort(); |
} |
985,7 → 1075,7 |
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->tab_Par->currentIndex() == 1)) |
{ |
TX_Data[0] = 0; |
send_Data('p', ADDRESS_FC, TX_Data, 0, true); |
Conn->send_Cmd('p', ADDRESS_FC, TX_Data, 0, true); |
Ticker->setInterval(500); |
TickerEvent[1] = true; |
1023,8 → 1113,7 |
TX_Data[0] = LCD_Page + 1; |
TX_Data[1] = 0; |
send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
void MKTool::slot_LCD_DOWN() // DONE 0.71g |
1035,10 → 1124,7 |
TX_Data[0] = LCD_Page - 1; |
TX_Data[1] = 0; |
send_Data('l', ADDRESS_ALL, TX_Data, 1, true); |
aa--; |
Conn->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
} |
// Settings aus MK lesen / in MK schreiben |
1047,7 → 1133,7 |
lb_Status->setText(tr("Lese FlightCtrl-Settings aus.")); |
TX_Data[0] = f_Settings->sb_Set->value(); |
TX_Data[1] = 0; |
send_Data('q', ADDRESS_FC, TX_Data, 1); |
Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1); |
} |
void MKTool::slot_SetFCSettings() // DONE 0.71g |
1056,7 → 1142,7 |
lb_Status->setText(tr("Schreibe FlightCtrl-Settings.")); |
send_Data('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false); |
Conn->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, false); |
} |
1230,12 → 1316,6 |
{ |
MyServer->NewPosition(NaviString); |
} |
/* |
qDebug(NaviString.Longitude.toLatin1().data()); |
qDebug(NaviString.Latitude.toLatin1().data()); |
qDebug(NaviString.Altitude.toLatin1().data()); |
*/ |
} |
// Seriel-Port Bereich, Befehle senden und Daten empfangen |
1242,8 → 1322,9 |
////////////////////////////////////////////////////////// |
// Neues Datenpacket empfangen -> Verarbeiten |
void MKTool::new_RXData(sRxData RX) // DONE 0.71g |
void MKTool::slot_newData(sRxData RX) // DONE 0.71g |
{ |
slot_showTerminal(1, RX.String); |
if (LastSend.length() > 2) |
{ |
1349,7 → 1430,7 |
} |
Position ++; |
TX_Data[0] = Position; |
send_Data('a', ADDRESS_ALL, TX_Data, 1, true); |
Conn->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
} |
if (Position == 31) |
{ |
1413,7 → 1494,7 |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
// Wenn MK3MAG dann andauernd Daten neu anfragen. |
if (Mode.ID == ADDRESS_MK3MAG) |
1441,7 → 1522,7 |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
1452,7 → 1533,11 |
{ |
TX_Data[0] = 0xff; |
TX_Data[1] = 0; |
send_Data('q', ADDRESS_FC, TX_Data, 1); |
// DEP: Raus wenn Resend implementiert. |
ToolBox::Wait(SLEEP); |
Conn->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
qDebug("FC - Get Settings"); |
} |
} |
// Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
1482,52 → 1567,37 |
} |
} |
// Neue Daten an der Schnittstelle |
void MKTool::slot_newDataReceived(const QByteArray &dataReceived) // DONE 0.71g |
void MKTool::slot_showTerminal(int Typ, QString Text) |
{ |
const char *RXt; |
RXt = dataReceived.data(); |
int a = 0; |
while (RXt[a] != '\0') |
switch(Typ) |
{ |
if (RXt[a] == '\r') |
case 1 : |
{ |
while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#')) |
{ |
RxData.String.remove(0,1); |
} |
if (ToolBox::check_CRC(RxData.String)) |
{ |
RxData.Input = RxData.String.toLatin1().data(); |
new_RXData(RxData); |
if ((cb_ShowData->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
{ |
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
// te_RX->insertPlainText(" > " + RxData.String + '\r'); |
te_RX->insertHtml("<span style=\"color:#00008b;\">" + RxData.String + "<br /></span>"); |
te_RX->insertHtml("<span style=\"color:#00008b;\">" + Text + "<br /></span>"); |
} |
} |
else |
break; |
case 2 : |
{ |
if ((cb_ShowMSG->isChecked()) && ((tab_Main->currentWidget()->objectName() == QString("Tab_3")) || (cb_ShowAlways->isChecked()))) |
{ |
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
// te_RX->insertPlainText(" > " + RxData.String + '\r'); |
te_RX->insertHtml("<span style=\"color:#008b00;\">" + RxData.String + "<br /></span>"); |
te_RX->insertHtml("<span style=\"color:#008b00;\">" + Text + "</span>"); |
} |
} |
RxData.String = QString(""); |
} |
else |
break; |
case 3 : |
{ |
if (cb_ShowSend->isChecked()) |
{ |
RxData.String = RxData.String + QString(RXt[a]); |
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
te_RX->insertHtml("<span style='color:#8b0000;'>" + Text + "<br /></span>"); |
} |
} |
a++; |
break; |
} |
} |
1534,16 → 1604,16 |
// Seriellen Port öffnen |
void MKTool::slot_OpenPort() |
{ |
if (serialPort->isOpen()) |
if (Conn->isOpen()) |
{ |
TX_Data[0] = Settings->Data.Debug_Off / 10; |
send_Data('d', ADDRESS_ALL, TX_Data, 1, false); |
Conn->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
ToolBox::Wait(SLEEP); |
if (Mode.ID == ADDRESS_NC) |
{ |
TX_Data[0] = Settings->Data.Navi_Off / 10; |
send_Data('o', ADDRESS_NC, TX_Data, 1, false); |
Conn->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
ToolBox::Wait(SLEEP); |
} |
1553,15 → 1623,13 |
TX_Data[1] = 0; |
TX_Data[2] = 0; |
TX_Data[3] = 0; |
send_Data('t', ADDRESS_FC, TX_Data, 4, false); |
Conn->send_Cmd('t', ADDRESS_FC, TX_Data, 4, false); |
ToolBox::Wait(SLEEP); |
} |
serialPort->close(); |
// pb_Open->setText("Seriell Verbinden"); |
Conn->Close(); |
ac_ConnectTTY->setText("Seriell Verbinden"); |
// pb_Open->setIcon(ToolBox::Icon(9)); |
// ac_ConnectTTY->setIcon(ToolBox::Icon(9)); |
le_Port->setEnabled(true); |
Ticker->stop(); |
1568,94 → 1636,26 |
} |
else |
{ |
serialPort->setPort(le_Port->text()); //Port |
serialPort->setBaudRate(BAUD57600); //BaudRate |
serialPort->setDataBits(DATA_8); //DataBits |
serialPort->setParity(PAR_NONE); //Parity |
serialPort->setStopBits(STOP_1); //StopBits |
serialPort->setFlowControl(FLOW_OFF); //FlowControl |
serialPort->setTimeout(0, 10); |
serialPort->enableSending(); |
serialPort->enableReceiving(); |
serialPort->open(); |
if (serialPort->isOpen()) |
if (Conn->Open(le_Port->text())) |
{ |
ac_ConnectTTY->setText("Seriell Trennen"); |
le_Port->setEnabled(false); |
serialPort->receiveData(); |
send_Data('v', ADDRESS_ALL, TX_Data, 0, true); |
Conn->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true); |
// pb_Open->setText("Seriell Trennen"); |
ac_ConnectTTY->setText("Seriell Trennen"); |
// pb_Open->setIcon(ToolBox::Icon(8)); |
// ac_ConnectTTY->setIcon(ToolBox::Icon(8)); |
Ticker->start(2000); |
} |
} |
} |
// Daten senden |
void MKTool::send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend) // DONE 0.71g |
{ |
if (serialPort->isOpen() && AllowSend) |
{ |
QByteArray Temp; |
QString TX_Data; |
if (CMD != '#') |
{ |
// qDebug("Send data.."); |
TX_Data = ToolBox::Encode64(Data, Length); |
TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
// qDebug(TX_Data.toLatin1().data()); |
TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
// qDebug(TX_Data.toLatin1().data()); |
if (Resend) |
{ |
LastSend = TX_Data; |
TickerEvent[0] = true; |
} |
Temp = QByteArray(TX_Data.toUtf8()); |
} |
else |
{ |
// qDebug("Send Raw.."); |
for (unsigned int a = 0; a < Length; a++) |
{ |
Temp[a] = Data[a]; |
// qDebug(QString("%1").arg(Temp[a]).toLatin1().data()); |
} |
} |
serialPort->sendData(Temp); |
if (cb_ShowSend->isChecked() && (CMD != '#')) |
{ |
te_RX->moveCursor(QTextCursor::End, QTextCursor::MoveAnchor); |
te_RX->insertHtml("<span style='color:#8b0000;'>" + TX_Data + "<br /></span>"); |
} |
} |
} |
// Programm beenden |
/////////////////// |
MKTool::~MKTool() |
{ |
// qDebug(" Programm Ende ..!! "); |
if (serialPort->isOpen()) |
if (Conn->isOpen()) |
{ |
serialPort->close(); |
Conn->Close(); |
} |
set_Preferences(); |
/QMK-Groundstation/trunk/Forms/mktool.h |
---|
41,7 → 41,8 |
#include "wdg_Settings.h" |
#include "dlg_LCD.h" |
#include "../SerialPort/ManageSerialPort.h" |
//#include "../SerialPort/ManageSerialPort.h" |
#include "../Classes/cConnection.h" |
#include "../Classes/cSettings.h" |
#include "../Classes/cServer.h" |
#include "../Classes/cQMK_Server.h" |
48,6 → 49,7 |
#include "../Classes/cAttitude.h" |
#include "../Classes/cSpeedMeter.h" |
#include "../Logger/Logger.h" |
#include "../typedefs.h" |
class QextSerialPort; |
66,7 → 68,8 |
bool AllowSend; |
// Object für Serielport |
ManageSerialPort *serialPort; |
// ManageSerialPort *serialPort; |
cConnection *Conn; |
// Settings-Object (Programmeinstellungen) |
cSettings *Settings; |
148,12 → 151,8 |
void config_Plot(); |
void new_NaviData(sRxData RX); |
// void new_Debugdata(); |
void parse_TargetKML(); |
// Daten Senden, Empfangen und verarbeiten |
void send_Data(char CMD, int Address, char Data[150],unsigned int Length, bool Resend = true); |
void new_RXData(sRxData RX); |
// Debugdaten anzeigen und speichern. |
void show_DebugData(); |
void update_Log(); |
166,6 → 165,8 |
void slot_QMKS_Connected(); |
void slot_QMKS_Disconnected(int Error); |
void slot_showTerminal(int Typ, QString Text); |
void slot_ac_Hardware(); |
void slot_rb_Hardware(); |
185,7 → 186,9 |
void slot_ac_GetLabels(); |
void slot_ac_Motortest(); |
void slot_ac_LCD(); |
void slot_pb_HexFile(); |
void slot_pb_SendWaypoint(); |
// Default-Ticker |
void slot_Ticker(); |
201,7 → 204,7 |
void slot_UpdateShell(); |
// Seriell-Port Slots |
void slot_newDataReceived(const QByteArray &dataReceived); |
void slot_newData(sRxData RX); |
void slot_OpenPort(); |
void slot_TabChanged(int Tab); |
/QMK-Groundstation/trunk/Forms/mktool.ui |
---|
1670,105 → 1670,207 |
<iconset resource="../MKTool.qrc" > |
<normaloff>:/Actions/Images/Actions/Waypoints.png</normaloff>:/Actions/Images/Actions/Waypoints.png</iconset> |
</attribute> |
</widget> |
<widget class="QWidget" name="Seite" > |
<attribute name="title" > |
<string>Debug</string> |
</attribute> |
<layout class="QGridLayout" name="gridLayout_9" > |
<layout class="QGridLayout" name="gridLayout_14" > |
<item row="0" column="0" > |
<widget class="QLabel" name="lb_Port" > |
<widget class="QGroupBox" name="groupBox_2" > |
<property name="title" > |
<string>Target</string> |
</property> |
<layout class="QGridLayout" name="gridLayout_11" > |
<item row="0" column="0" > |
<layout class="QGridLayout" name="gridLayout_10" > |
<item row="0" column="0" > |
<widget class="QLabel" name="label_8" > |
<property name="text" > |
<string>Device: </string> |
<string>Longitude:</string> |
</property> |
</widget> |
</item> |
<item row="0" column="1" > |
<widget class="QLineEdit" name="le_Port" > |
<property name="sizePolicy" > |
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" > |
<horstretch>0</horstretch> |
<verstretch>0</verstretch> |
</sizepolicy> |
<widget class="QLineEdit" name="le_TarLong" /> |
</item> |
<item row="1" column="0" > |
<widget class="QLabel" name="label_9" > |
<property name="text" > |
<string>Latitude:</string> |
</property> |
</widget> |
</item> |
<item row="1" column="1" > |
<widget class="QLineEdit" name="le_TarLat" /> |
</item> |
<item row="3" column="0" colspan="2" > |
<widget class="QPushButton" name="pb_FlyTo" > |
<property name="text" > |
<string>/dev/ttyUSB0</string> |
<string>Fliege da hin</string> |
</property> |
</widget> |
</item> |
<item row="0" column="2" > |
<widget class="QPushButton" name="pb_Open" > |
<item row="2" column="0" colspan="2" > |
<widget class="QCheckBox" name="cb_ClipBoard" > |
<property name="text" > |
<string>Verbinden</string> |
<string>überwache Zwischenablage</string> |
</property> |
<property name="icon" > |
<iconset> |
<normaloff>:/Actions/Images/22X22/network-disconnect.png</normaloff>:/Actions/Images/22X22/network-disconnect.png</iconset> |
</widget> |
</item> |
</layout> |
</item> |
<item row="1" column="0" > |
<spacer name="verticalSpacer_2" > |
<property name="orientation" > |
<enum>Qt::Vertical</enum> |
</property> |
<property name="sizeHint" stdset="0" > |
<size> |
<width>315</width> |
<height>120</height> |
</size> |
</property> |
</spacer> |
</item> |
</layout> |
<zorder>label_8</zorder> |
<zorder>label_9</zorder> |
<zorder>le_TarLong</zorder> |
<zorder>le_TarLat</zorder> |
<zorder>pb_FlyTo</zorder> |
<zorder>verticalSpacer_2</zorder> |
<zorder>te_KML</zorder> |
</widget> |
</item> |
<item row="0" column="3" colspan="2" > |
<widget class="QPushButton" name="pb_Record" > |
<property name="text" > |
<string>CSV Aufzeichen</string> |
<item row="0" column="1" > |
<spacer name="horizontalSpacer_2" > |
<property name="orientation" > |
<enum>Qt::Horizontal</enum> |
</property> |
<property name="icon" > |
<iconset> |
<normaloff>:/Actions/Images/22X22/media-record.png</normaloff>:/Actions/Images/22X22/media-record.png</iconset> |
<property name="sizeHint" stdset="0" > |
<size> |
<width>40</width> |
<height>20</height> |
</size> |
</property> |
</spacer> |
</item> |
</layout> |
</widget> |
</item> |
<item row="0" column="5" > |
<widget class="QPushButton" name="pb_Quit" > |
<widget class="QWidget" name="Seite" > |
<attribute name="title" > |
<string>Debug</string> |
</attribute> |
<widget class="QLabel" name="lb_Port" > |
<property name="geometry" > |
<rect> |
<x>10</x> |
<y>20</y> |
<width>71</width> |
<height>27</height> |
</rect> |
</property> |
<property name="text" > |
<string>Beenden</string> |
<string>Device: </string> |
</property> |
<property name="icon" > |
<iconset> |
<normaloff>:/Actions/Images/22X22/application-exit.png</normaloff>:/Actions/Images/22X22/application-exit.png</iconset> |
</widget> |
<widget class="QLineEdit" name="le_Port" > |
<property name="geometry" > |
<rect> |
<x>100</x> |
<y>20</y> |
<width>131</width> |
<height>27</height> |
</rect> |
</property> |
<property name="sizePolicy" > |
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" > |
<horstretch>0</horstretch> |
<verstretch>0</verstretch> |
</sizepolicy> |
</property> |
<property name="text" > |
<string>/dev/ttyUSB0</string> |
</property> |
</widget> |
</item> |
<item row="1" column="2" > |
<widget class="QRadioButton" name="rb_SelFC" > |
<property name="geometry" > |
<rect> |
<x>250</x> |
<y>20</y> |
<width>147</width> |
<height>21</height> |
</rect> |
</property> |
<property name="text" > |
<string>FlightCtrl</string> |
</property> |
</widget> |
</item> |
<item row="1" column="3" > |
<widget class="QRadioButton" name="rb_SelNC" > |
<property name="geometry" > |
<rect> |
<x>410</x> |
<y>20</y> |
<width>146</width> |
<height>21</height> |
</rect> |
</property> |
<property name="text" > |
<string>NaviCtrl</string> |
</property> |
</widget> |
</item> |
<item row="1" column="4" > |
<widget class="QRadioButton" name="rb_SelMag" > |
<property name="geometry" > |
<rect> |
<x>570</x> |
<y>20</y> |
<width>147</width> |
<height>21</height> |
</rect> |
</property> |
<property name="text" > |
<string>MK3Mag</string> |
</property> |
</widget> |
</item> |
<item row="2" column="0" colspan="2" > |
<widget class="QPushButton" name="Dec" > |
<property name="geometry" > |
<rect> |
<x>4</x> |
<y>240</y> |
<width>281</width> |
<height>26</height> |
</rect> |
</property> |
<property name="text" > |
<string>Decode</string> |
</property> |
</widget> |
</item> |
<item row="3" column="0" colspan="6" > |
<widget class="QLineEdit" name="IN" > |
<property name="geometry" > |
<rect> |
<x>10</x> |
<y>390</y> |
<width>883</width> |
<height>27</height> |
</rect> |
</property> |
<property name="text" > |
<string>#cO][`S>zNIP^y``====M==================================z[lS>|zGP^{]Y====M========[n======>o>m>omMq>|m`J==E=============yY </string> |
</property> |
</widget> |
</item> |
</layout> |
<widget class="QTextEdit" name="te_KML" > |
<property name="geometry" > |
<rect> |
<x>10</x> |
<y>50</y> |
<width>251</width> |
<height>181</height> |
</rect> |
</property> |
</widget> |
</widget> |
</widget> |
</item> |
</layout> |
<zorder>line_2</zorder> |
<zorder>lb_Status</zorder> |
<zorder>tab_Main</zorder> |
</widget> |
<widget class="QMenuBar" name="menubar" > |
<property name="geometry" > |
2238,9 → 2340,6 |
<property name="checkable" > |
<bool>true</bool> |
</property> |
<property name="enabled" > |
<bool>false</bool> |
</property> |
<property name="icon" > |
<iconset resource="../MKTool.qrc" > |
<normaloff>:/Actions/Images/Actions/Waypoints.png</normaloff>:/Actions/Images/Actions/Waypoints.png</iconset> |
2314,54 → 2413,6 |
</hints> |
</connection> |
<connection> |
<sender>pb_Quit</sender> |
<signal>clicked()</signal> |
<receiver>ac_Quit</receiver> |
<slot>trigger()</slot> |
<hints> |
<hint type="sourcelabel" > |
<x>663</x> |
<y>117</y> |
</hint> |
<hint type="destinationlabel" > |
<x>-1</x> |
<y>-1</y> |
</hint> |
</hints> |
</connection> |
<connection> |
<sender>pb_Open</sender> |
<signal>clicked()</signal> |
<receiver>ac_ConnectTTY</receiver> |
<slot>trigger()</slot> |
<hints> |
<hint type="sourcelabel" > |
<x>253</x> |
<y>117</y> |
</hint> |
<hint type="destinationlabel" > |
<x>-1</x> |
<y>-1</y> |
</hint> |
</hints> |
</connection> |
<connection> |
<sender>pb_Record</sender> |
<signal>clicked()</signal> |
<receiver>ac_RecordCSV</receiver> |
<slot>trigger()</slot> |
<hints> |
<hint type="sourcelabel" > |
<x>510</x> |
<y>117</y> |
</hint> |
<hint type="destinationlabel" > |
<x>-1</x> |
<y>-1</y> |
</hint> |
</hints> |
</connection> |
<connection> |
<sender>rb_SelFC</sender> |
<signal>toggled(bool)</signal> |
<receiver>ac_SelFC</receiver> |
/QMK-Groundstation/trunk/debian.pro |
---|
37,7 → 37,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
62,7 → 63,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |
/QMK-Groundstation/trunk/eeepc.pro |
---|
37,7 → 37,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
62,7 → 63,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |
/QMK-Groundstation/trunk/gentoo.pro |
---|
37,7 → 37,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
62,7 → 63,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |
/QMK-Groundstation/trunk/global.h |
---|
56,7 → 56,7 |
static const int SLEEP = 500000; |
static const QString QA_NAME = "QMK-Groundstation"; |
static const QString QA_VERSION_NR = "0.7.0m"; |
static const QString QA_VERSION_NR = "0.7.1f"; |
#ifdef _BETA_ |
static const QString QA_VERSION = QA_VERSION_NR + " (BETA)"; |
/QMK-Groundstation/trunk/osx.pro |
---|
37,7 → 37,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
62,7 → 63,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |
/QMK-Groundstation/trunk/suse.pro |
---|
37,7 → 37,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
62,7 → 63,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |
/QMK-Groundstation/trunk/typedefs.h |
---|
0,0 → 1,46 |
#ifndef TYPEDEFS_H |
#define TYPEDEFS_H |
#ifdef _BETA_ |
#define INVALID 0x00 |
#define NEWDATA 0x01 |
#define PROCESSED 0x02 |
typedef struct |
{ |
int32_t Longitude; // in 1E-7 deg |
int32_t Latitude; // in 1E-7 deg |
int32_t Altitude; // in mm |
uint8_t Status; // validity of data |
} __attribute__((packed)) GPS_Pos_t; |
#else |
typedef enum |
{ |
INVALID = 0, |
NEWDATA = 1, |
PROCESSED = 2 |
} Status_t; |
typedef struct |
{ |
int32_t Longitude; // in 1E-7 deg |
int32_t Latitude; // in 1E-7 deg |
int32_t Altitude; // in mm |
Status_t Status; // validity of data |
} __attribute__((packed)) GPS_Pos_t; |
#endif |
typedef struct |
{ |
GPS_Pos_t Position; // the gps position of the waypoint, see ubx.h for details |
int16_t Heading; // orientation, future implementation |
uint8_t ToleranceRadius; // in meters, if the MK is within that range around the target, then the next target is triggered |
uint8_t HoldTime; // in seconds, if the was once in the tolerance area around a WP, this time defies the delay before the next WP is triggered |
uint8_t Event_Flag; // future emplementation |
uint8_t reserve[12]; // reserve |
} __attribute__((packed)) Waypoint_t; |
#endif // TYPEDEFS_H |
/QMK-Groundstation/trunk/win.pro |
---|
58,7 → 58,8 |
Classes/cQMK_Server.cpp \ |
Logger/Logger.cpp \ |
Logger/CSVLogger.cpp \ |
Forms/dlg_LCD.cpp |
Forms/dlg_LCD.cpp \ |
Classes/cConnection.cpp |
win32:SOURCES += SerialPort/win_qextserialport.cpp |
unix:SOURCES += SerialPort/posix_qextserialport.cpp |
83,7 → 84,9 |
Logger/Logger.h \ |
Logger/CSVLogger.h \ |
Logger/DefaultLogger.h \ |
Forms/dlg_LCD.h |
Forms/dlg_LCD.h \ |
Classes/cConnection.h \ |
typedefs.h |
win32:HEADERS += SerialPort/win_qextserialport.h |
unix:HEADERS += SerialPort/posix_qextserialport.h |