Rev 519 | Rev 530 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 519 | Rev 529 | ||
---|---|---|---|
Line 78... | Line 78... | ||
78 | #include "debug.h" |
78 | #include "debug.h" |
79 | #include "spi_slave.h" |
79 | #include "spi_slave.h" |
80 | #include "ftphelper.h" |
80 | #include "ftphelper.h" |
81 | #include "led.h" |
81 | #include "led.h" |
82 | #include "fat16.h" |
82 | #include "fat16.h" |
- | 83 | #include "eeprom.h" |
|
- | 84 | ||
- | 85 | #define LIC_CMD_READ_LICENSE 1 |
|
- | 86 | #define LIC_CMD_WRITE_LICENSE 2 |
|
- | 87 | #define LIC_CMD_ERASE_LICENSE 3 |
|
Line 83... | Line 88... | ||
83 | 88 | ||
84 | 89 | ||
Line 107... | Line 112... | ||
107 | u8 UART1_Request_SystemTime = FALSE; |
112 | u8 UART1_Request_SystemTime = FALSE; |
108 | u8 UART1_DisplayKeys = 0; |
113 | u8 UART1_DisplayKeys = 0; |
109 | u8 UART1_DisplayLine = 0; |
114 | u8 UART1_DisplayLine = 0; |
110 | u8 UART1_ConfirmFrame = 0; |
115 | u8 UART1_ConfirmFrame = 0; |
111 | u8 UART1_Request_FTP = FALSE; |
116 | u8 UART1_Request_FTP = FALSE; |
- | 117 | u8 UART1_Request_LicenseString = FALSE; |
|
112 | u8 LastTransmittedFCStatusFlags2 = 0; |
118 | u8 LastTransmittedFCStatusFlags2 = 0; |
113 | u8 UART1_ExternalControlConfirmFrame = FALSE; |
119 | u8 UART1_ExternalControlConfirmFrame = FALSE; |
114 | u8 Send_NMEA_RMC = FALSE; |
120 | u8 Send_NMEA_RMC = FALSE; |
Line 115... | Line 121... | ||
115 | 121 | ||
Line 137... | Line 143... | ||
137 | Buffer_t UART1_tx_buffer; |
143 | Buffer_t UART1_tx_buffer; |
Line 138... | Line 144... | ||
138 | 144 | ||
Line 139... | Line 145... | ||
139 | volatile u8 SerialLinkOkay = 0; |
145 | volatile u8 SerialLinkOkay = 0; |
- | 146 | ||
Line 140... | Line 147... | ||
140 | 147 | u8 text[200]; |
|
141 | u8 text[200]; |
148 | u8 *LicensePtr = UART1_tbuffer; |
142 | 149 | ||
143 | const u8 ANALOG_LABEL[32][16] = |
150 | const u8 ANALOG_LABEL[32][16] = |
Line 157... | Line 164... | ||
157 | "GyroHeading ", |
164 | "GyroHeading ", |
158 | "SPI Error ", // achtung: muss auf 12 bleiben |
165 | "SPI Error ", // achtung: muss auf 12 bleiben |
159 | "SPI Okay ", |
166 | "SPI Okay ", |
160 | "I2C Error ", |
167 | "I2C Error ", |
161 | "I2C Okay ", //15 |
168 | "I2C Okay ", //15 |
162 | "16 dist (cm) ", |
169 | "16 ", |
163 | "17 alt dist ", |
170 | "17 ", |
164 | "18 time ", |
171 | "18 ", |
165 | "19 climb ", // SD-Card-time |
172 | "19 ", // SD-Card-time |
166 | "EarthMagnet [%] ", //20 |
173 | "EarthMagnet [%] ", //20 |
167 | "Ground Speed ", // "Z_Speed ", |
174 | "Ground Speed ", // "Z_Speed ", |
168 | "N_Speed ", |
175 | "N_Speed ", |
169 | "E_Speed ", |
176 | "E_Speed ", |
170 | "Magnet X ", |
177 | "Magnet X ", |
Line 424... | Line 431... | ||
424 | { |
431 | { |
425 | case 't': // request for the GPS time |
432 | case 't': // request for the GPS time |
426 | UART1_Request_SystemTime = TRUE; |
433 | UART1_Request_SystemTime = TRUE; |
427 | break; |
434 | break; |
Line -... | Line 435... | ||
- | 435 | ||
- | 436 | case 'm': // request for the license string |
|
- | 437 | UART1_Request_LicenseString = SerialMsg.pData[0]; |
|
- | 438 | if(UART1_Request_LicenseString == LIC_CMD_WRITE_LICENSE) |
|
- | 439 | { |
|
- | 440 | memcpy(LicensePtr, &SerialMsg.pData[1],LICENSE_SIZE_TEXT); // copy ftp parameter |
|
- | 441 | } |
|
428 | 442 | break; |
|
429 | case 'f': // ftp command |
443 | case 'f': // ftp command |
430 | UART1_Request_FTP = SerialMsg.pData[0]; |
444 | UART1_Request_FTP = SerialMsg.pData[0]; |
431 | //if (UART1_Request_FTP == FTP_CMD_SET_CWD || UART1_Request_FTP == FTP_CMD_GET_FILE) |
445 | //if (UART1_Request_FTP == FTP_CMD_SET_CWD || UART1_Request_FTP == FTP_CMD_GET_FILE) |
432 | memcpy(&FTP_data, &SerialMsg.pData[1], sizeof(FTP_data)); // copy ftp parameter |
446 | memcpy(&FTP_data, &SerialMsg.pData[1], sizeof(FTP_data)); // copy ftp parameter |
Line 1097... | Line 1111... | ||
1097 | else if(UART1_Request_ErrorMessage && (UART1_tx_buffer.Locked == FALSE)) |
1111 | else if(UART1_Request_ErrorMessage && (UART1_tx_buffer.Locked == FALSE)) |
1098 | { |
1112 | { |
1099 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
1113 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'E', NC_ADDRESS, 1, (u8 *)&ErrorMSG, sizeof(ErrorMSG)); |
1100 | UART1_Request_ErrorMessage = FALSE; |
1114 | UART1_Request_ErrorMessage = FALSE; |
1101 | } |
1115 | } |
- | 1116 | else if(UART1_Request_LicenseString && (UART1_tx_buffer.Locked == FALSE)) |
|
- | 1117 | { |
|
- | 1118 | u8 result = 1; |
|
- | 1119 | if(UART1_Request_LicenseString == LIC_CMD_READ_LICENSE) |
|
- | 1120 | { |
|
- | 1121 | result = LIC_CMD_READ_LICENSE; |
|
- | 1122 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'M', NC_ADDRESS, 2, &result, 1, LicensePtr, LICENSE_SIZE); |
|
- | 1123 | } |
|
- | 1124 | else |
|
- | 1125 | if((UART1_Request_LicenseString == LIC_CMD_ERASE_LICENSE) && !(FC.StatusFlags & FC_STATUS_MOTOR_RUN)) |
|
- | 1126 | { |
|
- | 1127 | result = LIC_CMD_ERASE_LICENSE; |
|
- | 1128 | DeleteLicenseInEEPROM(); |
|
- | 1129 | CheckLicense(GET_LICENSE); |
|
- | 1130 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'M', NC_ADDRESS, 1, &result, 1); |
|
- | 1131 | } |
|
- | 1132 | else |
|
- | 1133 | if((UART1_Request_LicenseString == LIC_CMD_WRITE_LICENSE) && !(FC.StatusFlags & FC_STATUS_MOTOR_RUN)) |
|
- | 1134 | { |
|
- | 1135 | result = LIC_CMD_WRITE_LICENSE; |
|
- | 1136 | if(CheckLicense(CHECK_ONLY)) //new license is okay |
|
- | 1137 | { |
|
- | 1138 | WriteLicenseToEEPROM(EEPROM_LICENSE_DATA_KOMPATIBEL); |
|
- | 1139 | result = 0; |
|
- | 1140 | } |
|
- | 1141 | else //new license is NOT okay |
|
- | 1142 | { |
|
- | 1143 | ClearLicenseText(); |
|
- | 1144 | CheckLicense(GET_LICENSE); // fetch a license if available |
|
- | 1145 | } |
|
- | 1146 | MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'M', NC_ADDRESS, 1, &result, 1); |
|
- | 1147 | } |
|
- | 1148 | UART1_Request_LicenseString = 0; |
|
- | 1149 | } |
|
1102 | #ifdef FOLLOW_ME |
1150 | #ifdef FOLLOW_ME |
1103 | else if(CheckDelay(UART1_FollowMe_Timer) && (UART1_tx_buffer.Locked == FALSE)) |
1151 | else if(CheckDelay(UART1_FollowMe_Timer) && (UART1_tx_buffer.Locked == FALSE)) |
1104 | { |
1152 | { |
1105 | if((GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.NumOfSats >= 4)) |
1153 | if((GPSData.Status != INVALID) && (GPSData.SatFix == SATFIX_3D) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.NumOfSats >= 4)) |
1106 | { |
1154 | { |