kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Fix incorrect date readout and thus SD log name
rodzic
fee2909d2f
commit
994144d62d
22
main/gps.cpp
22
main/gps.cpp
|
@ -618,12 +618,26 @@ static void GPS_NMEA(void) // wh
|
|||
if(NMEA.isGxGSV()) ProcessGSV(NMEA); // process satellite data
|
||||
else if(NMEA.isGxRMC())
|
||||
{ int8_t SameTime = GPS_DateTime.ReadTime((const char *)NMEA.ParmPtr(0)); // 1=same time, 0=diff. time, -1=error
|
||||
if(SameTime==0 && GPS_Burst.GxRMC) { GPS_BurstComplete(); GPS_BurstEnd(); GPS_BurstStart(NMEA.Len); }
|
||||
if(SameTime==0 && GPS_Burst.GxGGA) { GPS_BurstComplete(); GPS_BurstEnd(); GPS_BurstStart(NMEA.Len); }
|
||||
GPS_DateTime.ReadDate((const char *)NMEA.ParmPtr(8));
|
||||
#ifdef DEBUG_PRINT
|
||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||
Format_String(CONS_UART_Write, "GPS_NMEA() RMC ");
|
||||
Format_SignDec(CONS_UART_Write, (int16_t)(GPS_DateTime.Year), 2);
|
||||
Format_String(CONS_UART_Write, "\n");
|
||||
xSemaphoreGive(CONS_Mutex);
|
||||
#endif
|
||||
GPS_Burst.GxRMC=1; }
|
||||
else if(NMEA.isGxGGA())
|
||||
{ int8_t SameTime = GPS_DateTime.ReadTime((const char *)NMEA.ParmPtr(0)); // 1=same time, 0=diff. time, -1=error
|
||||
if(SameTime==0 && GPS_Burst.GxGGA) { GPS_BurstComplete(); GPS_BurstEnd(); GPS_BurstStart(NMEA.Len); }
|
||||
GPS_DateTime.ReadDate((const char *)NMEA.ParmPtr(6));
|
||||
if(SameTime==0 && GPS_Burst.GxRMC) { GPS_BurstComplete(); GPS_BurstEnd(); GPS_BurstStart(NMEA.Len); }
|
||||
#ifdef DEBUG_PRINT
|
||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||
Format_String(CONS_UART_Write, "GPS_NMEA() GGA ");
|
||||
Format_SignDec(CONS_UART_Write, (int16_t)(GPS_DateTime.Sec), 2);
|
||||
Format_String(CONS_UART_Write, "s\n");
|
||||
xSemaphoreGive(CONS_Mutex);
|
||||
#endif
|
||||
GPS_Burst.GxGGA=1; }
|
||||
else if(NMEA.isGxGSA())
|
||||
{ GPS_Burst.GxGSA=1; }
|
||||
|
@ -645,7 +659,7 @@ static void GPS_NMEA(void) // wh
|
|||
// bool RatePass=0;
|
||||
// Count++; if(Count>=5) { Count=0; RatePass=1; }
|
||||
// if( NMEA.isP() || NMEA.isGxRMC() || NMEA.isGxGGA() || NMEA.isGxGSA() || NMEA.isGxGSV() || NMEA.isGPTXT()) )
|
||||
if( NMEA.isP() || NMEA.isBD() || NMEA.isGx() )
|
||||
// if( NMEA.isP() || NMEA.isBD() || NMEA.isGx() )
|
||||
// we would need to patch the GGA here for the GPS which does not calc. nor correct for GeoidSepar
|
||||
#endif
|
||||
{ if(Parameters.Verbose)
|
||||
|
|
|
@ -807,7 +807,7 @@ class GPS_Time
|
|||
if(Len==1) mSec = Frac*100;
|
||||
else if(Len==2) mSec = Frac*10;
|
||||
else if(Len==3) mSec = Frac;
|
||||
else if(Len==4) mSec = Frac/10;
|
||||
else if(Len==4) mSec = Frac/10;
|
||||
else return -1; }
|
||||
if(mPrev!=mSec) Same=0; // return 0 when time is valid but did not change
|
||||
return Same; } // return 1 when time did not change (both RMC and GGA were for same time)
|
||||
|
|
|
@ -39,11 +39,20 @@ static int Log_Open(void)
|
|||
// int32_t Year = (LogDate>>9)-20;
|
||||
int32_t Day = GPS_DateTime.Day; // get day, month, year
|
||||
int32_t Month = GPS_DateTime.Month;
|
||||
int32_t Year = GPS_DateTime.Year-20;
|
||||
int32_t Year = GPS_DateTime.Year;
|
||||
uint32_t Date = 0;
|
||||
if(Year>=0) Date = Day*10000 + Month*100 + Year; // create DDMMYY number for easy printout
|
||||
if(Year>=20 && Year<70) Date = Year*10000 + Month*100 + Day; // create YYMMDD number for easy printout and sort
|
||||
strcpy(LogFileName, "/sdcard/CONS/TR000000.LOG");
|
||||
Format_UnsDec(LogFileName+15, Date, 6); // format the date into the log file name
|
||||
#ifdef DEBUG_PRINT
|
||||
xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
||||
Format_String(CONS_UART_Write, "Log_Open() ");
|
||||
Format_String(CONS_UART_Write, LogFileName);
|
||||
Format_String(CONS_UART_Write, " Year:");
|
||||
Format_SignDec(CONS_UART_Write, Year);
|
||||
Format_String(CONS_UART_Write, "\n");
|
||||
xSemaphoreGive(CONS_Mutex);
|
||||
#endif
|
||||
LogFile = fopen(LogFileName, "at"); // try to open the file
|
||||
if(LogFile==0) // if this fails
|
||||
{ if(mkdir("/sdcard/CONS", 0777)<0) return -1; // try to create the sub-directory
|
||||
|
|
Ładowanie…
Reference in New Issue