Rev 392 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 392 | Rev 393 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | * read mixer values from FlightCtrl |
11 | * read mixer values from FlightCtrl |
12 | */ |
12 | */ |
13 | void Handler::read_mixer() { |
13 | void Handler::read_mixer() { |
14 | TX_Data[0] = 0; |
14 | TX_Data[0] = 0; |
15 | com->send_cmd('n', ADDRESS_FC, TX_Data, 1, true); |
15 | com->send_cmd('n', ADDRESS_FC, TX_Data, 1, true); |
- | 16 | } |
|
- | 17 | ||
- | 18 | void Handler::receive_data(sRxData RX) { |
|
- | 19 | //extract hardware ID from received Data |
|
- | 20 | int hardwareID = RX.input[1] - 'a'; |
|
- | 21 | switch(hardwareID) |
|
- | 22 | { |
|
- | 23 | case ADDRESS_FC : |
|
- | 24 | switch(RX.input[2]) |
|
- | 25 | { |
|
- | 26 | // Motor-Mixer |
|
- | 27 | case 'N' : |
|
- | 28 | if (Parser::decode64(RX)) |
|
- | 29 | { |
|
- | 30 | com->stopReSend(); |
|
- | 31 | ||
- | 32 | if (RX.decode[0] == VERSION_MIXER) |
|
- | 33 | { |
|
- | 34 | f_MotorMixer->set_MotorConfig(RX); |
|
- | 35 | } |
|
- | 36 | } |
|
- | 37 | break; |
|
- | 38 | // Motor-Mixer Schreib-Bestätigung |
|
- | 39 | case 'M' : |
|
- | 40 | if (Parser::decode64(RX)) |
|
- | 41 | { |
|
- | 42 | com->stopReSend(); |
|
- | 43 | ||
- | 44 | if (RX.decode[0] == 1) |
|
- | 45 | { |
|
- | 46 | lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
|
- | 47 | } |
|
- | 48 | } |
|
- | 49 | break; |
|
- | 50 | ||
- | 51 | // Stick-Belegung der Fernsteuerung |
|
- | 52 | case 'P' : // DONE 0.71g |
|
- | 53 | if (Parser::decode64(RX)) |
|
- | 54 | { |
|
- | 55 | f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true)); |
|
- | 56 | f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true)); |
|
- | 57 | f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true)); |
|
- | 58 | f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true)); |
|
- | 59 | f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true)); |
|
- | 60 | f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true)); |
|
- | 61 | f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true)); |
|
- | 62 | f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true)); |
|
- | 63 | } |
|
- | 64 | break; |
|
- | 65 | // Settings lesen |
|
- | 66 | case 'Q' : // DONE 0.71g |
|
- | 67 | if (Parser::decode64(RX)) |
|
- | 68 | { |
|
- | 69 | o_Connection->stop_ReSend(); |
|
- | 70 | ||
- | 71 | if (RX.decode[1] == VERSION_SETTINGS) |
|
- | 72 | { |
|
- | 73 | int Settings_ID = RX.decode[0]; |
|
- | 74 | for (int a = 0; a < MaxParameter; a++) |
|
- | 75 | { |
|
- | 76 | FCSettings[a] = RX.decode[a + 2]; |
|
- | 77 | } |
|
- | 78 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
|
- | 79 | f_Settings->pb_Read->setEnabled(true); |
|
- | 80 | f_Settings->pb_Write->setEnabled(true); |
|
- | 81 | } |
|
- | 82 | else |
|
- | 83 | { |
|
- | 84 | f_Settings->pb_Read->setDisabled(true); |
|
- | 85 | f_Settings->pb_Write->setDisabled(true); |
|
- | 86 | ||
- | 87 | QString name = QString("Versionen inkompatibel.\n") + |
|
- | 88 | QString("Version von GroundStation benoetigt: ") + |
|
- | 89 | QString(VERSION_SETTINGS) + |
|
- | 90 | QString("\nVersion auf der FlightCtrl: ") + |
|
- | 91 | QString(RX.decode[1]) + |
|
- | 92 | QString("\nParameterbearbeitung nicht moeglich."); |
|
- | 93 | QMessageBox::warning(this, QA_NAME, |
|
- | 94 | name, QMessageBox::Ok); |
|
- | 95 | } |
|
- | 96 | } |
|
- | 97 | break; |
|
- | 98 | // Settings geschrieben |
|
- | 99 | case 'S' : // DONE 0.71g |
|
- | 100 | o_Connection->stop_ReSend(); |
|
- | 101 | break; |
|
- | 102 | } |
|
- | 103 | ||
- | 104 | case ADDRESS_NC : |
|
- | 105 | switch(RX.input[2]) |
|
- | 106 | { |
|
- | 107 | // Navigationsdaten |
|
- | 108 | case 'O' : // NOT DONE 0.12h |
|
- | 109 | if (Parser::decode64(RX)) |
|
- | 110 | { |
|
- | 111 | new_NaviData(RX); |
|
- | 112 | } |
|
- | 113 | break; |
|
- | 114 | } |
|
- | 115 | // case ADDRESS_MK3MAG : |
|
- | 116 | ||
- | 117 | default : |
|
- | 118 | switch(RX.input[2]) |
|
- | 119 | { |
|
- | 120 | // LCD-Anzeige |
|
- | 121 | case 'L' : // DONE 0.71g |
|
- | 122 | if (Parser::decode64(RX)) |
|
- | 123 | { |
|
- | 124 | o_Connection->stop_ReSend(); |
|
- | 125 | ||
- | 126 | int LCD[150]; |
|
- | 127 | memcpy(LCD,RX.decode, sizeof(RX.decode)); |
|
- | 128 | ||
- | 129 | f_LCD->show_Data(LCD); |
|
- | 130 | ||
- | 131 | LCD_Page = RX.decode[0]; |
|
- | 132 | LCD_MAX_Page = RX.decode[1]; |
|
- | 133 | } |
|
- | 134 | break; |
|
- | 135 | // Analoglabels |
|
- | 136 | case 'A' : // DONE 0.71g |
|
- | 137 | if (Parser::decode64(RX)) |
|
- | 138 | { |
|
- | 139 | o_Connection->stop_ReSend(); |
|
- | 140 | ||
- | 141 | int Position = RX.decode[0]; |
|
- | 142 | if (Position != 31) |
|
- | 143 | { |
|
- | 144 | Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
|
- | 145 | if (Settings->Analog1.Label[Position] == "") |
|
- | 146 | { |
|
- | 147 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
|
- | 148 | } |
|
- | 149 | Position ++; |
|
- | 150 | TX_Data[0] = Position; |
|
- | 151 | o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true); |
|
- | 152 | } |
|
- | 153 | if (Position == 31) |
|
- | 154 | { |
|
- | 155 | for (int a = 0; a < MaxAnalog; a++) |
|
- | 156 | { |
|
- | 157 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
|
- | 158 | } |
|
- | 159 | Settings->Analog1.Version = QString(Mode.Version); |
|
- | 160 | Settings->write_Settings_AnalogLabels(HardwareID); |
|
- | 161 | config_Plot(); |
|
- | 162 | } |
|
- | 163 | } |
|
- | 164 | break; |
|
- | 165 | // Debug-Daten |
|
- | 166 | case 'D' : // DONE 0.71g |
|
- | 167 | if (Parser::decode64(RX)) |
|
- | 168 | { |
|
- | 169 | for (int i = 0; i < MaxAnalog; i++) |
|
- | 170 | { |
|
- | 171 | AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
|
- | 172 | } |
|
- | 173 | show_DebugData(); |
|
- | 174 | } |
|
- | 175 | break; |
|
- | 176 | // Version |
|
- | 177 | case 'V' : // DONE 0.71h |
|
- | 178 | if (Parser::decode64(RX)) |
|
- | 179 | { |
|
- | 180 | o_Connection->stop_ReSend(); |
|
- | 181 | ||
- | 182 | Mode.ID = HardwareID; |
|
- | 183 | Mode.VERSION_MAJOR = RX.decode[0]; |
|
- | 184 | Mode.VERSION_MINOR = RX.decode[1]; |
|
- | 185 | Mode.VERSION_PATCH = RX.decode[4]; |
|
- | 186 | Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
|
- | 187 | Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
|
- | 188 | ||
- | 189 | Mode.Hardware = HardwareType[Mode.ID]; |
|
- | 190 | //TODO: Funktion im Handler get_version() oder sowas |
|
- | 191 | QString version = QString("%1").arg(RX.decode[0]) + "." + |
|
- | 192 | QString("%1").arg(RX.decode[1]) + |
|
- | 193 | QString(RX.decode[4] + 'a'); |
|
- | 194 | Mode.Version = version.toLatin1().data; |
|
- | 195 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
|
- | 196 | Mode.Hardware + " " + |
|
- | 197 | Mode.Version); |
|
- | 198 | ||
- | 199 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
|
- | 200 | { |
|
- | 201 | // AllowSend = false; |
|
- | 202 | QMessageBox::warning(this, QA_NAME, |
|
- | 203 | tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
|
- | 204 | } |
|
- | 205 | ||
- | 206 | if (ac_NoDebug->isChecked()) |
|
- | 207 | { |
|
- | 208 | TX_Data[0] = 0; |
|
- | 209 | } |
|
- | 210 | else |
|
- | 211 | if (ac_FastDebug->isChecked()) |
|
- | 212 | { |
|
- | 213 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
|
- | 214 | } |
|
- | 215 | else |
|
- | 216 | { |
|
- | 217 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
|
- | 218 | } |
|
- | 219 | ||
- | 220 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
|
- | 221 | ||
- | 222 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
|
- | 223 | if (Mode.ID == ADDRESS_MK3MAG) |
|
- | 224 | { |
|
- | 225 | TickerEvent[3] = true; |
|
- | 226 | rb_SelMag->setChecked(true); |
|
- | 227 | } |
|
- | 228 | ||
- | 229 | // Wenn NaviCtrl dann hier. |
|
- | 230 | if (Mode.ID == ADDRESS_NC) |
|
- | 231 | { |
|
- | 232 | rb_SelNC->setChecked(true); |
|
- | 233 | ||
- | 234 | if (ac_NoNavi->isChecked()) |
|
- | 235 | { |
|
- | 236 | TX_Data[0] = 0; |
|
- | 237 | } |
|
- | 238 | else |
|
- | 239 | if (ac_FastNavi->isChecked()) |
|
- | 240 | { |
|
- | 241 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
|
- | 242 | } |
|
- | 243 | else |
|
- | 244 | { |
|
- | 245 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
|
- | 246 | } |
|
- | 247 | ||
- | 248 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
|
- | 249 | } |
|
- | 250 | ||
- | 251 | ||
- | 252 | // Wenn FlightCtrl dann Settings abfragen. |
|
- | 253 | if (Mode.ID == ADDRESS_FC) |
|
- | 254 | { |
|
- | 255 | rb_SelFC->setChecked(true); |
|
- | 256 | { |
|
- | 257 | TX_Data[0] = 0xff; |
|
- | 258 | TX_Data[1] = 0; |
|
- | 259 | ||
- | 260 | // DEP: Raus wenn Resend implementiert. |
|
- | 261 | // ToolBox::Wait(SLEEP); |
|
- | 262 | o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
|
- | 263 | qDebug("FC - Get Settings"); |
|
- | 264 | } |
|
- | 265 | } |
|
- | 266 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
|
- | 267 | else |
|
- | 268 | { |
|
- | 269 | f_Settings->pb_Read->setDisabled(true); |
|
- | 270 | f_Settings->pb_Write->setDisabled(true); |
|
- | 271 | } |
|
- | 272 | ||
- | 273 | Settings->read_Settings_Analog(HardwareID); |
|
- | 274 | Settings->read_Settings_AnalogLabels(HardwareID); |
|
- | 275 | ||
- | 276 | if (Settings->Analog1.Version != QString(Mode.Version)) |
|
- | 277 | { |
|
- | 278 | lb_Status->setText(tr("Analoglabel-Version unterschiedlich. Lese Analoglabels neu aus.")); |
|
- | 279 | slot_ac_GetLabels(); |
|
- | 280 | } |
|
- | 281 | else |
|
- | 282 | for (int a = 0; a < MaxAnalog; a++) |
|
- | 283 | { |
|
- | 284 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
|
- | 285 | } |
|
- | 286 | config_Plot(); |
|
- | 287 | } |
|
- | 288 | break; |
|
- | 289 | } |
|
- | 290 | } |
|
16 | } |
291 | } |
17 | 292 |