59,7 → 59,7 |
#include "timer0.h" |
#include "uart1.h" |
#include "kml.h" |
#include "gpx.h" |
//#include "gpx.h" |
#include "ssc.h" |
#include "settings.h" |
|
76,13 → 76,13 |
} logfilestate_t; |
|
// logger handler prototypes |
logfilestate_t Logging_KML(uint32_t LogDelay); |
logfilestate_t Logging_GPX(uint32_t LogDelay); |
logfilestate_t Logging_KML(uint16_t LogDelay); |
//logfilestate_t Logging_GPX(uint16_t LogDelay); |
|
typedef struct |
{ |
uint32_t KML_Interval; // the kml-log interval (0 = off) |
uint32_t GPX_Interval; // the gpx-log interval (0 = off) |
uint16_t KML_Interval; // the kml-log interval (0 = off) |
uint16_t GPX_Interval; // the gpx-log interval (0 = off) |
} LogCfg_t; |
|
LogCfg_t LogCfg = {500 , 1000}; |
114,6 → 114,7 |
} |
|
//---------------------------------------------------------------------------------------------------- |
/* |
int8_t* GenerateGPXLogFileName(void) |
{ |
static uint16_t filenum = 0; // file name counter |
137,16 → 138,16 |
} |
else return NULL; |
} |
*/ |
|
|
|
//---------------------------------------------------------------------------------------------------- |
// logs the current gps position to a kml file |
logfilestate_t Logging_KML(uint32_t LogDelay) |
logfilestate_t Logging_KML(uint16_t LogDelay) |
{ |
static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate |
static int8_t* logfilename = NULL; // the pointer to the logfilename |
static uint32_t logtimer = 0, flushtimer = 0; // the log update timer |
static uint16_t logtimer = 0, flushtimer = 0; // the log update timer |
static KML_Document_t logfile; // the logfilehandle |
|
// initialize if LogDelay os zero |
171,13 → 172,13 |
{ |
logtimer = SetDelay(LogDelay); // standard interval |
|
//if(FC.MKFlags & MKFLAG_MOTOR_RUN) |
if(SysState == STATE_SEND_FOLLOWME) |
{ |
switch(logfilestate) |
{ |
case LOGFILE_IDLE: |
case LOGFILE_CLOSED: |
//if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D) && (FC.MKFlags & MKFLAG_FLY)) |
if((GPSData.Status != INVALID) && (GPSData.Flags & FLAG_GPSFIXOK) && (GPSData.SatFix == SATFIX_3D)) |
{ |
logfilestate = LOGFILE_START; |
} |
245,8 → 246,8 |
logfilestate = LOGFILE_IDLE; |
break; |
} |
} // EOF motors are not running |
/*else // model is not flying |
} // EOF follow me on |
else // follow me off |
{ // close log file if opened |
if(logfilestate == LOGFILE_OPENED) |
{ |
258,11 → 259,11 |
else // could not be closed |
{ |
printf("\r\nError closing kml-file\r\n"); |
logfilestate = LOGFILE_ERROR; |
logfilestate = LOGFILE_ERROR; |
} |
} |
} //EOF motors are not running |
*/ |
} //EOF follow me off |
|
} // EOF Check LogTimer |
|
return logfilestate; |
269,12 → 270,13 |
} |
|
//---------------------------------------------------------------------------------------------------- |
/* |
// logs gps and state info to a gpx file |
logfilestate_t Logging_GPX(uint32_t LogDelay) |
logfilestate_t Logging_GPX(uint16_t LogDelay) |
{ |
static logfilestate_t logfilestate = LOGFILE_IDLE; // the current logfilestate |
static int8_t* logfilename = NULL; // the pointer to the logfilename |
static uint32_t logtimer = 0, flushtimer = 0; // the log update timer |
static uint16_t logtimer = 0, flushtimer = 0; // the log update timer |
static GPX_Document_t logfile; // the logfilehandle |
|
// initialize if LogDelay os zero |
373,28 → 375,11 |
break; |
} |
} // EOF model is flying |
/* |
else // model is not flying |
{ // close log file if opened |
if(logfilestate == LOGFILE_OPENED) |
{ |
if(GPX_DocumentClose(&logfile)) |
{ |
printf("\r\nClosing gpx-file\r\n"); |
logfilestate = LOGFILE_CLOSED; |
} |
else // could not be closed |
{ |
printf("\r\nError closing gpx-file\r\n"); |
logfilestate = LOGFILE_ERROR; |
} |
} |
} //EOF model is not flying |
*/ |
} // EOF Check LogTimer |
|
return logfilestate; |
} |
*/ |
|
//---------------------------------------------------------------------------------------------------- |
// initialize logging |
403,9 → 388,9 |
LogCfg.KML_Interval = 500; //default |
Settings_GetParamValue(PID_KML_LOGGING, (uint16_t*)&LogCfg.KML_Interval); // overwrite by settings value |
Logging_KML(0); // initialize |
LogCfg.GPX_Interval = 1000; //default |
Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value |
Logging_GPX(0); // initialize |
//LogCfg.GPX_Interval = 1000; //default |
//Settings_GetParamValue(PID_GPX_LOGGING, (uint16_t*)&LogCfg.GPX_Interval); // overwrite by settings value |
//Logging_GPX(0); // initialize |
} |
|
//---------------------------------------------------------------------------------------------------- |
412,7 → 397,7 |
// gobal logging handler |
void Logging_Update(void) |
{ |
static uint32_t logtimer = 0; |
static uint16_t logtimer = 0; |
static logfilestate_t logstate = LOGFILE_IDLE; |
|
|
423,8 → 408,8 |
logtimer = SetDelay(10); // faster makes no sense |
// call the logger handlers if no error has occured |
if(logstate != LOGFILE_ERROR) logstate = Logging_KML(LogCfg.KML_Interval); |
if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval); |
|
//if(logstate != LOGFILE_ERROR) logstate = Logging_GPX(LogCfg.GPX_Interval); |
|
// a logging error has occured |
if(logstate == LOGFILE_ERROR) |
{ |