Subversion Repositories NaviCtrl

Rev

Rev 848 | Rev 856 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 848 Rev 852
Line 83... Line 83...
83
#include "crc16.h"
83
#include "crc16.h"
84
#include "eeprom.h"
84
#include "eeprom.h"
85
#include "triggerlog.h"
85
#include "triggerlog.h"
86
#include "settings.h"
86
#include "settings.h"
87
#include "MobileMenu.h"
87
#include "MobileMenu.h"
-
 
88
#include "CamCtrl.h"
Line 88... Line 89...
88
 
89
 
89
#define LIC_CMD_READ_LICENSE     1
90
#define LIC_CMD_READ_LICENSE     1
90
#define LIC_CMD_WRITE_LICENSE    2
91
#define LIC_CMD_WRITE_LICENSE    2
Line 107... Line 108...
107
NaviData_Tiny_t NaviData_Tiny;
108
NaviData_Tiny_t NaviData_Tiny;
108
NaviData_FS_Pos_t NaviData_Failsafe;
109
NaviData_FS_Pos_t NaviData_Failsafe;
109
NaviData_Out_t NaviData_Out1Trigger;
110
NaviData_Out_t NaviData_Out1Trigger;
110
NaviData_t NaviData;
111
NaviData_t NaviData;
111
NaviData_HoTT_Text_t NaviData_HoTT_Text;
112
NaviData_HoTT_Text_t NaviData_HoTT_Text;
-
 
113
WP_MissionParameter_t WP_MissionParameter;
-
 
114
NaviData_Laser_t NaviData_Laser;
Line 112... Line 115...
112
 
115
 
113
u8 UART1_Request_VersionInfo    = FALSE;
116
u8 UART1_Request_VersionInfo    = FALSE;
114
u8 UART1_Request_ExternalControl= FALSE;
117
u8 UART1_Request_ExternalControl= FALSE;
115
u8 UART1_Request_Display                = FALSE;
118
u8 UART1_Request_Display                = FALSE;
Line 134... Line 137...
134
u8 UART1_Request_LicenseString  = FALSE;
137
u8 UART1_Request_LicenseString  = FALSE;
135
u8 UART1_Request_PPM_Channels   = FALSE;
138
u8 UART1_Request_PPM_Channels   = FALSE;
136
u8 UART1_Request_MobileLabel    = 0xff;
139
u8 UART1_Request_MobileLabel    = 0xff;
137
u8 UART1_Request_MobileMenu     = 0;
140
u8 UART1_Request_MobileMenu     = 0;
138
u8 UART1_Request_MobileInfo             = 0;
141
u8 UART1_Request_MobileInfo             = 0;
-
 
142
u8 UART1_Request_MissonParameter = 0;
-
 
143
u8 StopAllAbbos = 0;
Line 139... Line 144...
139
 
144
 
140
u8 LastTransmittedFCStatusFlags2 = 0;
145
u8 LastTransmittedFCStatusFlags2 = 0;
141
u8 UART1_ExternalControlConfirmFrame = FALSE;
146
u8 UART1_ExternalControlConfirmFrame = FALSE;
142
u8 Send_NMEA_RMC = FALSE;
147
u8 Send_NMEA_RMC = FALSE;
Line 694... Line 699...
694
                                WPL_Answer.Index = WPL_Store.Index; // echo Index in cmd answer
699
                                WPL_Answer.Index = WPL_Store.Index; // echo Index in cmd answer
695
                                WPL_Answer.Status = PointList_WriteToFile(&WPL_Store);
700
                                WPL_Answer.Status = PointList_WriteToFile(&WPL_Store);
696
                                UART1_Request_WPLStore = TRUE;
701
                                UART1_Request_WPLStore = TRUE;
697
                                break;
702
                                break;
Line 698... Line 703...
698
 
703
 
699
                        case 'j':// Set/Get NC-Parameter
704
                        case 'j':
700
                                switch(SerialMsg.pData[0])
705
                                switch(SerialMsg.pData[0])
701
                                {
706
                                {
-
 
707
                                        case 0: // Get NC-Parameter
-
 
708
                                                        UART1_Request_ParameterId = SerialMsg.pData[1];
702
                                        case 0: // get
709
                                                        UART1_Request_Parameter = TRUE;
Line 703... Line 710...
703
                                        break;
710
                                        break;
704
 
711
 
705
                                        case 1: // set
712
                                        case 1: // Set NC-Parameter
706
                                        {
713
                                        {
707
                                                s16 value;
714
                                                s16 value;
-
 
715
                                                value = SerialMsg.pData[2] + (s16)SerialMsg.pData[3] * 0x0100;
-
 
716
                                                NCParams_SetValue(SerialMsg.pData[1], &value);
708
                                                value = SerialMsg.pData[2] + (s16)SerialMsg.pData[3] * 0x0100;
717
                                                UART1_Request_ParameterId = SerialMsg.pData[1];
709
                                                NCParams_SetValue(SerialMsg.pData[1], &value);
718
                                                UART1_Request_Parameter = TRUE;
-
 
719
                                        }
-
 
720
                                        break;
-
 
721
                                        case 3: // Get Mission-Parameter
710
                                        }
722
                                                        UART1_Request_MissonParameter = SerialMsg.pData[0];
-
 
723
                                        break;
-
 
724
 
-
 
725
                                        case 4: // Set Mission-Parameter
-
 
726
                                                        memcpy(&WP_MissionParameter, &SerialMsg.pData[1], sizeof(WP_MissionParameter));
-
 
727
                                                        UART1_Request_MissonParameter = SerialMsg.pData[0]; // answer request with 4
-
 
728
                                        break;
-
 
729
                                        case 5: // stop all abbos
-
 
730
                                                        StopAllAbbos = 1;
711
                                        break;
731
                                        break;
712
                                       
732
                               
713
                                        default:
733
                                        default:
714
                                        break;
-
 
715
                                }
-
 
716
                                UART1_Request_ParameterId = SerialMsg.pData[1];
734
                                        break;
717
                                UART1_Request_Parameter = TRUE;
735
                                }
718
                                break;
736
                                break;
719
                        default:
737
                        default:
720
                                // unsupported command recieved
738
                                // unsupported command recieved
Line 1137... Line 1155...
1137
//      if(Out1TriggerUpdateNewData && MaxBytesPerSecond > 200)   // (only if the data link can transmit more than 200Bytes per secons) -> it wouldn't fit into the data-flow if there are too few bytes available
1155
//      if(Out1TriggerUpdateNewData && MaxBytesPerSecond > 200)   // (only if the data link can transmit more than 200Bytes per secons) -> it wouldn't fit into the data-flow if there are too few bytes available
1138
//     sent += SendTriggerPos(); // dann passen die 35 Bytes noch ohne Verzögerung
1156
//     sent += SendTriggerPos(); // dann passen die 35 Bytes noch ohne Verzögerung
Line 1139... Line 1157...
1139
 
1157
 
1140
                switch(state++)
1158
                switch(state++)
-
 
1159
                {
1141
                {
1160
                 case 0: if(LaserCtrlTimeout > 0) // send only, if LaserCtrl is connected
-
 
1161
                                        {
-
 
1162
                                         NaviData_Laser.Index = 20;
-
 
1163
                                         NaviData_Laser.ActualLongitude = NaviData.CurrentPosition.Longitude;
-
 
1164
                                         NaviData_Laser.ActualLatitude = NaviData.CurrentPosition.Latitude;
-
 
1165
                                         NaviData_Laser.Altimeter_5cm = NaviData.Altimeter_5cm;
-
 
1166
                                         NaviData_Laser.GroundSpeed = NaviData.GroundSpeed / 10;
-
 
1167
                                         NaviData_Laser.OSDStatusFlags = (FC.StatusFlags & OSD_FLAG_MASK1) | (FC.StatusFlags2 & OSD_FLAG_MASK2);
-
 
1168
                                         NaviData_Laser.Distance = FromLaserCtrl.Distance;
-
 
1169
                                 sent += MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'O', NC_ADDRESS, 1 , (u8 *)&NaviData_Laser, sizeof(NaviData_Laser)) + 1;
-
 
1170
                                         break;
1142
                 case 0:
1171
                                        }
1143
                 case 6:
1172
                 case 6:
1144
                 case 5:
1173
                 case 5:
1145
// belegt 35 ASCII-Zeichen
1174
// belegt 35 ASCII-Zeichen
1146
                                NaviData_Flags.Index = 11;
1175
                                NaviData_Flags.Index = 11;
Line 1356... Line 1385...
1356
void UART1_TransmitTxData(void)
1385
void UART1_TransmitTxData(void)
1357
{
1386
{
1358
static u8 motorindex1 = 255, motorindex2 = 0;
1387
static u8 motorindex1 = 255, motorindex2 = 0;
1359
        if(DebugUART != UART1) return;
1388
        if(DebugUART != UART1) return;
Line 1360... Line 1389...
1360
 
1389
 
1361
        if(CheckDelay(UART1_AboTimeOut))
1390
        if(CheckDelay(UART1_AboTimeOut) || StopAllAbbos)
1362
        {
1391
        {
1363
                UART1_DebugData_Interval = 0;
1392
                UART1_DebugData_Interval = 0;
1364
                UART1_NaviData_Interval = 0;
1393
                UART1_NaviData_Interval = 0;
1365
                UART1_NaviData_MaxBytes = 0;
1394
                UART1_NaviData_MaxBytes = 0;
Line 1368... Line 1397...
1368
                UART1_MotorData_Interval = 0;
1397
                UART1_MotorData_Interval = 0;
1369
                UART1_NaviData_Timer = SetDelay(500);
1398
                UART1_NaviData_Timer = SetDelay(500);
1370
                UART1_AboTimeOut = SetDelay(1000);
1399
                UART1_AboTimeOut = SetDelay(1000);
1371
                UART1_MobileMenu_Timer = 0;
1400
                UART1_MobileMenu_Timer = 0;
1372
                TransmitNavigationData(0,1); // clear the CRC values
1401
                TransmitNavigationData(0,1); // clear the CRC values
-
 
1402
                StopAllAbbos = 0;
1373
        }
1403
        }
1374
//if(UART1_NaviData_MaxBytes > 150) UART1_NaviData_MaxBytes = 150;
1404
//if(UART1_NaviData_MaxBytes > 150) UART1_NaviData_MaxBytes = 150;
1375
//UART1_NaviData_MaxBytes = 150;
1405
//UART1_NaviData_MaxBytes = 150;
1376
/*
1406
/*
1377
#define CHK_MIN_INTERVAL(a,b) {if(a && a < b) a = b;}
1407
#define CHK_MIN_INTERVAL(a,b) {if(a && a < b) a = b;}
Line 1390... Line 1420...
1390
                s16 ParamValue;
1420
                s16 ParamValue;
1391
                NCParams_GetValue(UART1_Request_ParameterId, &ParamValue);
1421
                NCParams_GetValue(UART1_Request_ParameterId, &ParamValue);
1392
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'J', NC_ADDRESS, 2, &UART1_Request_ParameterId, sizeof(UART1_Request_ParameterId), &ParamValue, sizeof(ParamValue)); // answer the param request
1422
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'J', NC_ADDRESS, 2, &UART1_Request_ParameterId, sizeof(UART1_Request_ParameterId), &ParamValue, sizeof(ParamValue)); // answer the param request
1393
                UART1_Request_Parameter = FALSE;
1423
                UART1_Request_Parameter = FALSE;
1394
        }
1424
        }
-
 
1425
        else if(UART1_Request_MissonParameter && (UART1_tx_buffer.Locked == FALSE))
-
 
1426
        {
-
 
1427
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'J', NC_ADDRESS, 2, &UART1_Request_MissonParameter, sizeof(UART1_Request_MissonParameter), &WP_MissionParameter, sizeof(WP_MissionParameter)); // answer the param request
-
 
1428
                UART1_Request_MissonParameter = 0;
-
 
1429
        }
1395
        else if(UART1_Request_Echo && (UART1_tx_buffer.Locked == FALSE))
1430
        else if(UART1_Request_Echo && (UART1_tx_buffer.Locked == FALSE))
1396
        {
1431
        {
1397
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'Z', NC_ADDRESS, 1, &Echo, sizeof(Echo)); // answer the echo request
1432
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'Z', NC_ADDRESS, 1, &Echo, sizeof(Echo)); // answer the echo request
1398
                Echo = 0; // reset echo value
1433
                Echo = 0; // reset echo value
1399
                UART1_Request_Echo = FALSE;
1434
                UART1_Request_Echo = FALSE;