Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 500 → Rev 499

/QMK-Groundstation/branches/libMK/Forms/mktool.cpp
60,7 → 60,7
setWindowTitle(QA_NAME + " v" + QA_VERSION);
 
// Tab mit Debug-Elementen verbergen
//tab_Main->removeTab(6);
tab_Main->removeTab(6);
 
// Develop - Nicht gebrauchte sachen abschalten.
pb_SettingsReset->hide();
202,7 → 202,7
data = new KopterData();
 
//new QT-Communication object
com = new QTSerialCommunication(handler);
com = new QTSerialCommunication();
 
//create handler that handles incomming data
handler = new Handler(com, data);
249,10 → 249,10
// connect(o_Connection, SIGNAL(newData(sRxData)), this, SLOT(slot_newData(sRxData)));
// connect(o_Connection, SIGNAL(showTerminal(int, QString)), this, SLOT(slot_showTerminal(int, QString)));
 
// click on button to open/close serial connection
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_serial_connect()));
// Serielle Verbundung öffnen / schließen
connect(ac_ConnectTTY, SIGNAL(triggered()), this, SLOT(slot_OpenPort()));
 
// clock on button for the TCP-Connection to other QMK-Groundstations
// TCP-Connection for other QMK-Groundstations
connect(ac_QMKServer, SIGNAL(triggered()), this, SLOT(slot_QMKS_Connect()));
 
// Buttons Settings lesen / schreiben
568,6 → 568,8
///////////////
/*void MKTool::slot_Ticker()
{
 
 
if (TickerDiv)
TickerDiv = false;
else
1478,23 → 1480,10
}
}
 
// connect to MK
void MKTool::slot_serial_connect()
// Verbindung zum Kopter herstellen / Trennen
void MKTool::slot_OpenPort()
{
//connect to Mikrokopter
com->connect_MK(le_Port->text().toAscii().data());
//TODO: check, if connection really is established
ac_ConnectTTY->setText(tr("Kopter Trennen"));
 
le_Port->setEnabled(false);
 
//send command to get version of MK
handler->get_version();
 
//TODO: Ticker->start(2000);
//TODO: disconnect
 
//FIXME: Put this in libMK/QTCommunication.cpp
//FIXME: Put this in libMK/QTCommunication.cpp
/*
if (o_Connection->isOpen())
{
/QMK-Groundstation/branches/libMK/Forms/mktool.h
214,8 → 214,7
 
// Seriell-Port Slots
// void slot_newData(sRxData RX);
//connect to serial port
void slot_serial_connect();
void slot_OpenPort();
 
void slot_TabChanged(int Tab);
 
/QMK-Groundstation/branches/libMK/eeepc.pro
8,7 → 8,3
INCLUDEPATH += $(HOME)/include /usr/include/qwt-qt4
 
include(global.pri)
HEADERS += libMK/FlightLog.h
 
SOURCES += libMK/FlightLog.cpp
 
/QMK-Groundstation/branches/libMK/libMK/FlightLog.cpp
File deleted
\ No newline at end of file
/QMK-Groundstation/branches/libMK/libMK/Colors.h
File deleted
/QMK-Groundstation/branches/libMK/libMK/FlightLog.h
File deleted
\ No newline at end of file
/QMK-Groundstation/branches/libMK/libMK/Communication.cpp
10,4 → 10,4
 
void Communication::connection_lost() {
connected = false;
}
}
/QMK-Groundstation/branches/libMK/libMK/Handler.cpp
1,5 → 1,5
#include "Handler.h"
#include "FlightLog.h"
#include <iostream>
 
/**
* Constructor that gets a communication instance
190,20 → 190,8
/**
* receive data
*/
void Handler::receive_data(char * incomming, int length) {
if (incomming[0] != '#')
FlightLog::error("this frame is not correct");
FlightLog::info(incomming);
return;
int hardwareID = incomming[1] - 'a';
 
//The cmd is also known as ID-Byte (or ID for short) in the wiki-dokumentation
char cmd = incomming[2];
//decode data
unsigned char data[150];
 
Parser::decode64(incomming, length, data, 3);
 
//Parser::decode64(data);
void Handler::receive_data(int hardwareID, int cmd, char * data) {
switch(hardwareID)
{
case ADDRESS_FC :
215,7 → 203,6
//{
com->stop_resend();
//decoded data
FlightLog::info("received motortest values from FlightCtrl");
if (data[0] == VERSION_MIXER)
{
//f_MotorMixer->set_MotorConfig(RX);
228,16 → 215,12
 
if (data[0] == 1)
{
FlightLog::info("motor values written to FlightCtrl.");
//lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben."));
} else {
FlightLog::warning("could not write motor values to FlightCtrl!");
}
break;
 
// Stick-Belegung der Fernsteuerung
case 'P' : // DONE 0.71g
FlightLog::info("received stick-settings from FlightCtrl:");
/*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));
250,7 → 233,7
// Settings lesen
case 'Q' : // DONE 0.71g
com->stop_resend();
FlightLog::info("received settings from FlightCtrl");
 
if (data[1] == VERSION_SETTINGS)
{
int Settings_ID = data[0];
264,7 → 247,6
}
else
{
FlightLog::error("wrong FlightCtrl version");
/*f_Settings->pb_Read->setDisabled(true);
f_Settings->pb_Write->setDisabled(true);
 
281,7 → 263,6
// Settings written
case 'S' : // DONE 0.71g
com->stop_resend();
FlightLog::info("settings written successfully to FlightCtrl");
//TODO: QMessagebox("settings written successful") ?
break;
}
292,7 → 273,6
// Navigationsdaten
case 'O' : // NOT DONE 0.12h
//new_NaviData(RX);
FlightLog::info("received navigation data from NaviCtrl");
break;
}
// case ADDRESS_MK3MAG :
303,7 → 283,7
// LCD-Anzeige
case 'L' : // DONE 0.71g
com->stop_resend();
FlightLog::info("received LCD page.");
 
/*int LCD[150];
memcpy(LCD,RX.decode, sizeof(RX.decode));
 
316,7 → 296,7
// Analoglabels
case 'A' : // DONE 0.71g
com->stop_resend();
FlightLog::info("received analog labels");
 
//check position
if (data[0] != 31) {
/*
341,11 → 321,8
break;
// Debug-Daten
case 'D' : // DONE 0.71g
FlightLog::info("received debug data:");
for (int i = 0; i < MaxAnalog; i++) {
/*
Parser::dataToInt((char *)data, (i * 2) + 2, false);
*/
std::cout << Parser::dataToInt(data, (i * 2) + 2) << std::endl;
}
//show_DebugData();
break;
352,7 → 329,6
// Version
case 'V' : // DONE 0.71h
com->stop_resend();
FlightLog::info("received version");
/*
Mode.ID = HardwareID;
Mode.VERSION_MAJOR = RX.decode[0];
/QMK-Groundstation/branches/libMK/libMK/Handler.h
53,7 → 53,7
void get_version();
void get_ppm_channels();
 
void receive_data(char * incomming, int length);
void receive_data(int hardwareID, int cmd, char * data);
};
 
#endif
/QMK-Groundstation/branches/libMK/libMK/QTSerialCommunication.cpp
1,14 → 1,11
#include "QTSerialCommunication.h"
#include "../libMK/Parser.h"
#include "../Classes/ToolBox.h"
#include <iostream>
 
 
/**
* initiate connection and stuff
*/
QTSerialCommunication::QTSerialCommunication(Handler * handler) {
this->handler = handler;
QTSerialCommunication::QTSerialCommunication() {
connection_lost();
serial = new ManageSerialPort();
serial->setBaudRate(BAUD57600); //BaudRate
34,7 → 31,6
timeout--;
if (serial->isOpen()) {
serial->receiveData();
connect(serial, SIGNAL(newDataReceived(const QByteArray &)), this, SLOT(slot_received_data(const QByteArray &)));
connection_established();
//break while loop
return;
55,12 → 51,10
if (is_connected()) {
Parser::create_frame(cmd, address, data, length);
if (resend) {
//resend every 2 seconds
//resend evrey 2 seconds
resendTimer.start(2000);
resendData = data;
}
//TODO: save outgoing data for debug purpose
std::cout << "send: " << data << std::endl;
QByteArray temp(data);
serial->sendData(temp);
} else {
73,7 → 67,7
* stop timer
*/
void QTSerialCommunication::stop_resend() {
resendTimer.stop();
};
 
/**
82,23 → 76,5
void QTSerialCommunication::slot_resend_timer() {
}
 
/**
* get incomming data from QT-Serial-Manager
* and just give it to the handler.
*/
void QTSerialCommunication::slot_received_data(const QByteArray & data) {
received_data((char *)data.data(), data.length());
}
 
/**
* handel received data
*/
void QTSerialCommunication::received_data(char * data, int length) {
//Debug: print oud debug data
//TODO: save data in a file for debug purposes
std::cout << "receive: " << data << std::endl;
//handle incomming data
//FIXME: HIER! Hardware-Id = Mode.id
 
handler->receive_data(data, length);
void QTSerialCommunication::received_data(char * data) {
}
/QMK-Groundstation/branches/libMK/libMK/QTSerialCommunication.h
3,7 → 3,6
#include <QObject>
#include <QTimer>
#include "Communication.h"
#include "Handler.h"
#include "../SerialPort/ManageSerialPort.h"
 
/**
18,7 → 17,6
Q_OBJECT
 
private:
Handler * handler;
//timer to resend data if necessary
QTimer resendTimer;
//data that will be resended if the timer
29,11 → 27,10
ManageSerialPort * serial;
private slots:
void slot_resend_timer();
void slot_received_data(const QByteArray & data);
public:
QTSerialCommunication(Handler * handler);
QTSerialCommunication();
void connect_MK(char * addr);
void received_data(char * data, int length);
void received_data(char * data);
void send_cmd(char cmd, int address, char data[150], unsigned int length, bool resend);
void stop_resend();
};