/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.String.length() > 1) && (RxData.String.at(1) == '#')) |
while ((RxData.str.size() > 1) && (RxData.str.substr(1,1) == string("#"))) |
{ |
RxData.String.remove(0,1); |
RxData.str = RxData.str.substr(1, RxData.str.size()); |
} |
if (ToolBox::check_CRC(RxData.String)) |
if (Parser::check_CRC(RxData.str)) |
{ |
RxData.Input = RxData.String.toLatin1().data(); |
RxData.input = (char *)RxData.str.c_str(); |
emit(newData(RxData)); |
} |
else |
{ |
emit(showTerminal(2, RxData.String)); |
emit(showTerminal(2, QString(RxData.str.c_str()))); |
} |
} |
72,11 → 72,11 |
if (RXt[a] == '\r') |
{ |
new_Data(QString("")); |
RxData.String = QString(""); |
RxData.str = string(""); |
} |
else |
{ |
RxData.String = RxData.String + QString(RXt[a]); |
RxData.str = RxData.str + string(&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.String = QString(""); |
RxData.str = string(""); |
} |
else |
{ |
RxData.String = RxData.String + Input[z]; |
RxData.str = RxData.str + Input[z].toAscii(); |
} |
} |
} |
195,16 → 195,17 |
if (b_isOpen) |
{ |
QByteArray Temp; |
QString TX_Data; |
string TX_Data; |
if (CMD != '#') |
{ |
TX_Data = ToolBox::Encode64(Data, Length); |
TX_Data = Parser::encode64(Data, Length); |
TX_Data = QString("#") + (QString('a' + Address)) + QString(CMD) + TX_Data; |
TX_Data = ToolBox::add_CRC(TX_Data) + '\r'; |
char addr = 'a' + Address; |
TX_Data = string("#") + (string(&addr)) + string(&CMD) + TX_Data; |
TX_Data = Parser::add_CRC(TX_Data) + '\r'; |
Temp = QByteArray(TX_Data.toUtf8()); |
Temp = QByteArray(TX_Data.c_str()); |
if (Resend) |
{ |
234,7 → 235,7 |
break; |
} |
emit(showTerminal(3, TX_Data)); |
emit(showTerminal(3, QString(TX_Data.c_str()))); |
} |
return true; |
} |
/QMK-Groundstation/branches/own_com_lib/Forms/dlg_MotorMixer.cpp |
---|
68,9 → 68,9 |
} |
// Connection-Object übergeben. |
void dlg_MotorMixer::set_Objects(cConnection *t_Connection, cSettings *t_Settings) |
void dlg_MotorMixer::set_Objects(Handler *handler, cSettings *t_Settings) |
{ |
o_Connection = t_Connection; |
this->handler = handler; |
o_Settings = t_Settings; |
} |
79,7 → 79,7 |
{ |
int Pos = 0; |
MixerName = ToolBox::Data2QString(RX.Decode, 1, 12); |
MixerName = ToolBox::dataToQString(RX.decode, 1, 12); |
Pos = 13; |
87,7 → 87,7 |
{ |
for (int y = 0; y < 4; y++) |
{ |
Motor[z][y] = ToolBox::Data2Char(RX.Decode,Pos); |
Motor[z][y] = Parser::dataToChar(RX.decode,Pos); |
Pos++; |
} |
} |
253,6 → 253,8 |
} |
} |
//FIXME: put this in com/Handler.cpp |
/* |
int dlg_MotorMixer::get_MotorConfig() |
{ |
get_MotorData(); |
280,7 → 282,7 |
{ |
for (int y = 0; y < 4; y++) |
{ |
TX_Data[Pos] = ToolBox::Char2Data(Motor[z][y]); |
TX_Data[Pos] = Parser::charToData(Motor[z][y]); |
Pos++; |
} |
} |
292,19 → 294,22 |
{ |
TX_Data[0] = 0; |
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true); |
} |
}*/ |
// Motordaten auslesen |
// read motor values |
void dlg_MotorMixer::slot_pb_READ() |
{ |
TX_Data[0] = 0; |
o_Connection->send_Cmd('n', ADDRESS_FC, TX_Data, 1, true); |
//send command to get mixer values |
handler->read_mixer(); |
} |
//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,6 → 29,7 |
#include "../typedefs.h" |
//#include "../Classes/ToolBox.h" |
#include "../global.h" |
#include "../com/Handler.h" |
class dlg_MotorMixer : public QDialog, public Ui::dlg_MotorMixer_UI |
{ |
36,25 → 37,24 |
public: |
dlg_MotorMixer(QWidget *parent = 0); |
void set_Objects(cConnection *t_Connection, cSettings *t_Settings); |
void set_Objects(Handler *handler, cSettings *t_Settings); |
void set_MotorConfig(sRxData RX); |
void read_Mixer(); |
private: |
// Object für Kopter-Verbindung |
cConnection *o_Connection; |
//Handler for MK-Communication |
Handler *handler; |
cSettings *o_Settings; |
char TX_Data[150]; |
int Motor[16][4]; |
int Motor[16][4]; //vgl. typedefs.h |
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,7 → 36,6 |
#include "dlg_Preferences.h" |
#include "../global.h" |
#include "../Classes/ToolBox.h" |
#include "../com/Parser.h" |
#include <stdlib.h> |
198,13 → 197,19 |
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(); |
// neuer Logger |
// Logger |
logger = new Logger(Settings, &Mode); |
// LCD-Dialog |
238,13 → 243,14 |
connect(f_Map, SIGNAL(set_WayPoints(QList<sWayPoint>)), this , SLOT(slot_MAP_SetWayPoints(QList<sWayPoint>))); |
// Daten Senden / Empfangen |
connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData))); |
connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString))); |
//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))); |
// Serielle Verbundung öffnen / schließen |
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort())); |
// TCP-Connection verbinden / trennen |
// TCP-Connection for other QMK-Groundstations |
connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect())); |
// Buttons Settings lesen / schreiben |
406,6 → 412,7 |
} |
// 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)) |
453,7 → 460,8 |
abs((double)(Navi.Current.Longitude - desired_pos.Position.Longitude)) < max_radius && |
abs((double)(Navi.Current.Latitude - desired_pos.Position.Latitude)) < max_radius) |
{ |
o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
//FIXME: Put this in com/Handler.cpp |
// o_Connection->send_Cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
} |
else |
{ |
488,10 → 496,11 |
// 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; |
498,38 → 507,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 |
536,22 → 545,13 |
/////////////// |
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,6 → 603,7 |
} |
} |
} |
*/ |
} |
// Zum QMK-Datenserver verbinden |
708,6 → 709,8 |
void MKTool::slot_Motortest(sMotor p_Motor) |
{ |
//FIXME: put this in com/Handler.cpp |
/* |
Motor = p_Motor; |
for (int z = 0; z<12; z++) |
715,13 → 718,14 |
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(o_Connection, Settings); |
f_MotorMixer->read_Mixer(); |
f_MotorMixer->set_Objects(handler, Settings); |
handler->read_mixer(); |
if (f_MotorMixer->exec()==QDialog::Accepted) |
{ |
739,12 → 743,13 |
// 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; |
} |
761,6 → 766,8 |
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; |
797,7 → 804,7 |
o_Connection->send_Cmd('w', ADDRESS_NC, (char *)&WayPoint, sizeof(WayPoint), false); |
// ToolBox::Wait(SLEEP); |
} |
*/ |
} |
void MKTool::slot_MAP_SetTarget(sWayPoint Target) |
954,14 → 961,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; |
} |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
//FIXME: put this in com/Handler.cpp / com/NaviCtrl.cpp |
//o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
} |
970,7 → 978,7 |
if (ac_NoNavi->isChecked()) |
{ |
lb_Status->setText(tr("NaviDaten abstellen.")); |
TX_Data[0] = 0; |
// TX_Data[0] = 0; |
} |
else |
{ |
977,15 → 985,16 |
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; |
} |
} |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
//FIXME: Put this in com/Handler.cpp |
// o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
void MKTool::slot_ac_FastDebug() // DONE 0.71g |
995,14 → 1004,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; |
} |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
//FIXME: Put this in com/Handler.cpp |
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
} |
1012,7 → 1022,7 |
{ |
lb_Status->setText(tr("DebugDaten abstellen.")); |
TickerEvent[3] = false; |
TX_Data[0] = 0; |
//TX_Data[0] = 0; |
} |
else |
{ |
1023,15 → 1033,16 |
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; |
} |
} |
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
//FIXME: Put this in com/Handler.cpp |
// o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
} |
void MKTool::slot_ac_About() |
1042,8 → 1053,9 |
void MKTool::slot_ac_GetLabels() // DONE 0.71g |
{ |
lb_Status->setText(tr("Analoglabels auslesen.")); |
TX_Data[0] = 0; |
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
//FIXME: Put this in com/Handler.cpp |
// TX_Data[0] = 0; |
// o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
} |
void MKTool::slot_ac_StartServer() |
1149,11 → 1161,12 |
Update = new QProcess(); |
if (o_Connection->isOpen()) |
//FIXME: put this in QTCommunication.cpp |
/* if (o_Connection->isOpen()) |
{ |
slot_OpenPort(); |
} |
*/ |
Argumente << "-P"; |
Argumente << le_Port->text(); |
Argumente << "-p"; |
1208,8 → 1221,9 |
{ |
if ((tab_Main->currentWidget()->objectName() == QString("Tab_2")) && (f_Settings->listWidget->currentRow() == 1)) |
{ |
TX_Data[0] = 0; |
o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
// TX_Data[0] = 0; |
//FIXME: Put this in com/Handler.cpp |
// o_Connection->send_Cmd('p', ADDRESS_FC, TX_Data, 0, false); |
Ticker->setInterval(500); |
TickerEvent[1] = true; |
1225,7 → 1239,8 |
// LCD-Seiten weiterschalten |
void MKTool::slot_LCD_UP() // DONE 0.71g |
{ |
if (LCD_Page == LCD_MAX_Page) |
//FIXME: Put this in com/Handler.cpp |
/* if (LCD_Page == LCD_MAX_Page) |
TX_Data[0] = 0; |
else |
TX_Data[0] = LCD_Page + 1; |
1232,10 → 1247,13 |
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 |
1243,6 → 1261,7 |
TX_Data[1] = 0; |
o_Connection->send_Cmd('l', ADDRESS_ALL, TX_Data, 1, true); |
*/ |
} |
// Settings aus MK lesen / in MK schreiben |
1249,18 → 1268,24 |
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); |
*/ |
} |
1510,6 → 1535,8 |
// 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; |
1562,6 → 1589,7 |
Ticker->start(2000); |
} |
} |
*/ |
} |
// Programm beenden |
1569,11 → 1597,13 |
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,7 → 53,9 |
#include "../typedefs.h" |
//quadcopter lib stuff |
#include "../com/Parser.h" |
#include "../com/Handler.h" |
#include "../com/Communication.h" |
#include "../com/QTCommunication.h" |
class QextSerialPort; |
67,8 → 69,12 |
private: |
// Object für Kopter-Verbindung |
cConnection *o_Connection; |
//cConnection *o_Connection; |
Handler *handler; |
Communication *com; |
// Settings-Object (Programmeinstellungen) |
cSettings *Settings; |
137,9 → 143,6 |
// Softwareupdate |
QProcess *Update; |
// Sendedatenbuffer |
char TX_Data[150]; |
// FC-Settings |
int FCSettings[MaxParameter]; |
/QMK-Groundstation/branches/own_com_lib/com/Communication.h |
---|
13,6 → 13,7 |
//connect to MK |
virtual void connectMK(string) {}; |
//send command to MK |
virtual bool sendCmd(char, int, char[150],unsigned int, bool) {}; |
virtual bool sendCmd(char, int, char[150],unsigned int, bool) { return false; }; |
virtual void stopReSend() {}; |
}; |
#endif |
/QMK-Groundstation/branches/own_com_lib/com/Handler.cpp |
---|
11,10 → 11,14 |
* read mixer values from FlightCtrl |
*/ |
void Handler::read_mixer() { |
TX_Data[0] = 0; |
com->send_cmd('n', ADDRESS_FC, TX_Data, 1, true); |
char tx_data[1] = {0}; |
//com->log("read motor mixer"); |
com->sendCmd('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'; |
31,7 → 35,7 |
if (RX.decode[0] == VERSION_MIXER) |
{ |
f_MotorMixer->set_MotorConfig(RX); |
//f_MotorMixer->set_MotorConfig(RX); |
} |
} |
break; |
43,7 → 47,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; |
52,7 → 56,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)); |
59,7 → 63,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 |
66,22 → 70,22 |
case 'Q' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
o_Connection->stop_ReSend(); |
com->stopReSend(); |
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") + |
91,13 → 95,14 |
QString(RX.decode[1]) + |
QString("\nParameterbearbeitung nicht moeglich."); |
QMessageBox::warning(this, QA_NAME, |
name, QMessageBox::Ok); |
name, QMessageBox::Ok);*/ |
} |
} |
break; |
// Settings geschrieben |
// Settings written |
case 'S' : // DONE 0.71g |
o_Connection->stop_ReSend(); |
com->stopReSend(); |
//TODO: QMessagebox("settings written successful") ? |
break; |
} |
108,7 → 113,7 |
case 'O' : // NOT DONE 0.12h |
if (Parser::decode64(RX)) |
{ |
new_NaviData(RX); |
//new_NaviData(RX); |
} |
break; |
} |
121,9 → 126,9 |
case 'L' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
o_Connection->stop_ReSend(); |
com->stopReSend(); |
int LCD[150]; |
/*int LCD[150]; |
memcpy(LCD,RX.decode, sizeof(RX.decode)); |
f_LCD->show_Data(LCD); |
130,6 → 135,7 |
LCD_Page = RX.decode[0]; |
LCD_MAX_Page = RX.decode[1]; |
*/ |
} |
break; |
// Analoglabels |
136,11 → 142,12 |
case 'A' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
o_Connection->stop_ReSend(); |
com->stopReSend(); |
int Position = RX.decode[0]; |
if (Position != 31) |
{ |
/* |
Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
if (Settings->Analog1.Label[Position] == "") |
{ |
148,10 → 155,11 |
} |
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]); |
158,7 → 166,7 |
} |
Settings->Analog1.Version = QString(Mode.Version); |
Settings->write_Settings_AnalogLabels(HardwareID); |
config_Plot(); |
config_Plot();*/ |
} |
} |
break; |
168,9 → 176,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 |
177,8 → 185,8 |
case 'V' : // DONE 0.71h |
if (Parser::decode64(RX)) |
{ |
o_Connection->stop_ReSend(); |
com->stopReSend(); |
/* |
Mode.ID = HardwareID; |
Mode.VERSION_MAJOR = RX.decode[0]; |
Mode.VERSION_MINOR = RX.decode[1]; |
283,7 → 291,7 |
{ |
lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
} |
config_Plot(); |
config_Plot();*/ |
} |
break; |
} |
/QMK-Groundstation/branches/own_com_lib/com/Handler.h |
---|
1,8 → 1,10 |
#ifndef HANDLER_H |
#define HANDLER_H |
#include <string> |
#include <Parser.h> |
#include <Communication.h> |
#include "Parser.h" |
#include "Communication.h" |
#include "Kopter.h" |
#include "../Parameter_Positions.h" |
/** |
* The Handler handels commands that are send from/to the Mikrokopter |
12,10 → 14,14 |
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 |
void Parser::decode64(sRxData &rx) |
bool Parser::decode64(sRxData &rx) |
{ |
int length = rx.str.size(); |
unsigned char a,b,c,d; |
15,8 → 15,10 |
int len = length; |
int decLen = 0; |
if (rx.Input[ptrIn] == 0) { |
throw "Nothing received"; |
if (rx.input[ptrIn] == 0) { |
return false; |
//TODO: catch error to show that something went wrong during the decode process |
//throw "Nothing received"; |
} |
while(len != 0) { |
37,7 → 39,7 |
} |
for (int a=0; a<ptr; a++) { |
if (Long == false) { |
if (length == false) { |
int b1, b2, b3; |
b1 = ptrOut[a++]; |
48,14 → 50,15 |
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 |
67,11 → 70,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)); |
125,11 → 128,11 |
float Parser::getFloat(long value, int count) |
{ |
long num = math.pow(10, count); |
long num = pow(10, count); |
float temp = value; |
return value / num; |
return temp / num; |
} |
string Parser::dataToString(int Data[150], int Start, int End) |
145,10 → 148,11 |
} |
// check CRC |
bool Parser::check_CRC(char * RX, int length) |
bool Parser::check_CRC(string RXstr) |
{ |
int length = RXstr.size(); |
int CRC = 0; |
char *RX; |
char *RX = (char *)RXstr.c_str(); |
if (RX[1] == 127) |
{ |
176,8 → 180,9 |
} |
// add CRC |
string Parser::add_CRC(char * TX, int length) |
string Parser::add_CRC(string TX) |
{ |
int length = TX.size(); |
unsigned int tmpCRC = 0; |
char CRC[2]; |
/QMK-Groundstation/branches/own_com_lib/com/Parser.h |
---|
1,6 → 1,7 |
#ifndef PARSER_H |
#define PARSER_H |
#include <string> |
#include <cmath> |
/** |
* The Parser gets values from the Mikrokopter-USART interface |
7,6 → 8,8 |
* and parses them into a sRxData-Struct |
*/ |
using namespace std; |
struct sRxData |
{ |
char *input; |
20,8 → 23,8 |
static bool decode64(sRxData &rx); |
static string encode64(char data[150],unsigned int length); |
static string add_CRC(char * TX, int length); |
static string check_CRC(char * RX, int length); |
static string add_CRC(string TX); |
static bool check_CRC(string RX); |
static float getFloat(long value, int count); |
/QMK-Groundstation/branches/own_com_lib/com/QTCommunication.cpp |
---|
6,4 → 6,8 |
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,9 → 10,12 |
* ( 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/com.pri |
---|
0,0 → 1,15 |
DEPENDPATH += com |
INCLUDEPATH += com |
MOC_DIR = tmp |
OBJECTS_DIR = obj |
# Input |
HEADERS += Communication.h \ |
Handler.h \ |
Kopter.h \ |
Parser.h \ |
QTCommunication.h |
SOURCES += Handler.cpp \ |
Parser.cpp \ |
QTCommunication.cpp |
QT += network |
/QMK-Groundstation/branches/own_com_lib/eeepc.pro |
---|
1,4 → 1,5 |
include(QMapControl.pri) |
include(com.pri) |
DEFINES += _TTY_POSIX_ _EEEPC_ |
6,8 → 7,4 |
LIBS += -lqwt-qt4 |
INCLUDEPATH += $(HOME)/include /usr/include/qwt-qt4 |
include(global.pri)HEADERS += com/Handler.h com/Parser.h com/Kopter.h \ |
com/Communication.h \ |
com/QTCommunication.h |
SOURCES += com/QTCommunication.cpp |
include(global.pri) |
/QMK-Groundstation/branches/own_com_lib/groundstation.kdevelop |
---|
0,0 → 1,223 |
<?xml version = '1.0'?> |
<kdevelop> |
<general> |
<author/> |
<email/> |
<version>own_lib_branch</version> |
<projectmanagement>KDevTrollProject</projectmanagement> |
<primarylanguage>C++</primarylanguage> |
<keywords> |
<keyword>Mikrokopter</keyword> |
<keyword>Quadcopter</keyword> |
<keyword>C++</keyword> |
<keyword>QT</keyword> |
</keywords> |
<versioncontrol>kdevsubversion</versioncontrol> |
<ignoreparts/> |
<projectname>QMKGroundStation</projectname> |
<projectdirectory>.</projectdirectory> |
<absoluteprojectpath>false</absoluteprojectpath> |
<description/> |
<defaultencoding/> |
</general> |
<kdevfileview> |
<groups> |
<group pattern="*.cpp;*.cxx;*.h" name="Sources" /> |
<group pattern="*.ui" name="User Interface" /> |
<group pattern="*.png" name="Icons" /> |
<group pattern="*" name="Others" /> |
<hidenonprojectfiles>false</hidenonprojectfiles> |
<hidenonlocation>false</hidenonlocation> |
</groups> |
<tree> |
<hidenonprojectfiles>false</hidenonprojectfiles> |
<hidepatterns>*.o,*.lo,CVS</hidepatterns> |
<showvcsfields>false</showvcsfields> |
</tree> |
</kdevfileview> |
<kdevcppsupport> |
<qt> |
<used>true</used> |
<version>4</version> |
<includestyle>4</includestyle> |
<designerintegration>ExternalDesigner</designerintegration> |
<qmake>/usr/bin/qmake-qt4</qmake> |
<designer>/usr/bin/designer-qt4</designer> |
<root>/usr/lib/qt4</root> |
<designerpluginpaths/> |
</qt> |
<references/> |
<codecompletion> |
<automaticCodeCompletion>false</automaticCodeCompletion> |
<automaticArgumentsHint>true</automaticArgumentsHint> |
<automaticHeaderCompletion>true</automaticHeaderCompletion> |
<codeCompletionDelay>250</codeCompletionDelay> |
<argumentsHintDelay>400</argumentsHintDelay> |
<headerCompletionDelay>250</headerCompletionDelay> |
<showOnlyAccessibleItems>false</showOnlyAccessibleItems> |
<completionBoxItemOrder>0</completionBoxItemOrder> |
<howEvaluationContextMenu>true</howEvaluationContextMenu> |
<showCommentWithArgumentHint>true</showCommentWithArgumentHint> |
<statusBarTypeEvaluation>false</statusBarTypeEvaluation> |
<namespaceAliases>std=_GLIBCXX_STD;__gnu_cxx=std</namespaceAliases> |
<processPrimaryTypes>true</processPrimaryTypes> |
<processFunctionArguments>false</processFunctionArguments> |
<preProcessAllHeaders>false</preProcessAllHeaders> |
<parseMissingHeadersExperimental>false</parseMissingHeadersExperimental> |
<resolveIncludePathsUsingMakeExperimental>false</resolveIncludePathsUsingMakeExperimental> |
<alwaysParseInBackground>true</alwaysParseInBackground> |
<usePermanentCaching>true</usePermanentCaching> |
<alwaysIncludeNamespaces>false</alwaysIncludeNamespaces> |
<includePaths>.;</includePaths> |
</codecompletion> |
<creategettersetter> |
<prefixGet/> |
<prefixSet>set</prefixSet> |
<prefixVariable>m_,_</prefixVariable> |
<parameterName>theValue</parameterName> |
<inlineGet>true</inlineGet> |
<inlineSet>true</inlineSet> |
</creategettersetter> |
<splitheadersource> |
<enabled>false</enabled> |
<synchronize>true</synchronize> |
<orientation>Vertical</orientation> |
</splitheadersource> |
</kdevcppsupport> |
<kdevdoctreeview> |
<ignoretocs> |
<toc>bash</toc> |
<toc>bash_bugs</toc> |
<toc>clanlib</toc> |
<toc>fortran_bugs_gcc</toc> |
<toc>gnome1</toc> |
<toc>gnustep</toc> |
<toc>gtk</toc> |
<toc>gtk_bugs</toc> |
<toc>haskell</toc> |
<toc>haskell_bugs_ghc</toc> |
<toc>java_bugs_gcc</toc> |
<toc>java_bugs_sun</toc> |
<toc>kde2book</toc> |
<toc>opengl</toc> |
<toc>pascal_bugs_fp</toc> |
<toc>php</toc> |
<toc>php_bugs</toc> |
<toc>perl</toc> |
<toc>perl_bugs</toc> |
<toc>python</toc> |
<toc>python_bugs</toc> |
<toc>qt-kdev3</toc> |
<toc>ruby</toc> |
<toc>ruby_bugs</toc> |
<toc>sdl</toc> |
<toc>stl</toc> |
<toc>sw</toc> |
<toc>w3c-dom-level2-html</toc> |
<toc>w3c-svg</toc> |
<toc>w3c-uaag10</toc> |
<toc>wxwidgets_bugs</toc> |
</ignoretocs> |
<ignoredoxygen> |
<toc>KDE Libraries (Doxygen)</toc> |
</ignoredoxygen> |
</kdevdoctreeview> |
<kdevdebugger> |
<general> |
<dbgshell/> |
<breakpoints/> |
<programargs/> |
<gdbpath>/usr/bin/gdb</gdbpath> |
<breakonloadinglibs>true</breakonloadinglibs> |
<separatetty>false</separatetty> |
<floatingtoolbar>false</floatingtoolbar> |
<configGdbScript/> |
<runShellScript/> |
<runGdbScript/> |
<raiseGDBOnStart>false</raiseGDBOnStart> |
</general> |
<display> |
<staticmembers>false</staticmembers> |
<demanglenames>true</demanglenames> |
<outputradix>10</outputradix> |
</display> |
<breakpoints/> |
</kdevdebugger> |
<kdevtrollproject> |
<run> |
<mainprogram>/home/andreas/uni/Mikrokopter/QMK-Groundstation/branches/own_com_lib/build/bin/QMK-Groundstation</mainprogram> |
<programargs/> |
<directoryradio>executable</directoryradio> |
<globaldebugarguments/> |
<globalcwd>.</globalcwd> |
<useglobalprogram>true</useglobalprogram> |
<terminal>false</terminal> |
<autocompile>false</autocompile> |
<autoinstall>false</autoinstall> |
<autokdesu>false</autokdesu> |
<envvars/> |
</run> |
<general> |
<activedir></activedir> |
</general> |
<make> |
<abortonerror>true</abortonerror> |
<runmultiplejobs>false</runmultiplejobs> |
<numberofjobs>1</numberofjobs> |
<dontact>false</dontact> |
<makebin/> |
<prio>0</prio> |
<envvars/> |
</make> |
<qmake> |
<savebehaviour>2</savebehaviour> |
<replacePaths>false</replacePaths> |
<disableDefaultOpts>true</disableDefaultOpts> |
<enableFilenamesOnly>false</enableFilenamesOnly> |
<showVariablesInTree>true</showVariablesInTree> |
<showParseErrors>true</showParseErrors> |
<projectfile>/home/andreas/uni/Mikrokopter/QMK-Groundstation/branches/own_com_lib/eeepc.pro</projectfile> |
</qmake> |
</kdevtrollproject> |
<workspace> |
<openfiles/> |
</workspace> |
<kdevfilecreate> |
<filetypes/> |
<useglobaltypes> |
<type ext="ui" /> |
<type ext="qrc" /> |
<type ext="cpp" /> |
<type ext="h" /> |
<type ext="ts" /> |
</useglobaltypes> |
</kdevfilecreate> |
<kdevdocumentation> |
<projectdoc> |
<docsystem>Doxygen Documentation Collection</docsystem> |
<docurl>QMKGroundStation.tag</docurl> |
<usermanualurl/> |
</projectdoc> |
</kdevdocumentation> |
<substmap> |
<APPNAME>QMKGroundStation</APPNAME> |
<APPNAMELC>QMKGroundStation</APPNAMELC> |
<APPNAMESC>QMKGroundStation</APPNAMESC> |
<APPNAMEUC>QMKGROUNDSTATION</APPNAMEUC> |
<AUTHOR/> |
<DESIGNER/> |
<EMAIL>user@localhost</EMAIL> |
<LICENSE>GPL</LICENSE> |
<LICENSEFILE>COPYING</LICENSEFILE> |
<QMAKE/> |
<VERSION>own_lib_branch</VERSION> |
<YEAR>2009</YEAR> |
<dest>branches/own_com_lib</dest> |
</substmap> |
<cppsupportpart> |
<filetemplates> |
<interfacesuffix>.h</interfacesuffix> |
<implementationsuffix>.cpp</implementationsuffix> |
</filetemplates> |
</cppsupportpart> |
</kdevelop> |
/QMK-Groundstation/branches/own_com_lib |
---|
Property changes: |
Added: svn:ignore |
+Doxyfile |
+groundstation.kdevses |
+Makefile |
+build |
+svn-prop.tmp |
+QMKGroundStation.kdevelop.pcs |