Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 396 → Rev 395

/QMK-Groundstation/branches/own_com_lib/com.pri
File deleted
/QMK-Groundstation/branches/own_com_lib/groundstation.kdevelop
File deleted
/QMK-Groundstation/branches/own_com_lib/Classes/cConnection.cpp
42,21 → 42,21
 
void cConnection::new_Data(QString Data)
{
//Data = Data;
Data = Data;
 
while ((RxData.str.size() > 1) && (RxData.str.substr(1,1) == string("#")))
while ((RxData.String.length() > 1) && (RxData.String.at(1) == '#'))
{
RxData.str = RxData.str.substr(1, RxData.str.size());
RxData.String.remove(0,1);
}
 
if (Parser::check_CRC(RxData.str))
if (ToolBox::check_CRC(RxData.String))
{
RxData.input = (char *)RxData.str.c_str();
RxData.Input = RxData.String.toLatin1().data();
emit(newData(RxData));
}
else
{
emit(showTerminal(2, QString(RxData.str.c_str())));
emit(showTerminal(2, RxData.String));
}
 
}
72,11 → 72,11
if (RXt[a] == '\r')
{
new_Data(QString(""));
RxData.str = string("");
RxData.String = QString("");
}
else
{
RxData.str = RxData.str + string(&RXt[a]);
RxData.String = RxData.String + QString(RXt[a]);
}
a++;
}
124,7 → 124,7
TTY->setPort(Address); //Port
TTY->open();
 
ToolBox::wait(1000);
ToolBox::Wait(1000);
 
if (TTY->isOpen())
{
181,11 → 181,11
if (Input[z] == '\r')
{
new_Data(QString(""));
RxData.str = string("");
RxData.String = QString("");
}
else
{
RxData.str = RxData.str + Input[z].toAscii();
RxData.String = RxData.String + Input[z];
}
}
}
195,17 → 195,16
if (b_isOpen)
{
QByteArray Temp;
string TX_Data;
QString TX_Data;
 
if (CMD != '#')
{
TX_Data = Parser::encode64(Data, Length);
TX_Data = ToolBox::Encode64(Data, Length);
 
char addr = 'a' + Address;
TX_Data = string("#") + (string(&addr)) + string(&CMD) + TX_Data;
TX_Data = Parser::add_CRC(TX_Data) + '\r';
TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data;
TX_Data = ToolBox::add_CRC(TX_Data) + '\r';
 
Temp = QByteArray(TX_Data.c_str());
Temp = QByteArray(TX_Data.toUtf8());
 
if (Resend)
{
235,7 → 234,7
break;
}
 
emit(showTerminal(3, QString(TX_Data.c_str())));
emit(showTerminal(3, TX_Data));
}
return true;
}
/QMK-Groundstation/branches/own_com_lib/Forms/dlg_MotorMixer.cpp
68,9 → 68,9
}
 
// Connection-Object übergeben.
void dlg_MotorMixer::set_Objects(Handler *handler, cSettings *t_Settings)
void dlg_MotorMixer::set_Objects(cConnection *t_Connection, cSettings *t_Settings)
{
this->handler = handler;
o_Connection = t_Connection;
o_Settings = t_Settings;
}
 
79,7 → 79,7
{
int Pos = 0;
 
MixerName = ToolBox::dataToQString(RX.decode, 1, 12);
MixerName = ToolBox::Data2QString(RX.Decode, 1, 12);
 
Pos = 13;
 
87,7 → 87,7
{
for (int y = 0; y < 4; y++)
{
Motor[z][y] = Parser::dataToChar(RX.decode,Pos);
Motor[z][y] = ToolBox::Data2Char(RX.Decode,Pos);
Pos++;
}
}
253,8 → 253,6
}
}
 
//FIXME: put this in com/Handler.cpp
/*
int dlg_MotorMixer::get_MotorConfig()
{
get_MotorData();
282,7 → 280,7
{
for (int y = 0; y < 4; y++)
{
TX_Data[Pos] = Parser::charToData(Motor[z][y]);
TX_Data[Pos] = ToolBox::Char2Data(Motor[z][y]);
Pos++;
}
}
294,22 → 292,19
{
TX_Data[0] = 0;
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true);
}*/
}
 
// read motor values
// Motordaten auslesen
void dlg_MotorMixer::slot_pb_READ()
{
//send command to get mixer values
handler->read_mixer();
TX_Data[0] = 0;
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true);
}
 
//write motor values
//FIXME: put this in com/Handler.cpp
 
void dlg_MotorMixer::slot_pb_WRITE()
{
/* int Length = get_MotorConfig();
o_Connection->send_Cmd('m', ADDRESS_FC, TX_Data, Length, true);*/
int Length = get_MotorConfig();
o_Connection->send_Cmd('m', ADDRESS_FC, TX_Data, Length, true);
}
 
void dlg_MotorMixer::slot_pb_LOAD()
/QMK-Groundstation/branches/own_com_lib/Forms/dlg_MotorMixer.h
29,7 → 29,6
#include "../typedefs.h"
//#include "../Classes/ToolBox.h"
#include "../global.h"
#include "../com/Handler.h"
 
class dlg_MotorMixer : public QDialog, public Ui::dlg_MotorMixer_UI
{
37,24 → 36,25
 
public:
dlg_MotorMixer(QWidget *parent = 0);
void set_Objects(Handler *handler, cSettings *t_Settings);
void set_Objects(cConnection *t_Connection, cSettings *t_Settings);
void set_MotorConfig(sRxData RX);
void read_Mixer();
 
private:
//Handler for MK-Communication
Handler *handler;
// Object für Kopter-Verbindung
cConnection *o_Connection;
 
cSettings *o_Settings;
 
char TX_Data[150];
 
int Motor[16][4]; //vgl. typedefs.h
int Motor[16][4];
QString MixerName;
int MixerVersion;
 
void set_MotorData();
void get_MotorData();
int get_MotorConfig();
 
private slots:
void slot_pb_READ();
/QMK-Groundstation/branches/own_com_lib/Forms/mktool.cpp
36,6 → 36,7
#include "dlg_Preferences.h"
#include "../global.h"
#include "../Classes/ToolBox.h"
#include "../com/Parser.h"
 
#include <stdlib.h>
 
197,19 → 198,13
 
void MKTool::init_Objects()
{
//new QT-Communication object
com = new QTCommunication();
 
//create handler that handles incomming data
handler = new Handler(com);
 
// QTimer-Instanzen
Ticker = new QTimer(this);
 
// Verbindungsobject
//o_Connection = new cConnection();
o_Connection = new cConnection();
 
// Logger
// neuer Logger
logger = new Logger(Settings, &Mode);
 
// LCD-Dialog
243,14 → 238,13
connect(f_Map, SIGNAL(set_WayPoints(QList<sWayPoint>)), this , SLOT(slot_MAP_SetWayPoints(QList<sWayPoint>)));
 
// Daten Senden / Empfangen
//FIXME: put this in QTCommunication.cpp
// connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
// connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
 
// Serielle Verbundung öffnen / schließen
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
 
// TCP-Connection for other QMK-Groundstations
// TCP-Connection verbinden / trennen
connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect()));
 
// Buttons Settings lesen / schreiben
412,7 → 406,6
}
 
// Waypoint zur NC Senden.
//FIXME: put this in cpp/NaviCtrl.cpp
void MKTool::slot_pb_SendTarget()
{
if ((Navi.Current.Longitude == 0) && (Navi.Current.Latitude == 0))
460,8 → 453,7
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius &&
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius)
{
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false);
}
else
{
496,11 → 488,10
// Hardware Auswahl und umschalten
void MKTool::slot_rb_Hardware()
{
//FIXME:put this in Handler.cpp
if ((rb_SelNC->isChecked() == false) && (Mode.ID != ADDRESS_NC))
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
/*TX_Data[0] = 0x1B;
TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
507,38 → 498,38
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
ToolBox::wait(SLEEP);*/
ToolBox::wait(SLEEP);
}
 
if (rb_SelFC->isChecked())
{
lb_Status->setText(tr("Schalte um auf FlightCtrl."));
/*TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
TX_Data[0] = 0;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
}
else
if (rb_SelMag->isChecked())
{
lb_Status->setText(tr("Schalte um auf MK3MAG."));
/*TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);*/
TX_Data[0] = 1;
o_Connection->send_Cmd('u', ADDRESS_NC, TX_Data, 1, false);
}
else
if (rb_SelNC->isChecked())
{
lb_Status->setText(tr("Schalte um auf NaviCtrl."));
/*TX_Data[0] = 0x1B;
TX_Data[0] = 0x1B;
TX_Data[1] = 0x1B;
TX_Data[2] = 0x55;
TX_Data[3] = 0xAA;
TX_Data[4] = 0x00;
TX_Data[5] = '\r';
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);*/
o_Connection->send_Cmd('#', ADDRESS_NC, TX_Data, 6, false);
}
ToolBox::wait(SLEEP);
 
// qDebug("Select RB Hardware");
//o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
o_Connection->send_Cmd('v', ADDRESS_ALL, TX_Data, 0, true);
}
 
// Ticker-Event
545,13 → 536,22
///////////////
void MKTool::slot_Ticker()
{
//FIXME: Put this somewhere in Handler.cpp
/*
if (TickerDiv)
TickerDiv = false;
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)
603,7 → 603,6
}
}
}
*/
}
 
// Zum QMK-Datenserver verbinden
709,8 → 708,6
 
void MKTool::slot_Motortest(sMotor p_Motor)
{
//FIXME: put this in com/Handler.cpp
/*
Motor = p_Motor;
 
for (int z = 0; z<12; z++)
718,14 → 715,13
TX_Data[z] = Motor.Speed[z];
}
o_Connection->send_Cmd('t', ADDRESS_FC, TX_Data, 12, false);
*/
}
 
// Motormixer-Einstellungen anzeigen
void MKTool::slot_ac_MotorMixer()
{
f_MotorMixer->set_Objects(handler, Settings);
handler->read_mixer();
f_MotorMixer->set_Objects(o_Connection, Settings);
f_MotorMixer->read_Mixer();
 
if (f_MotorMixer->exec()==QDialog::Accepted)
{
743,13 → 739,12
// LCD auf / ab
connect(f_LCD->pb_LCDup, SIGNAL(clicked()), this, SLOT(slot_LCD_UP()));
connect(f_LCD->pb_LCDdown, SIGNAL(clicked()), this, SLOT(slot_LCD_DOWN()));
//FIXME: put this in com/Handler.cpp
 
f_LCD->show();
/*TX_Data[0] = 0;
TX_Data[0] = 0;
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
//FIXME: replace ticker with something else
 
Ticker->setInterval(500);
TickerEvent[2] = true;
}
766,8 → 761,6
 
void MKTool::slot_MAP_SetWayPoints(QList<sWayPoint> l_WayPoints)
{
//FIXME: Put this in com/Handler.cpp or com/NaviCtrlHandler.cpp
/*
Waypoint_t WayPoint;
double Longitude, Latitude;
 
804,7 → 797,7
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false);
// ToolBox::Wait(SLEEP);
}
*/
 
}
 
void MKTool::slot_MAP_SetTarget(sWayPoint Target)
961,15 → 954,14
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
//TX_Data[0] = Settings->Data.Navi_Fast / 10;
TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
//TX_Data[0] = Settings->Data.Navi_Slow / 10;
TX_Data[0] = Settings->Data.Navi_Slow / 10;
}
//FIXME: put this in com/Handler.cpp / com/NaviCtrl.cpp
//o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
}
 
978,7 → 970,7
if (ac_NoNavi->isChecked())
{
lb_Status->setText(tr("NaviDaten abstellen."));
// TX_Data[0] = 0;
TX_Data[0] = 0;
}
else
{
985,16 → 977,15
if (ac_FastNavi->isChecked())
{
lb_Status->setText(tr("Fordere schnelle NaviDaten an."));
// TX_Data[0] = Settings->Data.Navi_Fast / 10;
TX_Data[0] = Settings->Data.Navi_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame NaviDaten an."));
// TX_Data[0] = Settings->Data.Navi_Slow / 10;
TX_Data[0] = Settings->Data.Navi_Slow / 10;
}
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false);
}
 
void MKTool::slot_ac_FastDebug() // DONE 0.71g
1004,15 → 995,14
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
TX_Data[0] = Settings->Data.Debug_Slow / 10;
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
}
 
1022,7 → 1012,7
{
lb_Status->setText(tr("DebugDaten abstellen."));
TickerEvent[3] = false;
//TX_Data[0] = 0;
TX_Data[0] = 0;
}
else
{
1033,16 → 1023,15
if (ac_FastDebug->isChecked())
{
lb_Status->setText(tr("Fordere schnelle DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Fast / 10;
TX_Data[0] = Settings->Data.Debug_Fast / 10;
}
else
{
lb_Status->setText(tr("Fordere langsame DebugDaten an."));
//TX_Data[0] = Settings->Data.Debug_Slow / 10;
TX_Data[0] = Settings->Data.Debug_Slow / 10;
}
}
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false);
}
 
void MKTool::slot_ac_About()
1053,9 → 1042,8
void MKTool::slot_ac_GetLabels() // DONE 0.71g
{
lb_Status->setText(tr("Analoglabels auslesen."));
//FIXME: Put this in com/Handler.cpp
// TX_Data[0] = 0;
// o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
TX_Data[0] = 0;
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
}
 
void MKTool::slot_ac_StartServer()
1161,12 → 1149,11
 
Update = new QProcess();
 
//FIXME: put this in QTCommunication.cpp
/* if (o_Connection->isOpen())
if (o_Connection->isOpen())
{
slot_OpenPort();
}
*/
 
Argumente << "-P";
Argumente << le_Port->text();
Argumente << "-p";
1221,9 → 1208,8
{
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1))
{
// TX_Data[0] = 0;
//FIXME: Put this in com/Handler.cpp
// o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
TX_Data[0] = 0;
o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false);
 
Ticker->setInterval(500);
TickerEvent[1] = true;
1239,8 → 1225,7
// LCD-Seiten weiterschalten
void MKTool::slot_LCD_UP() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/* if (LCD_Page == LCD_MAX_Page)
if (LCD_Page == LCD_MAX_Page)
TX_Data[0] = 0;
else
TX_Data[0] = LCD_Page + 1;
1247,13 → 1232,10
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
}
 
void MKTool::slot_LCD_DOWN() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
if (LCD_Page == 0)
TX_Data[0] = LCD_MAX_Page;
else
1261,7 → 1243,6
 
TX_Data[1] = 0;
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true);
*/
}
 
// Settings aus MK lesen / in MK schreiben
1268,24 → 1249,18
void MKTool::slot_GetFCSettings() // DONE 0.71g
{
lb_Status->setText(tr("Lese FlightCtrl-Settings aus."));
//FIXME: Put this in com/Handler.cpp
/*
TX_Data[0] = f_Settings->sb_Set->value();
TX_Data[1] = 0;
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true);
*/
}
 
void MKTool::slot_SetFCSettings() // DONE 0.71g
{
//FIXME: Put this in com/Handler.cpp
/*
char *TX_Data2 = f_Settings->GetFCSettings();
 
lb_Status->setText(tr("Schreibe FlightCtrl-Settings."));
 
o_Connection->send_Cmd('s', ADDRESS_FC, TX_Data2, MaxParameter + 2, true);
*/
}
 
 
1535,8 → 1510,6
// Verbindung zum Kopter herstellen / Trennen
void MKTool::slot_OpenPort()
{
//FIXME: Put this in com/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
TX_Data[0] = Settings->Data.Debug_Off / 10;
1589,7 → 1562,6
Ticker->start(2000);
}
}
*/
}
 
// Programm beenden
1597,13 → 1569,11
 
MKTool::~MKTool()
{
//FIXME: Put this in com/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
o_Connection->Close();
}
*/
 
set_Preferences();
Settings->write_Settings();
 
/QMK-Groundstation/branches/own_com_lib/Forms/mktool.h
53,9 → 53,7
#include "../typedefs.h"
 
//quadcopter lib stuff
#include "../com/Handler.h"
#include "../com/Communication.h"
#include "../com/QTCommunication.h"
#include "../com/Parser.h"
 
class QextSerialPort;
 
69,12 → 67,8
 
private:
// Object für Kopter-Verbindung
//cConnection *o_Connection;
cConnection *o_Connection;
 
Handler *handler;
 
Communication *com;
 
// Settings-Object (Programmeinstellungen)
cSettings *Settings;
 
143,6 → 137,9
// Softwareupdate
QProcess *Update;
 
// Sendedatenbuffer
char TX_Data[150];
 
// FC-Settings
int FCSettings[MaxParameter];
 
/QMK-Groundstation/branches/own_com_lib/com/Communication.h
8,12 → 8,11
 
using namespace std;
 
class Communication{
class Communication {
public:
//connect to MK
virtual void connectMK(string) {};
//send command to MK
virtual bool sendCmd(char, int, char[150],unsigned int, bool) { return false; };
virtual void stopReSend() {};
virtual bool sendCmd(char, int, char[150],unsigned int, bool) {};
};
#endif
/QMK-Groundstation/branches/own_com_lib/com/Handler.cpp
11,14 → 11,10
* read mixer values from FlightCtrl
*/
void Handler::read_mixer() {
char tx_data[1] = {0};
//com->log("read motor mixer");
com->sendCmd('n', ADDRESS_FC, tx_data, 1, true);
TX_Data[0] = 0;
com->send_cmd('n', ADDRESS_FC, TX_Data, 1, true);
}
 
void Handler::get_motor_config() {
}
 
void Handler::receive_data(sRxData RX) {
//extract hardware ID from received Data
int hardwareID = RX.input[1] - 'a';
35,7 → 31,7
 
if (RX.decode[0] == VERSION_MIXER)
{
//f_MotorMixer->set_MotorConfig(RX);
f_MotorMixer->set_MotorConfig(RX);
}
}
break;
47,7 → 43,7
 
if (RX.decode[0] == 1)
{
//lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben."));
lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben."));
}
}
break;
56,7 → 52,7
case 'P' : // DONE 0.71g
if (Parser::decode64(RX))
{
/*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true));
f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true));
f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true));
f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true));
f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true));
63,7 → 59,7
f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true));
f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true));
f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true));
f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/
f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));
}
break;
// Settings lesen
70,22 → 66,22
case 'Q' : // DONE 0.71g
if (Parser::decode64(RX))
{
com->stopReSend();
o_Connection->stop_ReSend();
 
if (RX.decode[1] == VERSION_SETTINGS)
{
int Settings_ID = RX.decode[0];
/*for (int a = 0; a < MaxParameter; a++)
for (int a = 0; a < MaxParameter; a++)
{
FCSettings[a] = RX.decode[a + 2];
}
f_Settings->show_FCSettings(Settings_ID, FCSettings);
f_Settings->pb_Read->setEnabled(true);
f_Settings->pb_Write->setEnabled(true);*/
f_Settings->pb_Write->setEnabled(true);
}
else
{
/*f_Settings->pb_Read->setDisabled(true);
f_Settings->pb_Read->setDisabled(true);
f_Settings->pb_Write->setDisabled(true);
 
QString name = QString("Versionen inkompatibel.\n") +
95,14 → 91,13
QString(RX.decode[1]) +
QString("\nParameterbearbeitung nicht moeglich.");
QMessageBox::warning(this, QA_NAME,
name, QMessageBox::Ok);*/
name, QMessageBox::Ok);
}
}
break;
// Settings written
// Settings geschrieben
case 'S' : // DONE 0.71g
com->stopReSend();
//TODO: QMessagebox("settings written successful") ?
o_Connection->stop_ReSend();
break;
}
 
113,7 → 108,7
case 'O' : // NOT DONE 0.12h
if (Parser::decode64(RX))
{
//new_NaviData(RX);
new_NaviData(RX);
}
break;
}
126,9 → 121,9
case 'L' : // DONE 0.71g
if (Parser::decode64(RX))
{
com->stopReSend();
o_Connection->stop_ReSend();
 
/*int LCD[150];
int LCD[150];
memcpy(LCD,RX.decode, sizeof(RX.decode));
 
f_LCD->show_Data(LCD);
135,7 → 130,6
 
LCD_Page = RX.decode[0];
LCD_MAX_Page = RX.decode[1];
*/
}
break;
// Analoglabels
142,12 → 136,11
case 'A' : // DONE 0.71g
if (Parser::decode64(RX))
{
com->stopReSend();
o_Connection->stop_ReSend();
 
int Position = RX.decode[0];
if (Position != 31)
{
/*
Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed();
if (Settings->Analog1.Label[Position] == "")
{
155,11 → 148,10
}
Position ++;
TX_Data[0] = Position;
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);
}
if (Position == 31)
{
/*
for (int a = 0; a < MaxAnalog; a++)
{
lb_Analog[a]->setText(Settings->Analog1.Label[a]);
166,7 → 158,7
}
Settings->Analog1.Version = QString(Mode.Version);
Settings->write_Settings_AnalogLabels(HardwareID);
config_Plot();*/
config_Plot();
}
}
break;
176,9 → 168,9
{
for (int i = 0; i < MaxAnalog; i++)
{
//AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2);
AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2);
}
//show_DebugData();
show_DebugData();
}
break;
// Version
185,8 → 177,8
case 'V' : // DONE 0.71h
if (Parser::decode64(RX))
{
com->stopReSend();
/*
o_Connection->stop_ReSend();
 
Mode.ID = HardwareID;
Mode.VERSION_MAJOR = RX.decode[0];
Mode.VERSION_MINOR = RX.decode[1];
291,7 → 283,7
{
lb_Analog[a]->setText(Settings->Analog1.Label[a]);
}
config_Plot();*/
config_Plot();
}
break;
}
/QMK-Groundstation/branches/own_com_lib/com/Handler.h
1,10 → 1,8
#ifndef HANDLER_H
#define HANDLER_H
#include <string>
#include "Parser.h"
#include "Communication.h"
#include "Kopter.h"
#include "../Parameter_Positions.h"
#include <Parser.h>
#include <Communication.h>
 
/**
* The Handler handels commands that are send from/to the Mikrokopter
14,14 → 12,10
class Handler {
private:
Communication * com;
 
//buffer to send data
//char tx_data[150];
public:
Handler(Communication * com);
void read_mixer();
void receive_data(sRxData rx);
void get_motor_config();
};
 
#endif
/QMK-Groundstation/branches/own_com_lib/com/Parser.cpp
2,7 → 2,7
 
// Base64 Decoder
// see Parser.h for details about sRxData
bool Parser::decode64(sRxData &rx)
void Parser::decode64(sRxData &rx)
{
int length = rx.str.size();
unsigned char a,b,c,d;
15,10 → 15,8
int len = length;
int decLen = 0;
 
if (rx.input[ptrIn] == 0) {
return false;
//TODO: catch error to show that something went wrong during the decode process
//throw "Nothing received";
if (rx.Input[ptrIn] == 0) {
throw "Nothing received";
}
 
while(len != 0) {
39,7 → 37,7
}
 
for (int a=0; a<ptr; a++) {
if (length == false) {
if (Long == false) {
int b1, b2, b3;
 
b1 = ptrOut[a++];
50,15 → 48,14
if (b3 > 32767)
b3 = b3 - 65536;
 
rx.decode[decLen] = b3;
decLen++;
RX.decode[DecLen] = b3;
DecLen++;
} else {
rx.decode[decLen] = ptrOut[a];
decLen++;
RX.decode[DecLen] = ptrOut[a];
DecLen++;
}
rx.decLen = decLen;
RX.DecLen = DecLen;
}
return true;
}
 
// base64 encoder
70,11 → 67,11
 
char tx_buff[150];
 
while(length > 0)
while(Length > 0)
{
if(length) { a = data[ptr++]; length--;} else a = 0;
if(length) { b = data[ptr++]; length--;} else b = 0;
if(length) { c = data[ptr++]; length--;} else c = 0;
if(Length) { a = data[ptr++]; length--;} else a = 0;
if(Length) { b = data[ptr++]; length--;} else b = 0;
if(Length) { c = data[ptr++]; length--;} else c = 0;
 
tx_buff[pt++] = '=' + (a >> 2);
tx_buff[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4));
128,11 → 125,11
 
float Parser::getFloat(long value, int count)
{
long num = pow(10, count);
long num = math.pow(10, count);
 
float temp = value;
 
return temp / num;
return value / num;
}
 
string Parser::dataToString(int Data[150], int Start, int End)
148,11 → 145,10
}
 
// check CRC
bool Parser::check_CRC(string RXstr)
bool Parser::check_CRC(char * RX, int length)
{
int length = RXstr.size();
int CRC = 0;
char *RX = (char *)RXstr.c_str();
char *RX;
 
if (RX[1] == 127)
{
180,9 → 176,8
}
 
// add CRC
string Parser::add_CRC(string TX)
string Parser::add_CRC(char * TX, int length)
{
int length = TX.size();
unsigned int tmpCRC = 0;
 
char CRC[2];
/QMK-Groundstation/branches/own_com_lib/com/Parser.h
1,7 → 1,6
#ifndef PARSER_H
#define PARSER_H
#include <string>
#include <cmath>
 
/**
* The Parser gets values from the Mikrokopter-USART interface
8,8 → 7,6
* and parses them into a sRxData-Struct
*/
 
using namespace std;
 
struct sRxData
{
char *input;
23,8 → 20,8
static bool decode64(sRxData &rx);
static string encode64(char data[150],unsigned int length);
 
static string add_CRC(string TX);
static bool check_CRC(string RX);
static string add_CRC(char * TX, int length);
static string check_CRC(char * RX, int length);
 
static float getFloat(long value, int count);
 
/QMK-Groundstation/branches/own_com_lib/com/QTCommunication.cpp
6,8 → 6,4
 
bool QTCommunication::sendCmd(char cmd, int address, char data[150], unsigned int length, bool resend) {
};
 
void QTCommunication::stopReSend() {
};
/QMK-Groundstation/branches/own_com_lib/com/QTCommunication.h
10,12 → 10,9
* ( philippe.vianney.liaud gmail.com )
*/
 
using namespace std;
 
class QTCommunication : public Communication {
public:
void connectMK(string addr);
bool sendCmd(char cmd, int address, char data[150], unsigned int length, bool resend);
void stopReSend();
};
#endif
/QMK-Groundstation/branches/own_com_lib/eeepc.pro
1,5 → 1,4
include(QMapControl.pri)
include(com.pri)
 
 
DEFINES += _TTY_POSIX_ _EEEPC_
7,4 → 6,8
LIBS += -lqwt-qt4
INCLUDEPATH += $(HOME)/include /usr/include/qwt-qt4
 
include(global.pri)
include(global.pri)HEADERS += com/Handler.h com/Parser.h com/Kopter.h \
com/Communication.h \
com/QTCommunication.h
SOURCES += com/QTCommunication.cpp
 
/QMK-Groundstation/branches/own_com_lib
Property changes:
Deleted: svn:ignore
-Doxyfile
-groundstation.kdevses
-Makefile
-build
-svn-prop.tmp
-QMKGroundStation.kdevelop.pcs