Subversion Repositories NaviCtrl

Rev

Rev 360 | Rev 396 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 360 Rev 368
1
/*#######################################################################################*/
1
/*#######################################################################################*/
2
/* !!! THIS IS NOT FREE SOFTWARE !!!                                                     */
2
/* !!! THIS IS NOT FREE SOFTWARE !!!                                                     */
3
/*#######################################################################################*/
3
/*#######################################################################################*/
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5
// + www.MikroKopter.com
5
// + www.MikroKopter.com
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
7
// + Software Nutzungsbedingungen (english version: see below)
7
// + Software Nutzungsbedingungen (english version: see below)
8
// + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt -
8
// + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt -
9
// + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den
9
// + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den
10
// + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool 
10
// + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool 
11
// + - nachfolgend Software genannt - nur für private Zwecke zu nutzen.
11
// + - nachfolgend Software genannt - nur für private Zwecke zu nutzen.
12
// + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig.
12
// + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig.
13
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
13
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14
// + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im
14
// + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im
15
// + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu.
15
// + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu.
16
// + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie
16
// + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie
17
// + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden.
17
// + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden.
18
// + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren
18
// + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren
19
// + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
19
// + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
20
// + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren
20
// + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren
21
// + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand 
21
// + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand 
22
// + des Mitverschuldens offen.
22
// + des Mitverschuldens offen.
23
// + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet.
23
// + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet.
24
// + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
24
// + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt.
25
// + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern.
25
// + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern.
26
// + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang
26
// + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang
27
// + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt.
27
// + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt.
28
// + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software.
28
// + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software.
29
// + #### ENDE DER NUTZUNGSBEDINGUNGEN ####'
29
// + #### ENDE DER NUTZUNGSBEDINGUNGEN ####'
30
// +  Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar.
30
// +  Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar.
31
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32
// + Software LICENSING TERMS
32
// + Software LICENSING TERMS
33
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
34
// + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor -
34
// + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor -
35
// + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware 
35
// + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware 
36
// + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*.
36
// + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*.
37
// + The Software may only be used with the Licensor's products.
37
// + The Software may only be used with the Licensor's products.
38
// + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this
38
// + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this
39
// + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this
39
// + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this
40
// + agreement shall be the property of the Licensor.
40
// + agreement shall be the property of the Licensor.
41
// + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other
41
// + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other
42
// + features that can be used to identify the program may not be altered or defaced by the customer.
42
// + features that can be used to identify the program may not be altered or defaced by the customer.
43
// + The customer shall be responsible for taking reasonable precautions
43
// + The customer shall be responsible for taking reasonable precautions
44
// + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the
44
// + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the
45
// + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and
45
// + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and
46
// + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product
46
// + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product
47
// + liability. However, the Licensor shall be entitled to the defense of contributory negligence.
47
// + liability. However, the Licensor shall be entitled to the defense of contributory negligence.
48
// + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test
48
// + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test
49
// + the software for his purpose before any operational usage. The customer will backup his data before using the software.
49
// + the software for his purpose before any operational usage. The customer will backup his data before using the software.
50
// + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data
50
// + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data
51
// + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations.
51
// + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations.
52
// + *) The territory aspect only refers to the place where the Software is used, not its programmed range.
52
// + *) The territory aspect only refers to the place where the Software is used, not its programmed range.
53
// + #### END OF LICENSING TERMS ####
53
// + #### END OF LICENSING TERMS ####
54
// + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de.
54
// + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de.
55
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
56
 
56
 
57
#include <stdio.h>
57
#include <stdio.h>
58
#include <stdarg.h>
58
#include <stdarg.h>
59
#include <string.h>
59
#include <string.h>
60
#include "91x_lib.h"
60
#include "91x_lib.h"
61
#include "config.h"
61
#include "config.h"
62
#include "main.h"
62
#include "main.h"
63
#include "fat16.h"
63
#include "fat16.h"
64
#include "ftphelper.h"
64
#include "ftphelper.h"
65
#include "mkprotocol.h"
65
#include "mkprotocol.h"
66
#include "debug.h"
66
#include "debug.h"
67
#include "uart1.h"
67
#include "uart1.h"
68
 
68
 
69
 
69
 
70
typedef struct
70
typedef struct
71
{
71
{
72
  u8            Name[13];
72
  u8            Name[13];
73
  u8            Attribute;
73
  u8            Attribute;
74
  u32           Size;
74
  u32           Size;
75
 
75
 
76
} __attribute__((packed)) FTP_direntry_t;
76
} __attribute__((packed)) FTP_direntry_t;
77
 
77
 
78
FTP_direntry_t FTP_direntry;
78
FTP_direntry_t FTP_direntry;
79
 
79
 
80
char FTP_data[DATA_TRANSFER_SIZE+1];                              //  rx & tx buffer to avoid 2 buffers
80
char FTP_data[DATA_TRANSFER_SIZE+1];                              //  rx & tx buffer to avoid 2 buffers
81
 
81
 
82
u16 CompressBuffer(char *buf, u16 size, u16 offset)
82
u16 CompressBuffer(char *buf, u16 size, u16 offset)
83
{
83
{
84
  #define KEYWORD_COUNT 27
84
  #define KEYWORD_COUNT 27
85
 
85
 
86
  const char keyword[KEYWORD_COUNT][16]=
86
  const char keyword[KEYWORD_COUNT][16]=
87
                                        {"Altimeter>\0    \0",
87
                                        {"Altimeter>\0    \0",
88
                                         "Current>\0      \0",
88
                                         "Current>\0      \0",
89
                                         "Variometer>\0   \0",
89
                                         "Variometer>\0   \0",
90
                                         "GroundSpeed>\0  \0",
90
                                         "GroundSpeed>\0  \0",
91
                                         "VerticalSpeed>\0\0",
91
                                         "VerticalSpeed>\0\0",
92
                                         "FlightTime>\0   \0",
92
                                         "FlightTime>\0   \0",
93
                                         "Voltage>\0      \0",
93
                                         "Voltage>\0      \0",
94
                                         "Capacity>\0     \0",
94
                                         "Capacity>\0     \0",
95
                                         "RCQuality>\0    \0",
95
                                         "RCQuality>\0    \0",
96
                                         "RCRSSI>\0       \0",
96
                                         "RCRSSI>\0       \0",
97
                                         "Compass>\0      \0",
97
                                         "Compass>\0      \0",
98
                                         "NickAngle>\0    \0",
98
                                         "NickAngle>\0    \0",
99
                                         "RollAngle>\0    \0",
99
                                         "RollAngle>\0    \0",
100
                                         "NCFlag>\0       \0",
100
                                         "NCFlag>\0       \0",
101
                                         "ErrorCode>\0    \0",
101
                                         "ErrorCode>\0    \0",
102
                                         "TargetBearing>\0\0",
102
                                         "TargetBearing>\0\0",
103
                                         "RCSticks>\0     \0",
103
                                         "RCSticks>\0     \0",
104
                                         "GPSSticks>\0    \0",
104
                                         "GPSSticks>\0    \0",
105
                                         "extensions>\0   \0",
105
                                         "extensions>\0   \0",
106
                                         "Course>\0       \0",
106
                                         "Course>\0       \0",
107
                                         "trkpt\0         \0",
107
                                         "trkpt\0         \0",
108
                                         "time>\0         \0",
108
                                         "time>\0         \0",
109
                                         "sat>\0          \0",
109
                                         "sat>\0          \0",
110
                                         "ele>\0          \0",
110
                                         "ele>\0          \0",
111
                                         " lat=\0         \0",
111
                                         " lat=\0         \0",
112
                                         " lon=\0         \0",
112
                                         " lon=\0         \0",
113
                                         "TargetDistance>\0" };
113
                                         "TargetDistance>\0" };
114
  u16 i, count = size;
114
  u16 i, count = size;
115
  char *s = NULL, *start = buf+offset;
115
  char *s = NULL, *start = buf+offset;
116
 
116
 
117
   for ( i = 0; i < KEYWORD_COUNT; i++)
117
   for ( i = 0; i < KEYWORD_COUNT; i++)
118
   {
118
   {
119
                s = strstr(start, keyword[i]);
119
                s = strstr(start, keyword[i]);
120
                if (s != NULL)
120
                if (s != NULL)
121
                {       u8 keylen = strlen(keyword[i]);
121
                {       u8 keylen = strlen(keyword[i]);
122
                        *s= 27;  
122
                        *s= 27;  
123
                        *(s+1) = i+1;
123
                        *(s+1) = i+1;
124
                        count-= (keylen-2);
124
                        count-= (keylen-2);
125
                        memcpy(s+2, s+keylen, count - (s-buf));
125
                        memcpy(s+2, s+keylen, count - (s-buf));
126
                        i--;
126
                        i--;
127
                }
127
                }
128
        }
128
        }
129
   
129
   
130
   return (count);
130
   return (count);
131
}
131
}
132
// --------------------------------------------------------------------
132
// --------------------------------------------------------------------
133
void CheckFTPCommand(u8 FTP_command)
133
void CheckFTPCommand(u8 FTP_command)
134
{
134
{
-
 
135
/*
135
  static Find_t fe;
136
  static Find_t fe;
136
  static File_t *fp = NULL;
137
  static File_t *fp = NULL;
137
  static u8 blockindex, compressLevel = 0;
138
  static u8 blockindex, compressLevel = 0;
138
 
139
 
139
  u32 filesize;
140
  u32 filesize;
140
 
141
 
141
  switch (FTP_command)
142
  switch (FTP_command)
142
  {
143
  {
143
        case FTP_CMD_FINDFIRST:
144
        case FTP_CMD_FINDFIRST:
144
                FTP_direntry.Name[0] = 0;
145
                FTP_direntry.Name[0] = 0;
145
                if (findfirst_("*.*", 0x35, &fe))
146
                if (findfirst_("*.*", 0x35, &fe))
146
                {
147
                {
147
                  memcpy(&FTP_direntry.Name, &fe.name, 13);    
148
                  memcpy(&FTP_direntry.Name, &fe.name, 13);    
148
                  FTP_direntry.Attribute = fe.fp.Attribute;
149
                  FTP_direntry.Attribute = fe.fp.Attribute;
149
                  FTP_direntry.Size = fe.fp.Size;
150
                  FTP_direntry.Size = fe.fp.Size;
150
                 // Debug(FTP_direntry.Name);
151
                 // Debug(FTP_direntry.Name);
151
                }
152
                }
152
               
153
               
153
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 2, &FTP_command, 1, &FTP_direntry, sizeof(FTP_direntry));
154
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 2, &FTP_command, 1, &FTP_direntry, sizeof(FTP_direntry));
154
        break;
155
        break;
155
       
156
       
156
        case FTP_CMD_FINDNEXT:
157
        case FTP_CMD_FINDNEXT:
157
       
158
       
158
                FTP_direntry.Name[0] = 0;
159
                FTP_direntry.Name[0] = 0;
159
 
160
 
160
                if (findnext_(&fe))
161
                if (findnext_(&fe))
161
                {
162
                {
162
                  memcpy(&FTP_direntry.Name, &fe.name, 13);    
163
                  memcpy(&FTP_direntry.Name, &fe.name, 13);    
163
                  FTP_direntry.Attribute = fe.fp.Attribute;
164
                  FTP_direntry.Attribute = fe.fp.Attribute;
164
                  FTP_direntry.Size = fe.fp.Size;
165
                  FTP_direntry.Size = fe.fp.Size;
165
                 // Debug(FTP_direntry.Name);
166
                 // Debug(FTP_direntry.Name);
166
                }
167
                }
167
               
168
               
168
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 2, &FTP_command, 1, &FTP_direntry, sizeof(FTP_direntry));
169
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 2, &FTP_command, 1, &FTP_direntry, sizeof(FTP_direntry));
169
        break;
170
        break;
170
       
171
       
171
        case FTP_CMD_GET_CWD:
172
        case FTP_CMD_GET_CWD:
172
                {
173
                {
173
                char data_null = 0;
174
                char data_null = 0;
174
                        MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 3, &FTP_command, 1, GetPath(), strlen(GetPath()), &data_null, 1 );
175
                        MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 3, &FTP_command, 1, GetPath(), strlen(GetPath()), &data_null, 1 );
175
                }
176
                }
176
               
177
               
177
        break;
178
        break;
178
       
179
       
179
        case FTP_CMD_SET_CWD:
180
        case FTP_CMD_SET_CWD:
180
               
181
               
181
                chdir_(FTP_data);
182
                chdir_(FTP_data);
182
        break;
183
        break;
183
       
184
       
184
        case FTP_CMD_OPEN_FILE:
185
        case FTP_CMD_OPEN_FILE:
185
                {
186
                {
186
                u8 filefound;
187
                u8 filefound;
187
                       
188
                       
188
                compressLevel = FTP_data[0];
189
                compressLevel = FTP_data[0];
189
                fp = fopen_(&FTP_data[1], 'r');
190
                fp = fopen_(&FTP_data[1], 'r');
190
                if (fp != NULL)
191
                if (fp != NULL)
191
                {
192
                {
192
                  filefound = 1;
193
                  filefound = 1;
193
                  filesize = fp->Size;
194
                  filesize = fp->Size;
194
                  blockindex = 0;                                                                               // reset index counter
195
                  blockindex = 0;                                                                               // reset index counter
195
                }
196
                }
196
                else filefound = 0;                                                                             // this means, no valid file found for transfer
197
                else filefound = 0;                                                                             // this means, no valid file found for transfer
197
 
198
 
198
 
199
 
199
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 3, &FTP_command, 1, &filefound, 1, &filesize, sizeof(filesize));
200
                MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 3, &FTP_command, 1, &filefound, 1, &filesize, sizeof(filesize));
200
                }
201
                }
201
        break;
202
        break;
202
 
203
 
203
        case FTP_CMD_GET_FILE_DATA:
204
        case FTP_CMD_GET_FILE_DATA:
204
                {
205
                {
205
                  u16 size = DATA_TRANSFER_SIZE;
206
                  u16 size = DATA_TRANSFER_SIZE;
206
                 
207
                 
207
                if (FTP_data[0] == blockindex + 1)                                      // next block is requested
208
                if (FTP_data[0] == blockindex + 1)                                      // next block is requested
208
                 {
209
                 {
209
                   blockindex++;                                       
210
                   blockindex++;                                       
210
                 }
211
                 }
211
                 else if (FTP_data[0] == blockindex)                                    // repeat last block
212
                 else if (FTP_data[0] == blockindex)                                    // repeat last block
212
                 {
213
                 {
213
                    fseek_(fp, SEEK_CUR, -DATA_TRANSFER_SIZE);                  // set filepointer to beginning of last block
214
                    fseek_(fp, SEEK_CUR, -DATA_TRANSFER_SIZE);                  // set filepointer to beginning of last block
214
                 }                                                                                                             
215
                 }                                                                                                             
215
                 else blockindex = FTP_data[0]+ 10;                                             // ABORT transfer,  blockindex now out of valid range
216
                 else blockindex = FTP_data[0]+ 10;                                             // ABORT transfer,  blockindex now out of valid range
216
         
217
         
217
                 fread_(FTP_data, DATA_TRANSFER_SIZE, 1, fp);                           // read data block to buffer);
218
                 fread_(FTP_data, DATA_TRANSFER_SIZE, 1, fp);                           // read data block to buffer);
218
                 FTP_data[DATA_TRANSFER_SIZE] = 0;             
219
                 FTP_data[DATA_TRANSFER_SIZE] = 0;             
219
           
220
           
220
             if (compressLevel)
221
             if (compressLevel)
221
                 {
222
                 {
222
                        size = CompressBuffer(FTP_data, DATA_TRANSFER_SIZE, 0);
223
                        size = CompressBuffer(FTP_data, DATA_TRANSFER_SIZE, 0);
223
                               
224
                               
224
                         if (compressLevel > 1)
225
                         if (compressLevel > 1)
225
                         {
226
                         {
226
                                if (size < DATA_TRANSFER_SIZE - 50)
227
                                if (size < DATA_TRANSFER_SIZE - 50)
227
                                 {              
228
                                 {              
228
                                        fread_(&FTP_data[size], DATA_TRANSFER_SIZE - size, 1, fp);                              // read data block to buffer);          
229
                                        fread_(&FTP_data[size], DATA_TRANSFER_SIZE - size, 1, fp);                              // read data block to buffer);         
229
                                        FTP_data[DATA_TRANSFER_SIZE] = 0;              
230
                                        FTP_data[DATA_TRANSFER_SIZE] = 0;              
230
                                   size = CompressBuffer(FTP_data, DATA_TRANSFER_SIZE, size);
231
                                   size = CompressBuffer(FTP_data, DATA_TRANSFER_SIZE, size);
231
                                }
232
                                }
232
                         }
233
                         }
233
                 }
234
                 }
234
                 
235
                 
235
                 MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 4, &FTP_command, 1, &blockindex, 1, &size, 2, &FTP_data, size);
236
                 MKProtocol_CreateSerialFrame(&UART1_tx_buffer, 'F', NC_ADDRESS, 4, &FTP_command, 1, &blockindex, 1, &size, 2, &FTP_data, size);
236
                }
237
                }
237
        break;
238
        break;
238
 
239
 
239
        case FTP_CMD_CLOSE_FILE:
240
        case FTP_CMD_CLOSE_FILE:
240
                fclose_(fp);
241
                fclose_(fp);
241
                Debug("ftp: CloseFile");               
242
                Debug("ftp: CloseFile");               
242
 
243
 
243
        break;
244
        break;
244
 
245
 
245
        case FTP_CMD_NONE:
246
        case FTP_CMD_NONE:
246
        default:
247
        default:
247
                FTP_command = FTP_CMD_NONE;
248
                FTP_command = FTP_CMD_NONE;
248
                Debug("ftp: CMD None");
249
                Debug("ftp: CMD None");
249
        break;
250
        break;
250
  }
251
  }
-
 
252
*/
251
}
253
}
252
 
254
 
253
 
255
 
254
 
256