82,7 → 82,7 |
} |
|
/** |
* send a waypoint to the NaviCtrl (the copter will fly to the position emidiately) |
* send a waypoint to the NaviCtrl (the MikroKopter will fly to the position emidiately) |
*/ |
void Handler::send_waypoint(Waypoint_t desired_pos) { |
com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
189,281 → 189,252 |
/** |
* receive data |
*/ |
void Handler::receive_data(sRxData RX) { |
//extract hardware ID from received Data |
int hardwareID = RX.input[1] - 'a'; |
//Parser::decode64(data); |
void Handler::receive_data(int hardwareID, int cmd, char * data) { |
switch(hardwareID) |
{ |
case ADDRESS_FC : |
switch(RX.input[2]) |
switch(cmd) |
{ |
// Motor-Mixer |
case 'N' : |
if (Parser::decode64(RX)) |
{ |
//if (Parser::decode64(RX)) |
//{ |
com->stop_resend(); |
|
if (RX.decode[0] == VERSION_MIXER) |
//decoded data |
if (data[0] == VERSION_MIXER) |
{ |
//f_MotorMixer->set_MotorConfig(RX); |
} |
} |
break; |
//} |
break; |
// Motor-Mixer Schreib-Bestätigung |
case 'M' : |
if (Parser::decode64(RX)) |
com->stop_resend(); |
|
if (data[0] == 1) |
{ |
com->stop_resend(); |
|
if (RX.decode[0] == 1) |
{ |
//lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
} |
//lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
} |
break; |
break; |
|
// Stick-Belegung der Fernsteuerung |
case 'P' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
/*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)); |
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));*/ |
} |
break; |
/*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)); |
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));*/ |
break; |
// Settings lesen |
case 'Q' : // DONE 0.71g |
if (Parser::decode64(RX)) |
com->stop_resend(); |
|
if (data[1] == VERSION_SETTINGS) |
{ |
com->stop_resend(); |
|
if (RX.decode[1] == VERSION_SETTINGS) |
int Settings_ID = data[0]; |
/*for (int a = 0; a < MaxParameter; a++) |
{ |
int Settings_ID = RX.decode[0]; |
/*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);*/ |
FCSettings[a] = RX.decode[a + 2]; |
} |
else |
{ |
/*f_Settings->pb_Read->setDisabled(true); |
f_Settings->pb_Write->setDisabled(true); |
f_Settings->show_FCSettings(Settings_ID, FCSettings); |
f_Settings->pb_Read->setEnabled(true); |
f_Settings->pb_Write->setEnabled(true);*/ |
} |
else |
{ |
/*f_Settings->pb_Read->setDisabled(true); |
f_Settings->pb_Write->setDisabled(true); |
|
QString name = QString("Versionen inkompatibel.\n") + |
QString("Version von GroundStation benoetigt: ") + |
QString(VERSION_SETTINGS) + |
QString("\nVersion auf der FlightCtrl: ") + |
QString(RX.decode[1]) + |
QString("\nParameterbearbeitung nicht moeglich."); |
QMessageBox::warning(this, QA_NAME, |
name, QMessageBox::Ok);*/ |
} |
QString name = QString("Versionen inkompatibel.\n") + |
QString("Version von GroundStation benoetigt: ") + |
QString(VERSION_SETTINGS) + |
QString("\nVersion auf der FlightCtrl: ") + |
QString(RX.decode[1]) + |
QString("\nParameterbearbeitung nicht moeglich."); |
QMessageBox::warning(this, QA_NAME, |
name, QMessageBox::Ok);*/ |
} |
break; |
break; |
// Settings written |
case 'S' : // DONE 0.71g |
com->stop_resend(); |
//TODO: QMessagebox("settings written successful") ? |
break; |
break; |
} |
|
case ADDRESS_NC : |
switch(RX.input[2]) |
switch(cmd) |
{ |
// Navigationsdaten |
case 'O' : // NOT DONE 0.12h |
if (Parser::decode64(RX)) |
{ |
//new_NaviData(RX); |
} |
break; |
//new_NaviData(RX); |
break; |
} |
// case ADDRESS_MK3MAG : |
|
default : |
switch(RX.input[2]) |
switch(cmd) |
{ |
// LCD-Anzeige |
case 'L' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
com->stop_resend(); |
com->stop_resend(); |
|
/*int LCD[150]; |
memcpy(LCD,RX.decode, sizeof(RX.decode)); |
/*int LCD[150]; |
memcpy(LCD,RX.decode, sizeof(RX.decode)); |
|
f_LCD->show_Data(LCD); |
f_LCD->show_Data(LCD); |
|
LCD_Page = RX.decode[0]; |
LCD_MAX_Page = RX.decode[1]; |
*/ |
} |
break; |
LCD_Page = RX.decode[0]; |
LCD_MAX_Page = RX.decode[1]; |
*/ |
break; |
// Analoglabels |
case 'A' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
com->stop_resend(); |
com->stop_resend(); |
|
int Position = RX.decode[0]; |
if (Position != 31) |
//check position |
if (data[0] != 31) { |
/* |
Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
if (Settings->Analog1.Label[Position] == "") |
{ |
/* |
Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
if (Settings->Analog1.Label[Position] == "") |
{ |
Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
} |
Position ++; |
TX_Data[0] = Position; |
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
} |
if (Position == 31) |
Position ++; |
TX_Data[0] = Position; |
o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
} else { |
/* |
for (int a = 0; a < MaxAnalog; a++) |
{ |
/* |
for (int a = 0; a < MaxAnalog; a++) |
{ |
lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
} |
Settings->Analog1.Version = QString(Mode.Version); |
Settings->write_Settings_AnalogLabels(HardwareID); |
config_Plot();*/ |
lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
} |
Settings->Analog1.Version = QString(Mode.Version); |
Settings->write_Settings_AnalogLabels(HardwareID); |
config_Plot();*/ |
} |
break; |
break; |
// Debug-Daten |
case 'D' : // DONE 0.71g |
if (Parser::decode64(RX)) |
{ |
for (int i = 0; i < MaxAnalog; i++) |
{ |
//AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
} |
//show_DebugData(); |
for (int i = 0; i < MaxAnalog; i++) { |
//AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
} |
break; |
//show_DebugData(); |
break; |
// Version |
case 'V' : // DONE 0.71h |
if (Parser::decode64(RX)) |
{ |
com->stop_resend(); |
/* |
Mode.ID = HardwareID; |
Mode.VERSION_MAJOR = RX.decode[0]; |
Mode.VERSION_MINOR = RX.decode[1]; |
Mode.VERSION_PATCH = RX.decode[4]; |
Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
com->stop_resend(); |
/* |
Mode.ID = HardwareID; |
Mode.VERSION_MAJOR = RX.decode[0]; |
Mode.VERSION_MINOR = RX.decode[1]; |
Mode.VERSION_PATCH = RX.decode[4]; |
Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
|
Mode.Hardware = HardwareType[Mode.ID]; |
//TODO: Funktion im Handler get_version() oder sowas |
QString version = QString("%1").arg(RX.decode[0]) + "." + |
QString("%1").arg(RX.decode[1]) + |
QString(RX.decode[4] + 'a'); |
Mode.Version = version.toLatin1().data; |
setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
Mode.Hardware + " " + |
Mode.Version); |
Mode.Hardware = HardwareType[Mode.ID]; |
//TODO: Funktion im Handler get_version() oder sowas |
QString version = QString("%1").arg(RX.decode[0]) + "." + |
QString("%1").arg(RX.decode[1]) + |
QString(RX.decode[4] + 'a'); |
Mode.Version = version.toLatin1().data; |
setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
Mode.Hardware + " " + |
Mode.Version); |
|
if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
{ |
if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
{ |
// AllowSend = false; |
QMessageBox::warning(this, QA_NAME, |
tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
} |
QMessageBox::warning(this, QA_NAME, |
tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
} |
|
if (ac_NoDebug->isChecked()) |
if (ac_NoDebug->isChecked()) |
{ |
TX_Data[0] = 0; |
} |
else |
if (ac_FastDebug->isChecked()) |
{ |
TX_Data[0] = Settings->Data.Debug_Fast / 10; |
} |
else |
{ |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
} |
|
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
|
// Wenn MK3MAG dann andauernd Daten neu anfragen. |
if (Mode.ID == ADDRESS_MK3MAG) |
{ |
TickerEvent[3] = true; |
rb_SelMag->setChecked(true); |
} |
|
// Wenn NaviCtrl dann hier. |
if (Mode.ID == ADDRESS_NC) |
{ |
rb_SelNC->setChecked(true); |
|
if (ac_NoNavi->isChecked()) |
{ |
TX_Data[0] = 0; |
} |
else |
if (ac_FastDebug->isChecked()) |
if (ac_FastNavi->isChecked()) |
{ |
TX_Data[0] = Settings->Data.Debug_Fast / 10; |
TX_Data[0] = Settings->Data.Navi_Fast / 10; |
} |
else |
{ |
TX_Data[0] = Settings->Data.Debug_Slow / 10; |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
|
o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
|
// Wenn MK3MAG dann andauernd Daten neu anfragen. |
if (Mode.ID == ADDRESS_MK3MAG) |
{ |
TickerEvent[3] = true; |
rb_SelMag->setChecked(true); |
} |
|
// Wenn NaviCtrl dann hier. |
if (Mode.ID == ADDRESS_NC) |
// Wenn FlightCtrl dann Settings abfragen. |
if (Mode.ID == ADDRESS_FC) |
{ |
rb_SelFC->setChecked(true); |
{ |
rb_SelNC->setChecked(true); |
TX_Data[0] = 0xff; |
TX_Data[1] = 0; |
|
if (ac_NoNavi->isChecked()) |
{ |
TX_Data[0] = 0; |
} |
else |
if (ac_FastNavi->isChecked()) |
{ |
TX_Data[0] = Settings->Data.Navi_Fast / 10; |
} |
else |
{ |
TX_Data[0] = Settings->Data.Navi_Slow / 10; |
} |
|
o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
} |
|
|
// Wenn FlightCtrl dann Settings abfragen. |
if (Mode.ID == ADDRESS_FC) |
{ |
rb_SelFC->setChecked(true); |
{ |
TX_Data[0] = 0xff; |
TX_Data[1] = 0; |
|
// DEP: Raus wenn Resend implementiert. |
// DEP: Raus wenn Resend implementiert. |
// ToolBox::Wait(SLEEP); |
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
qDebug("FC - Get Settings"); |
} |
o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
qDebug("FC - Get Settings"); |
} |
// Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
else |
{ |
f_Settings->pb_Read->setDisabled(true); |
f_Settings->pb_Write->setDisabled(true); |
} |
} |
// Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
else |
{ |
f_Settings->pb_Read->setDisabled(true); |
f_Settings->pb_Write->setDisabled(true); |
} |
|
Settings->read_Settings_Analog(HardwareID); |
Settings->read_Settings_AnalogLabels(HardwareID); |
Settings->read_Settings_Analog(HardwareID); |
Settings->read_Settings_AnalogLabels(HardwareID); |
|
if (Settings->Analog1.Version != QString(Mode.Version)) |
{ |
lb_Status->setText(tr("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.")); |
slot_ac_GetLabels(); |
} |
else |
for (int a = 0; a < MaxAnalog; a++) |
{ |
lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
} |
config_Plot();*/ |
if (Settings->Analog1.Version != QString(Mode.Version)) |
{ |
lb_Status->setText(tr("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.")); |
slot_ac_GetLabels(); |
} |
break; |
else |
for (int a = 0; a < MaxAnalog; a++) |
{ |
lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
} |
config_Plot();*/ |
break; |
} |
} |
} |