1,5 → 1,5 |
#include "Handler.h" |
#include <iostream> |
#include "FlightLog.h" |
|
/** |
* Constructor that gets a communication instance |
190,8 → 190,20 |
/** |
* receive data |
*/ |
//Parser::decode64(data); |
void Handler::receive_data(int hardwareID, int cmd, char * 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); |
|
switch(hardwareID) |
{ |
case ADDRESS_FC : |
203,6 → 215,7 |
//{ |
com->stop_resend(); |
//decoded data |
FlightLog::info("received motortest values from FlightCtrl"); |
if (data[0] == VERSION_MIXER) |
{ |
//f_MotorMixer->set_MotorConfig(RX); |
215,12 → 228,16 |
|
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)); |
233,7 → 250,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]; |
247,6 → 264,7 |
} |
else |
{ |
FlightLog::error("wrong FlightCtrl version"); |
/*f_Settings->pb_Read->setDisabled(true); |
f_Settings->pb_Write->setDisabled(true); |
|
263,6 → 281,7 |
// Settings written |
case 'S' : // DONE 0.71g |
com->stop_resend(); |
FlightLog::info("settings written successfully to FlightCtrl"); |
//TODO: QMessagebox("settings written successful") ? |
break; |
} |
273,6 → 292,7 |
// Navigationsdaten |
case 'O' : // NOT DONE 0.12h |
//new_NaviData(RX); |
FlightLog::info("received navigation data from NaviCtrl"); |
break; |
} |
// case ADDRESS_MK3MAG : |
283,7 → 303,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)); |
|
296,7 → 316,7 |
// Analoglabels |
case 'A' : // DONE 0.71g |
com->stop_resend(); |
|
FlightLog::info("received analog labels"); |
//check position |
if (data[0] != 31) { |
/* |
321,8 → 341,11 |
break; |
// Debug-Daten |
case 'D' : // DONE 0.71g |
FlightLog::info("received debug data:"); |
for (int i = 0; i < MaxAnalog; i++) { |
std::cout << Parser::dataToInt(data, (i * 2) + 2) << std::endl; |
/* |
Parser::dataToInt((char *)data, (i * 2) + 2, false); |
*/ |
} |
//show_DebugData(); |
break; |
329,6 → 352,7 |
// Version |
case 'V' : // DONE 0.71h |
com->stop_resend(); |
FlightLog::info("received version"); |
/* |
Mode.ID = HardwareID; |
Mode.VERSION_MAJOR = RX.decode[0]; |