Rev 442 | Rev 462 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 442 | Rev 449 | ||
---|---|---|---|
Line 80... | Line 80... | ||
80 | void Handler::stop_navictrl_debug() { |
80 | void Handler::stop_navictrl_debug() { |
81 | set_navictrl_debug(0); |
81 | set_navictrl_debug(0); |
82 | } |
82 | } |
Line 83... | Line 83... | ||
83 | 83 | ||
84 | /** |
84 | /** |
85 | * send a waypoint to the NaviCtrl (the copter will fly to the position emidiately) |
85 | * send a waypoint to the NaviCtrl (the MikroKopter will fly to the position emidiately) |
86 | */ |
86 | */ |
87 | void Handler::send_waypoint(Waypoint_t desired_pos) { |
87 | void Handler::send_waypoint(Waypoint_t desired_pos) { |
88 | com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
88 | com->send_cmd('s', ADDRESS_NC, (char *)&desired_pos, sizeof(desired_pos), false); |
Line 187... | Line 187... | ||
187 | } |
187 | } |
Line 188... | Line 188... | ||
188 | 188 | ||
189 | /** |
189 | /** |
190 | * receive data |
190 | * receive data |
191 | */ |
191 | */ |
192 | void Handler::receive_data(sRxData RX) { |
192 | //Parser::decode64(data); |
193 | //extract hardware ID from received Data |
- | |
194 | int hardwareID = RX.input[1] - 'a'; |
193 | void Handler::receive_data(int hardwareID, int cmd, char * data) { |
195 | switch(hardwareID) |
194 | switch(hardwareID) |
196 | { |
195 | { |
197 | case ADDRESS_FC : |
196 | case ADDRESS_FC : |
198 | switch(RX.input[2]) |
197 | switch(cmd) |
199 | { |
198 | { |
200 | // Motor-Mixer |
199 | // Motor-Mixer |
201 | case 'N' : |
200 | case 'N' : |
202 | if (Parser::decode64(RX)) |
201 | //if (Parser::decode64(RX)) |
203 | { |
202 | //{ |
204 | com->stop_resend(); |
- | |
- | 203 | com->stop_resend(); |
|
205 | 204 | //decoded data |
|
206 | if (RX.decode[0] == VERSION_MIXER) |
205 | if (data[0] == VERSION_MIXER) |
207 | { |
206 | { |
208 | //f_MotorMixer->set_MotorConfig(RX); |
207 | //f_MotorMixer->set_MotorConfig(RX); |
209 | } |
208 | } |
210 | } |
209 | //} |
211 | break; |
210 | break; |
212 | // Motor-Mixer Schreib-Bestätigung |
211 | // Motor-Mixer Schreib-Bestätigung |
213 | case 'M' : |
- | |
214 | if (Parser::decode64(RX)) |
- | |
215 | { |
212 | case 'M' : |
Line 216... | Line 213... | ||
216 | com->stop_resend(); |
213 | com->stop_resend(); |
217 | 214 | ||
218 | if (RX.decode[0] == 1) |
215 | if (data[0] == 1) |
219 | { |
- | |
220 | //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
216 | { |
221 | } |
217 | //lb_Status->setText(tr("MotorMixer-Daten in FC geschrieben.")); |
Line 222... | Line 218... | ||
222 | } |
218 | } |
223 | break; |
219 | break; |
224 | - | ||
225 | // Stick-Belegung der Fernsteuerung |
- | |
226 | case 'P' : // DONE 0.71g |
220 | |
227 | if (Parser::decode64(RX)) |
221 | // Stick-Belegung der Fernsteuerung |
228 | { |
222 | case 'P' : // DONE 0.71g |
229 | /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true)); |
223 | /*f_Settings->pb_K1->setValue(Parser::dataToInt(RX.decode, 2,true)); |
230 | f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true)); |
224 | f_Settings->pb_K2->setValue(Parser::dataToInt(RX.decode, 4,true)); |
231 | f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true)); |
225 | f_Settings->pb_K3->setValue(Parser::dataToInt(RX.decode, 6,true)); |
232 | f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true)); |
226 | f_Settings->pb_K4->setValue(Parser::dataToInt(RX.decode, 8,true)); |
233 | f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true)); |
227 | f_Settings->pb_K5->setValue(Parser::dataToInt(RX.decode, 10 ,true)); |
234 | f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true)); |
- | |
235 | f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true)); |
228 | f_Settings->pb_K6->setValue(Parser::dataToInt(RX.decode, 12,true)); |
236 | f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/ |
229 | f_Settings->pb_K7->setValue(Parser::dataToInt(RX.decode, 14,true)); |
237 | } |
230 | f_Settings->pb_K8->setValue(Parser::dataToInt(RX.decode, 16,true));*/ |
238 | break; |
- | |
239 | // Settings lesen |
- | |
240 | case 'Q' : // DONE 0.71g |
231 | break; |
Line 241... | Line 232... | ||
241 | if (Parser::decode64(RX)) |
232 | // Settings lesen |
- | 233 | case 'Q' : // DONE 0.71g |
|
- | 234 | com->stop_resend(); |
|
- | 235 | ||
242 | { |
236 | if (data[1] == VERSION_SETTINGS) |
243 | com->stop_resend(); |
- | |
244 | - | ||
245 | if (RX.decode[1] == VERSION_SETTINGS) |
- | |
246 | { |
237 | { |
247 | int Settings_ID = RX.decode[0]; |
- | |
248 | /*for (int a = 0; a < MaxParameter; a++) |
- | |
249 | { |
- | |
250 | FCSettings[a] = RX.decode[a + 2]; |
- | |
251 | } |
238 | int Settings_ID = data[0]; |
- | 239 | /*for (int a = 0; a < MaxParameter; a++) |
|
- | 240 | { |
|
- | 241 | FCSettings[a] = RX.decode[a + 2]; |
|
- | 242 | } |
|
252 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
243 | f_Settings->show_FCSettings(Settings_ID, FCSettings); |
253 | f_Settings->pb_Read->setEnabled(true); |
244 | f_Settings->pb_Read->setEnabled(true); |
254 | f_Settings->pb_Write->setEnabled(true);*/ |
245 | f_Settings->pb_Write->setEnabled(true);*/ |
255 | } |
246 | } |
Line 256... | Line 247... | ||
256 | else |
247 | else |
257 | { |
248 | { |
258 | /*f_Settings->pb_Read->setDisabled(true); |
249 | /*f_Settings->pb_Read->setDisabled(true); |
259 | f_Settings->pb_Write->setDisabled(true); |
250 | f_Settings->pb_Write->setDisabled(true); |
260 | 251 | ||
261 | QString name = QString("Versionen inkompatibel.\n") + |
252 | QString name = QString("Versionen inkompatibel.\n") + |
262 | QString("Version von GroundStation benoetigt: ") + |
253 | QString("Version von GroundStation benoetigt: ") + |
263 | QString(VERSION_SETTINGS) + |
254 | QString(VERSION_SETTINGS) + |
264 | QString("\nVersion auf der FlightCtrl: ") + |
- | |
265 | QString(RX.decode[1]) + |
255 | QString("\nVersion auf der FlightCtrl: ") + |
266 | QString("\nParameterbearbeitung nicht moeglich."); |
256 | QString(RX.decode[1]) + |
267 | QMessageBox::warning(this, QA_NAME, |
257 | QString("\nParameterbearbeitung nicht moeglich."); |
268 | name, QMessageBox::Ok);*/ |
258 | QMessageBox::warning(this, QA_NAME, |
269 | } |
259 | name, QMessageBox::Ok);*/ |
270 | } |
260 | } |
271 | break; |
261 | break; |
272 | // Settings written |
262 | // Settings written |
Line 273... | Line 263... | ||
273 | case 'S' : // DONE 0.71g |
263 | case 'S' : // DONE 0.71g |
274 | com->stop_resend(); |
264 | com->stop_resend(); |
275 | //TODO: QMessagebox("settings written successful") ? |
265 | //TODO: QMessagebox("settings written successful") ? |
276 | break; |
266 | break; |
277 | } |
267 | } |
278 | - | ||
279 | case ADDRESS_NC : |
- | |
280 | switch(RX.input[2]) |
268 | |
281 | { |
- | |
282 | // Navigationsdaten |
269 | case ADDRESS_NC : |
283 | case 'O' : // NOT DONE 0.12h |
270 | switch(cmd) |
284 | if (Parser::decode64(RX)) |
271 | { |
Line 285... | Line 272... | ||
285 | { |
272 | // Navigationsdaten |
286 | //new_NaviData(RX); |
273 | case 'O' : // NOT DONE 0.12h |
287 | } |
274 | //new_NaviData(RX); |
288 | break; |
275 | break; |
289 | } |
276 | } |
290 | // case ADDRESS_MK3MAG : |
- | |
291 | - | ||
292 | default : |
277 | // case ADDRESS_MK3MAG : |
Line 293... | Line 278... | ||
293 | switch(RX.input[2]) |
278 | |
294 | { |
279 | default : |
Line 295... | Line 280... | ||
295 | // LCD-Anzeige |
280 | switch(cmd) |
Line 296... | Line 281... | ||
296 | case 'L' : // DONE 0.71g |
281 | { |
297 | if (Parser::decode64(RX)) |
282 | // LCD-Anzeige |
298 | { |
- | |
299 | com->stop_resend(); |
283 | case 'L' : // DONE 0.71g |
300 | 284 | com->stop_resend(); |
|
301 | /*int LCD[150]; |
285 | |
302 | memcpy(LCD,RX.decode, sizeof(RX.decode)); |
286 | /*int LCD[150]; |
303 | - | ||
304 | f_LCD->show_Data(LCD); |
- | |
305 | 287 | memcpy(LCD,RX.decode, sizeof(RX.decode)); |
|
Line 306... | Line 288... | ||
306 | LCD_Page = RX.decode[0]; |
288 | |
307 | LCD_MAX_Page = RX.decode[1]; |
289 | f_LCD->show_Data(LCD); |
- | 290 | ||
- | 291 | LCD_Page = RX.decode[0]; |
|
- | 292 | LCD_MAX_Page = RX.decode[1]; |
|
308 | */ |
293 | */ |
309 | } |
- | |
310 | break; |
- | |
311 | // Analoglabels |
- | |
312 | case 'A' : // DONE 0.71g |
- | |
313 | if (Parser::decode64(RX)) |
294 | break; |
314 | { |
- | |
315 | com->stop_resend(); |
- | |
316 | - | ||
317 | int Position = RX.decode[0]; |
- | |
318 | if (Position != 31) |
295 | // Analoglabels |
319 | { |
296 | case 'A' : // DONE 0.71g |
- | 297 | com->stop_resend(); |
|
- | 298 | ||
- | 299 | //check position |
|
- | 300 | if (data[0] != 31) { |
|
- | 301 | /* |
|
320 | /* |
302 | Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
321 | Settings->Analog1.Label[Position] = ToolBox::dataToQString(RX.decode,1,17).trimmed(); |
- | |
322 | if (Settings->Analog1.Label[Position] == "") |
- | |
323 | { |
- | |
324 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
303 | if (Settings->Analog1.Label[Position] == "") |
325 | } |
- | |
326 | Position ++; |
- | |
327 | TX_Data[0] = Position; |
- | |
328 | o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
- | |
329 | } |
304 | { |
- | 305 | Settings->Analog1.Label[Position] = "A-" + QString("%1").arg(Position); |
|
- | 306 | } |
|
- | 307 | Position ++; |
|
330 | if (Position == 31) |
308 | TX_Data[0] = Position; |
331 | { |
309 | o_Connection->send_Cmd('a', ADDRESS_ALL, TX_Data, 1, true);*/ |
332 | /* |
310 | } else { |
333 | for (int a = 0; a < MaxAnalog; a++) |
311 | /* |
334 | { |
- | |
335 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
- | |
336 | } |
312 | for (int a = 0; a < MaxAnalog; a++) |
337 | Settings->Analog1.Version = QString(Mode.Version); |
- | |
338 | Settings->write_Settings_AnalogLabels(HardwareID); |
313 | { |
339 | config_Plot();*/ |
- | |
340 | } |
- | |
341 | } |
314 | lb_Analog[a]->setText(Settings->Analog1.Label[a]); |
- | 315 | } |
|
342 | break; |
316 | Settings->Analog1.Version = QString(Mode.Version); |
343 | // Debug-Daten |
317 | Settings->write_Settings_AnalogLabels(HardwareID); |
344 | case 'D' : // DONE 0.71g |
318 | config_Plot();*/ |
345 | if (Parser::decode64(RX)) |
- | |
346 | { |
- | |
347 | for (int i = 0; i < MaxAnalog; i++) |
319 | } |
348 | { |
320 | break; |
349 | //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
321 | // Debug-Daten |
350 | } |
322 | case 'D' : // DONE 0.71g |
351 | //show_DebugData(); |
323 | for (int i = 0; i < MaxAnalog; i++) { |
352 | } |
324 | //AnalogData[i] = Parser::dataToInt(RX.decode, (i * 2) + 2); |
353 | break; |
325 | } |
354 | // Version |
326 | //show_DebugData(); |
355 | case 'V' : // DONE 0.71h |
327 | break; |
356 | if (Parser::decode64(RX)) |
328 | // Version |
357 | { |
329 | case 'V' : // DONE 0.71h |
358 | com->stop_resend(); |
330 | com->stop_resend(); |
359 | /* |
331 | /* |
360 | Mode.ID = HardwareID; |
332 | Mode.ID = HardwareID; |
361 | Mode.VERSION_MAJOR = RX.decode[0]; |
333 | Mode.VERSION_MAJOR = RX.decode[0]; |
362 | Mode.VERSION_MINOR = RX.decode[1]; |
334 | Mode.VERSION_MINOR = RX.decode[1]; |
363 | Mode.VERSION_PATCH = RX.decode[4]; |
335 | Mode.VERSION_PATCH = RX.decode[4]; |
364 | Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
336 | Mode.VERSION_SERIAL_MAJOR = RX.decode[2]; |
Line 365... | Line 337... | ||
365 | Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
337 | Mode.VERSION_SERIAL_MINOR = RX.decode[3]; |
366 | 338 | ||
367 | Mode.Hardware = HardwareType[Mode.ID]; |
339 | Mode.Hardware = HardwareType[Mode.ID]; |
368 | //TODO: Funktion im Handler get_version() oder sowas |
340 | //TODO: Funktion im Handler get_version() oder sowas |
369 | QString version = QString("%1").arg(RX.decode[0]) + "." + |
341 | QString version = QString("%1").arg(RX.decode[0]) + "." + |
- | 342 | QString("%1").arg(RX.decode[1]) + |
|
- | 343 | QString(RX.decode[4] + 'a'); |
|
- | 344 | Mode.Version = version.toLatin1().data; |
|
- | 345 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
|
- | 346 | Mode.Hardware + " " + |
|
- | 347 | Mode.Version); |
|
- | 348 | ||
- | 349 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
|
- | 350 | { |
|
- | 351 | // AllowSend = false; |
|
- | 352 | QMessageBox::warning(this, QA_NAME, |
|
- | 353 | tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
|
- | 354 | } |
|
- | 355 | ||
370 | QString("%1").arg(RX.decode[1]) + |
356 | if (ac_NoDebug->isChecked()) |
- | 357 | { |
|
- | 358 | TX_Data[0] = 0; |
|
Line -... | Line 359... | ||
- | 359 | } |
|
- | 360 | else |
|
- | 361 | if (ac_FastDebug->isChecked()) |
|
- | 362 | { |
|
- | 363 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
|
- | 364 | } |
|
- | 365 | else |
|
- | 366 | { |
|
- | 367 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
|
- | 368 | } |
|
- | 369 | ||
- | 370 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
|
371 | QString(RX.decode[4] + 'a'); |
371 | |
372 | Mode.Version = version.toLatin1().data; |
372 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
373 | setWindowTitle(QA_NAME + " v" + QA_VERSION + " - " + |
373 | if (Mode.ID == ADDRESS_MK3MAG) |
374 | Mode.Hardware + " " + |
374 | { |
375 | Mode.Version); |
375 | TickerEvent[3] = true; |
376 | 376 | rb_SelMag->setChecked(true); |
|
377 | if (Mode.VERSION_SERIAL_MAJOR != VERSION_SERIAL_MAJOR) |
377 | } |
378 | { |
378 | |
379 | // AllowSend = false; |
379 | // Wenn NaviCtrl dann hier. |
380 | QMessageBox::warning(this, QA_NAME, |
380 | if (Mode.ID == ADDRESS_NC) |
381 | tr("Serielles Protokoll Inkompatibel. \nBitte neue Programmversion installieren,"), QMessageBox::Ok); |
381 | { |
382 | } |
382 | rb_SelNC->setChecked(true); |
383 | 383 | ||
Line 384... | Line -... | ||
384 | if (ac_NoDebug->isChecked()) |
- | |
385 | { |
- | |
386 | TX_Data[0] = 0; |
- | |
387 | } |
- | |
388 | else |
- | |
389 | if (ac_FastDebug->isChecked()) |
- | |
390 | { |
- | |
391 | TX_Data[0] = Settings->Data.Debug_Fast / 10; |
- | |
392 | } |
- | |
393 | else |
- | |
394 | { |
- | |
395 | TX_Data[0] = Settings->Data.Debug_Slow / 10; |
- | |
396 | } |
- | |
397 | - | ||
398 | o_Connection->send_Cmd('d', ADDRESS_ALL, TX_Data, 1, false); |
- | |
399 | - | ||
400 | // Wenn MK3MAG dann andauernd Daten neu anfragen. |
- | |
401 | if (Mode.ID == ADDRESS_MK3MAG) |
- | |
402 | { |
- | |
403 | TickerEvent[3] = true; |
- | |
404 | rb_SelMag->setChecked(true); |
- | |
405 | } |
- | |
406 | - | ||
407 | // Wenn NaviCtrl dann hier. |
- | |
408 | if (Mode.ID == ADDRESS_NC) |
- | |
409 | { |
- | |
410 | rb_SelNC->setChecked(true); |
- | |
411 | - | ||
412 | if (ac_NoNavi->isChecked()) |
384 | if (ac_NoNavi->isChecked()) |
413 | { |
385 | { |
Line 414... | Line 386... | ||
414 | TX_Data[0] = 0; |
386 | TX_Data[0] = 0; |
415 | } |
387 | } |
- | 388 | else |
|
- | 389 | if (ac_FastNavi->isChecked()) |
|
416 | else |
390 | { |
417 | if (ac_FastNavi->isChecked()) |
- | |
418 | { |
- | |
419 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
391 | TX_Data[0] = Settings->Data.Navi_Fast / 10; |
420 | } |
392 | } |
Line 421... | Line 393... | ||
421 | else |
393 | else |
422 | { |
394 | { |
423 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
395 | TX_Data[0] = Settings->Data.Navi_Slow / 10; |
424 | } |
396 | } |
425 | - | ||
426 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
- | |
427 | } |
- | |
428 | - | ||
429 | - | ||
430 | // Wenn FlightCtrl dann Settings abfragen. |
- | |
431 | if (Mode.ID == ADDRESS_FC) |
- | |
432 | { |
397 | |
- | 398 | o_Connection->send_Cmd('o', ADDRESS_NC, TX_Data, 1, false); |
|
- | 399 | } |
|
- | 400 | ||
- | 401 | ||
- | 402 | // Wenn FlightCtrl dann Settings abfragen. |
|
- | 403 | if (Mode.ID == ADDRESS_FC) |
|
- | 404 | { |
|
Line 433... | Line 405... | ||
433 | rb_SelFC->setChecked(true); |
405 | rb_SelFC->setChecked(true); |
434 | { |
406 | { |
Line 435... | Line 407... | ||
435 | TX_Data[0] = 0xff; |
407 | TX_Data[0] = 0xff; |
436 | TX_Data[1] = 0; |
408 | TX_Data[1] = 0; |
437 | 409 | ||
438 | // DEP: Raus wenn Resend implementiert. |
410 | // DEP: Raus wenn Resend implementiert. |
439 | // ToolBox::Wait(SLEEP); |
411 | // ToolBox::Wait(SLEEP); |
440 | o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
412 | o_Connection->send_Cmd('q', ADDRESS_FC, TX_Data, 1, true); |
441 | qDebug("FC - Get Settings"); |
413 | qDebug("FC - Get Settings"); |
442 | } |
414 | } |
443 | } |
415 | } |
444 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
- | |
445 | else |
- | |
446 | { |
416 | // Wenn nicht Lesen und Schreiben der Settings deaktivieren. |
- | 417 | else |
|
447 | f_Settings->pb_Read->setDisabled(true); |
418 | { |
448 | f_Settings->pb_Write->setDisabled(true); |
419 | f_Settings->pb_Read->setDisabled(true); |
449 | } |
420 | f_Settings->pb_Write->setDisabled(true); |
450 | 421 | } |
|
451 | Settings->read_Settings_Analog(HardwareID); |
422 |