Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 500 → Rev 499

/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];