Rev 2515 | Rev 2518 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2515 | Rev 2516 | ||
---|---|---|---|
Line 82... | Line 82... | ||
82 | unsigned volatile char SioTmp = 0; |
82 | unsigned volatile char SioTmp = 0; |
83 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
83 | unsigned volatile char NeuerDatensatzEmpfangen = 0; |
84 | unsigned volatile char NeueKoordinateEmpfangen = 0; |
84 | unsigned volatile char NeueKoordinateEmpfangen = 0; |
85 | unsigned volatile char UebertragungAbgeschlossen = 1; |
85 | unsigned volatile char UebertragungAbgeschlossen = 1; |
86 | unsigned volatile char CntCrcError = 0; |
86 | unsigned volatile char CntCrcError = 0; |
87 | unsigned volatile char AnzahlEmpfangsBytes = 0; |
87 | unsigned volatile char AnzahlEmpfangsBytes = 0; // achtung: das ist die AscII-Buffer länge, nicht die Nettodatenlänge |
88 | unsigned volatile char TxdBuffer[MAX_SENDE_BUFF]; |
88 | unsigned volatile char TxdBuffer[MAX_SENDE_BUFF]; |
89 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
89 | unsigned volatile char RxdBuffer[MAX_EMPFANGS_BUFF]; |
Line 90... | Line 90... | ||
90 | 90 | ||
91 | unsigned char *pRxData = 0; |
91 | unsigned char *pRxData = 0; |
Line 96... | Line 96... | ||
96 | 96 | ||
97 | unsigned char PcZugriff = 100; |
97 | unsigned char PcZugriff = 100; |
98 | unsigned char MotorTest[16]; |
98 | unsigned char MotorTest[16]; |
99 | unsigned char MeineSlaveAdresse = 1; // Flight-Ctrl |
99 | unsigned char MeineSlaveAdresse = 1; // Flight-Ctrl |
- | 100 | unsigned char ConfirmFrame; |
|
100 | unsigned char ConfirmFrame; |
101 | unsigned char ExternalControlTimeout = 0; |
101 | struct str_DebugOut DebugOut; |
102 | struct str_DebugOut DebugOut; |
102 | struct str_ExternControl ExternControl; |
103 | struct str_ExternControl ExternalControl; |
103 | struct str_VersionInfo VersionInfo; |
104 | struct str_VersionInfo VersionInfo; |
104 | struct str_WinkelOut WinkelOut; |
105 | struct str_WinkelOut WinkelOut; |
Line 105... | Line 106... | ||
105 | struct str_Data3D Data3D; |
106 | struct str_Data3D Data3D; |
Line 369... | Line 370... | ||
369 | case FC_ADDRESS: // FC special commands |
370 | case FC_ADDRESS: // FC special commands |
370 | switch(RxdBuffer[2]) |
371 | switch(RxdBuffer[2]) |
371 | { |
372 | { |
372 | case 'K':// Kompasswert |
373 | case 'K':// Kompasswert |
373 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
374 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
374 | // KompassRichtung = ((540 + KompassValue - KompassSollWert) % 360) - 180; |
- | |
375 | break; |
375 | break; |
376 | case 't':// Motortest |
376 | case 't':// Motortest |
377 | if(AnzahlEmpfangsBytes > 20) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
377 | if(AnzahlEmpfangsBytes > 20) memcpy(&MotorTest[0], (unsigned char *)pRxData, sizeof(MotorTest)); |
378 | else memcpy(&MotorTest[0], (unsigned char *)pRxData, 4); |
378 | else memcpy(&MotorTest[0], (unsigned char *)pRxData, 4); |
379 | PC_MotortestActive = 240; |
379 | PC_MotortestActive = 240; |
Line 609... | Line 609... | ||
609 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
609 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
610 | break; |
610 | break; |
611 | // 'K' comand placed here only for compatibility to old MK3MAG software, that does not send the right Slave Address |
611 | // 'K' comand placed here only for compatibility to old MK3MAG software, that does not send the right Slave Address |
612 | case 'K':// Kompasswert |
612 | case 'K':// Kompasswert |
613 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
613 | memcpy((unsigned char *)&KompassValue , (unsigned char *)pRxData, sizeof(KompassValue)); |
614 | // KompassRichtung = ((540 + KompassValue - KompassSollWert) % 360) - 180; |
- | |
615 | break; |
614 | break; |
616 | case 'a':// Texte der Analogwerte |
615 | case 'a':// Texte der Analogwerte |
617 | DebugTextAnforderung = pRxData[0]; |
616 | DebugTextAnforderung = pRxData[0]; |
618 | if (DebugTextAnforderung > 31) DebugTextAnforderung = 31; |
617 | if (DebugTextAnforderung > 31) DebugTextAnforderung = 31; |
619 | PcZugriff = 255; |
618 | PcZugriff = 255; |
620 | break; |
619 | break; |
621 | case 'b': |
620 | case 'b': |
- | 621 | if(AnzahlEmpfangsBytes < 20) // prevents that the old frame is guilty |
|
- | 622 | { |
|
622 | memcpy((unsigned char *)&ExternControl, (unsigned char *)pRxData, sizeof(ExternControl)); |
623 | memcpy((unsigned char *)&ExternalControl, (unsigned char *)pRxData, sizeof(ExternalControl)); |
623 | ConfirmFrame = ExternControl.Frame; |
624 | ConfirmFrame = ExternalControl.Frame; |
- | 625 | ExternalControlTimeout = 100; // 2 seconds timeout |
|
624 | PcZugriff = 255; |
626 | } |
625 | break; |
627 | break; |
626 | case 'c': // Poll the 3D-Data |
628 | case 'c': // Poll the 3D-Data |
627 | if(!Intervall3D) { if(pRxData[0]) Timer3D = SetDelay(pRxData[0] * 10);} |
629 | if(!Intervall3D) { if(pRxData[0]) Timer3D = SetDelay(pRxData[0] * 10);} |
628 | Intervall3D = pRxData[0] * 10; |
630 | Intervall3D = pRxData[0] * 10; |
629 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
631 | AboTimeOut = SetDelay(ABO_TIMEOUT); |
Line 787... | Line 789... | ||
787 | Debug_OK("Version gesendet"); |
789 | Debug_OK("Version gesendet"); |
788 | } |
790 | } |
Line 789... | Line 791... | ||
789 | 791 | ||
790 | if(GetExternalControl && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
792 | if(GetExternalControl && UebertragungAbgeschlossen) // Bei Get werden die vom PC einstellbaren Werte vom PC zurückgelesen |
791 | { |
793 | { |
792 | SendOutData('G',MeineSlaveAdresse, 1, (unsigned char *) &ExternControl, sizeof(ExternControl)); |
794 | SendOutData('G',MeineSlaveAdresse, 1, (unsigned char *) &ExternalControl, sizeof(ExternalControl)); |
793 | GetExternalControl = 0; |
795 | GetExternalControl = 0; |
794 | } |
796 | } |
795 | if(((DebugDataIntervall>0 && CheckDelay(Debug_Timer)) || DebugDataAnforderung) && UebertragungAbgeschlossen) |
797 | if(((DebugDataIntervall>0 && CheckDelay(Debug_Timer)) || DebugDataAnforderung) && UebertragungAbgeschlossen) |
796 | { |
798 | { |
Line 858... | Line 860... | ||
858 | else SendRedundantMotor[0] = 0; |
860 | else SendRedundantMotor[0] = 0; |
859 | if(PC_MotortestActive) SendRedundantMotor[0] |= 0x80; |
861 | if(PC_MotortestActive) SendRedundantMotor[0] |= 0x80; |
860 | SendRedundantMotor[i+1] = Motor[i].SetPoint; |
862 | SendRedundantMotor[i+1] = Motor[i].SetPoint; |
861 | } |
863 | } |
862 | SendOutData('!', FC_ADDRESS, 1, (unsigned char *) &SendRedundantMotor, RequiredMotors+1); |
864 | SendOutData('!', FC_ADDRESS, 1, (unsigned char *) &SendRedundantMotor, RequiredMotors+1); |
- | 865 | Kompass_Timer = SetDelay(25); |
|
863 | } |
866 | } |
864 | #endif |
867 | #endif |
Line 865... | Line 868... | ||
865 | 868 | ||
866 | #ifdef DEBUG // only include functions if DEBUG is defined |
869 | #ifdef DEBUG // only include functions if DEBUG is defined |