Rev 310 | Rev 350 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 310 | Rev 345 | ||
---|---|---|---|
Line 274... | Line 274... | ||
274 | { |
274 | { |
275 | static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate |
275 | static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate |
276 | static s8* logfilename = NULL; // the pointer to the logfilename |
276 | static s8* logfilename = NULL; // the pointer to the logfilename |
277 | static u32 logtimer = 0, flushtimer = 0; // the log update timer |
277 | static u32 logtimer = 0, flushtimer = 0; // the log update timer |
278 | static GPX_Document_t logfile; // the logfilehandle |
278 | static GPX_Document_t logfile; // the logfilehandle |
- | 279 | static u8 part = 0; |
|
- | 280 | u32 measure_time; |
|
Line 279... | Line 281... | ||
279 | 281 | ||
280 | // initialize if LogDelay is zero |
282 | // initialize if LogDelay is zero |
281 | if(!LogDelay) |
283 | if(!LogDelay) |
282 | { |
284 | { |
Line 293... | Line 295... | ||
293 | GPX_DocumentInit(&logfile); |
295 | GPX_DocumentInit(&logfile); |
294 | logtimer = SetDelay(0); // set logtimer to now |
296 | logtimer = SetDelay(0); // set logtimer to now |
295 | return logfilestate; |
297 | return logfilestate; |
296 | } |
298 | } |
297 | // no init |
299 | // no init |
298 | if(CheckDelay(logtimer)) |
300 | if(CheckDelay(logtimer) || part) |
299 | { |
301 | { |
300 | logtimer = SetDelay(LogDelay); // standard interval |
302 | logtimer = SetDelay(LogDelay); // standard interval |
Line 301... | Line 303... | ||
301 | 303 | ||
302 | if(FC.StatusFlags & FC_STATUS_MOTOR_RUN) |
304 | if(FC.StatusFlags & FC_STATUS_MOTOR_RUN || part) |
303 | { |
305 | { |
304 | switch(logfilestate) |
306 | switch(logfilestate) |
305 | { |
307 | { |
306 | case LOGFILE_IDLE: |
308 | case LOGFILE_IDLE: |
307 | case LOGFILE_CLOSED: |
309 | case LOGFILE_CLOSED: |
308 | if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.StatusFlags & FC_STATUS_FLY)) |
310 | if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.StatusFlags & FC_STATUS_FLY)) |
309 | { |
311 | { |
310 | logfilestate = LOGFILE_START; |
312 | logfilestate = LOGFILE_START; |
- | 313 | } |
|
311 | } |
314 | part = 0; |
312 | break; |
315 | break; |
313 | case LOGFILE_START: |
316 | case LOGFILE_START: |
314 | // find unused logfile name |
317 | // find unused logfile name |
315 | do |
318 | do |
Line 341... | Line 344... | ||
341 | { |
344 | { |
342 | logfilestate = LOGFILE_ERROR; |
345 | logfilestate = LOGFILE_ERROR; |
343 | UART1_PutString("\r\nError getting free gpx-file name\r\n"); |
346 | UART1_PutString("\r\nError getting free gpx-file name\r\n"); |
344 | } |
347 | } |
345 | // else retry in next loop |
348 | // else retry in next loop |
- | 349 | part = 0; |
|
346 | break; |
350 | break; |
347 | case LOGFILE_OPENED: |
351 | case LOGFILE_OPENED: |
348 | // append new gps log data |
352 | // append new gps log data |
- | 353 | measure_time = CountMilliseconds; |
|
349 | if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D)) |
354 | if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D)) |
350 | { |
355 | { |
351 | if(!GPX_LoggGPSCoordinates(&logfile)) |
356 | if(!GPX_LoggGPSCoordinates(&logfile,part)) |
352 | { // error logging data |
357 | { // error logging data |
353 | UART1_PutString("\r\nError logging to gpx-file\r\n"); |
358 | UART1_PutString("\r\nError logging to gpx-file\r\n"); |
354 | GPX_DocumentClose(&logfile); |
359 | GPX_DocumentClose(&logfile); |
355 | logfilestate = LOGFILE_ERROR; |
360 | logfilestate = LOGFILE_ERROR; |
356 | } |
361 | } |
Line 361... | Line 366... | ||
361 | flushtimer = SetDelay(LOG_FLUSH_INTERVAL); |
366 | flushtimer = SetDelay(LOG_FLUSH_INTERVAL); |
362 | fflush_(logfile.file); |
367 | fflush_(logfile.file); |
363 | } |
368 | } |
364 | } |
369 | } |
365 | } |
370 | } |
- | 371 | if(++part == 9) part = 0; |
|
- | 372 | DebugOut.Analog[19] = CountMilliseconds - measure_time; |
|
366 | break; |
373 | break; |
Line 367... | Line 374... | ||
367 | 374 | ||
- | 375 | case LOGFILE_ERROR: |
|
368 | case LOGFILE_ERROR: |
376 | part = 0; |
Line 369... | Line 377... | ||
369 | break; |
377 | break; |
- | 378 | ||
370 | 379 | default: |
|
371 | default: |
380 | part = 0; |
372 | logfilestate = LOGFILE_IDLE; |
381 | logfilestate = LOGFILE_IDLE; |
373 | break; |
382 | break; |
374 | } |
383 | } |
Line 379... | Line 388... | ||
379 | { |
388 | { |
380 | if(GPX_DocumentClose(&logfile)) |
389 | if(GPX_DocumentClose(&logfile)) |
381 | { |
390 | { |
382 | UART1_PutString("\r\nClosing gpx-file\r\n"); |
391 | UART1_PutString("\r\nClosing gpx-file\r\n"); |
383 | logfilestate = LOGFILE_CLOSED; |
392 | logfilestate = LOGFILE_CLOSED; |
- | 393 | part = 0; |
|
384 | } |
394 | } |
385 | else // could not be closed |
395 | else // could not be closed |
386 | { |
396 | { |
387 | UART1_PutString("\r\nError closing gpx-file\r\n"); |
397 | UART1_PutString("\r\nError closing gpx-file\r\n"); |
388 | logfilestate = LOGFILE_ERROR; |
398 | logfilestate = LOGFILE_ERROR; |
- | 399 | part = 0; |
|
389 | } |
400 | } |
390 | } |
401 | } |
391 | } //EOF model is not flying |
402 | } //EOF model is not flying |
392 | } // EOF Check LogTimer |
403 | } // EOF Check LogTimer |