Subversion Repositories Projects

Rev

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

Rev 419 Rev 420
Line 57... Line 57...
57
#include <stdio.h>
57
#include <stdio.h>
58
#include "main.h"
58
#include "main.h"
59
#include "timer0.h"
59
#include "timer0.h"
60
#include "uart1.h"
60
#include "uart1.h"
61
#include "kml.h"
61
#include "kml.h"
62
//#include "gpx.h"
62
#include "gpx.h"
63
#include "ssc.h"
63
#include "ssc.h"
64
#include "settings.h"
64
#include "settings.h"
65
#include "printf_P.h"
65
#include "printf_P.h"
Line 76... Line 76...
76
        LOGFILE_ERROR
76
        LOGFILE_ERROR
77
} logfilestate_t;
77
} logfilestate_t;
Line 78... Line 78...
78
 
78
 
79
// logger handler prototypes
79
// logger handler prototypes
80
logfilestate_t Logging_KML(uint16_t LogDelay);
80
logfilestate_t Logging_KML(uint16_t LogDelay);
Line 81... Line 81...
81
//logfilestate_t Logging_GPX(uint16_t LogDelay);
81
logfilestate_t Logging_GPX(uint16_t LogDelay);
82
 
82
 
83
typedef struct
83
typedef struct
84
{
84
{
Line 113... Line 113...
113
        }
113
        }
114
        else return NULL;
114
        else return NULL;
115
}
115
}
Line 116... Line 116...
116
 
116
 
117
//----------------------------------------------------------------------------------------------------
-
 
118
/*
117
//----------------------------------------------------------------------------------------------------
119
int8_t* GenerateGPXLogFileName(void)
118
int8_t* GenerateGPXLogFileName(void)
120
{
119
{
121
        static uint16_t filenum = 0;    // file name counter
120
        static uint16_t filenum = 0;    // file name counter
122
        static int8_t filename[35];
121
        static int8_t filename[35];
Line 137... Line 136...
137
                filenum++;
136
                filenum++;
138
                return filename;
137
                return filename;
139
        }
138
        }
140
        else return NULL;
139
        else return NULL;
141
}
140
}
142
*/
-
 
Line 143... Line 141...
143
 
141
 
144
 
142
 
145
//----------------------------------------------------------------------------------------------------
143
//----------------------------------------------------------------------------------------------------
Line 265... Line 263...
265
 
263
 
266
        return logfilestate;
264
        return logfilestate;
Line 267... Line 265...
267
}
265
}
268
 
-
 
269
//----------------------------------------------------------------------------------------------------
266
 
270
/*
267
//----------------------------------------------------------------------------------------------------
271
// logs gps and state info to a gpx file
268
// logs gps and state info to a gpx file
272
logfilestate_t Logging_GPX(uint16_t LogDelay)
269
logfilestate_t Logging_GPX(uint16_t LogDelay)
273
{
270
{
274
        static  logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate
271
        static  logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate
275
        static  int8_t* logfilename = NULL;                                             // the pointer to the logfilename
272
        static  int8_t* logfilename = NULL;                                     // the pointer to the logfilename
Line 276... Line 273...
276
        static  uint16_t logtimer = 0, flushtimer = 0;          // the log update timer
273
        static  uint16_t logtimer = 0, flushtimer = 0;      // the log update timer
277
        static  GPX_Document_t logfile;                                         // the logfilehandle
274
        static  GPX_Document_t logfile;                                         // the logfilehandle
278
 
275
 
Line 296... Line 293...
296
        // no init
293
        // no init
297
        if(CheckDelay(logtimer))
294
        if(CheckDelay(logtimer))
298
        {
295
        {
299
                logtimer = SetDelay(LogDelay);  // standard interval
296
                logtimer = SetDelay(LogDelay);  // standard interval
Line 300... Line 297...
300
 
297
 
301
                //if(FC.MKFlags & MKFLAG_MOTOR_RUN)
298
                if(SysState == STATE_SEND_FOLLOWME)
302
                {
299
                {
303
                        switch(logfilestate)
300
                        switch(logfilestate)
304
                        {
301
                        {
305
                                case LOGFILE_IDLE:
302
                                case LOGFILE_IDLE:
Line 365... Line 362...
365
 
362
 
366
                                default:
363
                                default:
367
                                        logfilestate = LOGFILE_IDLE;
364
                                        logfilestate = LOGFILE_IDLE;
368
                                        break;
365
                                        break;
369
                        }
366
                        }
-
 
367
                } // EOF follow me on
-
 
368
                else // follow me off
-
 
369
                {   // close log file if opened
-
 
370
                        if(logfilestate == LOGFILE_OPENED)
-
 
371
                        {
-
 
372
                                if(GPX_DocumentClose(&logfile))
-
 
373
                                {
-
 
374
                                        printf("\r\nClosing gpx-file\r\n");
-
 
375
                                        logfilestate = LOGFILE_CLOSED;
-
 
376
                                }
-
 
377
                                else  // could not be closed
-
 
378
                                {
-
 
379
                                        printf("\r\nError closing gpx-file\r\n");
-
 
380
                                        logfilestate =  LOGFILE_ERROR;
-
 
381
                                }
-
 
382
                        }
370
                } // EOF model is flying
383
                } //EOF follow me off
Line 371... Line 384...
371
        } // EOF Check LogTimer
384
        } // EOF Check LogTimer
372
 
385
 
373
        return logfilestate;
386
        return logfilestate;
Line 374... Line 387...
374
}
387
}
375
*/
388
 
376
 
389
 
377
//----------------------------------------------------------------------------------------------------
390
//----------------------------------------------------------------------------------------------------
378
// initialize logging
391
// initialize logging
379
void Logging_Init(void)
392
void Logging_Init(void)
380
{
393
{
381
        LogCfg.KML_Interval = 500; //default
394
        LogCfg.KML_Interval = 500; //default
382
        Settings_GetParamValue(PID_KML_LOGGING, (uint16_t*)&LogCfg.KML_Interval); // overwrite by settings value
395
        Settings_GetParamValue(PID_KML_LOGGING, (uint16_t*)&LogCfg.KML_Interval); // overwrite by settings value
383
        Logging_KML(0); // initialize
396
        Logging_KML(0); // initialize
384
        //LogCfg.GPX_Interval = 1000; //default
397
        LogCfg.GPX_Interval = 1000; //default
Line 385... Line 398...
385
        //Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value
398
        Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value
386
        //Logging_GPX(0);       // initialize
399
        Logging_GPX(0); // initialize
387
}
400
}
Line 399... Line 412...
399
                if(CheckDelay(logtimer))
412
                if(CheckDelay(logtimer))
400
                {
413
                {
401
                        logtimer = SetDelay(10);  // faster makes no sense
414
                        logtimer = SetDelay(10);  // faster makes no sense
402
                        // call the logger handlers if no error has occured
415
                        // call the logger handlers if no error has occured
403
                        if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval);
416
                        if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval);
404
                        //if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
417
                        if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval);
Line 405... Line 418...
405
 
418
 
406
                        // a logging error has occured
419
                        // a logging error has occured
407
                        if(logstate == LOGFILE_ERROR)
420
                        if(logstate == LOGFILE_ERROR)
408
                        {
421
                        {