kopia lustrzana https://github.com/pjalocha/esp32-ogn-tracker
Porównaj commity
4 Commity
ae91503a71
...
adcbeda815
Autor | SHA1 | Data |
---|---|---|
Pawel Jalocha | adcbeda815 | |
Pawel Jalocha | f448e4cf8b | |
Pawel Jalocha | 916765929b | |
Pawel Jalocha | 196589f2dc |
|
@ -173,6 +173,7 @@ static void ProcessGSV(NMEA_RxMsg &GSV) // process GxGSV to extract
|
||||||
if(GSV.isGPGSV()) { SatSys=0; }
|
if(GSV.isGPGSV()) { SatSys=0; }
|
||||||
else if(GSV.isGLGSV()) { SatSys=1; }
|
else if(GSV.isGLGSV()) { SatSys=1; }
|
||||||
else if(GSV.isGAGSV()) { SatSys=2; }
|
else if(GSV.isGAGSV()) { SatSys=2; }
|
||||||
|
else if(GSV.isBDGSV()) { SatSys=3; }
|
||||||
else return;
|
else return;
|
||||||
if(GSV.Parms<3) return;
|
if(GSV.Parms<3) return;
|
||||||
int8_t Pkts=Read_Dec1((const char *)GSV.ParmPtr(0)); if(Pkts<0) return; // how many packets to pass all sats
|
int8_t Pkts=Read_Dec1((const char *)GSV.ParmPtr(0)); if(Pkts<0) return; // how many packets to pass all sats
|
||||||
|
|
56
main/log.cpp
56
main/log.cpp
|
@ -30,13 +30,13 @@ static const uint32_t FlashLog_MaxTime = 3600; // 1 hour max. per single log
|
||||||
static const uint32_t FlashLog_MaxSize = 0x10000; // 64KB max. per single log file
|
static const uint32_t FlashLog_MaxSize = 0x10000; // 64KB max. per single log file
|
||||||
#ifdef WITH_SPIFFS_FAT
|
#ifdef WITH_SPIFFS_FAT
|
||||||
static const uint32_t FlashLog_SavePeriod = 30; // [sec] reopen the file every 30sec
|
static const uint32_t FlashLog_SavePeriod = 30; // [sec] reopen the file every 30sec
|
||||||
static const uint32_t FlashLog_SaveSize = 4096; // [bytes] reopen the file every 4KB
|
static const uint32_t FlashLog_SaveSize = 4096; // [bytes] reopen the file every 4KB
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool FlashLog_SaveReq=0; // request to save the log right away, like after landing or before shutdown
|
bool FlashLog_SaveReq=0; // request to save the log right away, like after landing or before shutdown
|
||||||
uint32_t FlashLog_FileTime=0; // [sec] UTC time corresponding to the log file
|
uint32_t FlashLog_FileTime=0; // [sec] UTC time corresponding to the log file
|
||||||
char FlashLog_FileName[32]; // current log file name if open
|
char FlashLog_FileName[32]; // current log file name if open
|
||||||
static FILE *FlashLog_File=0; // current log file if open
|
static FILE * FlashLog_File=0; // current log file if open
|
||||||
static uint32_t FlashLog_FileFlush=0; // track where the log file has been forced to be written to flash
|
static uint32_t FlashLog_FileFlush=0; // track where the log file has been forced to be written to flash
|
||||||
|
|
||||||
FIFO<OGN_LogPacket<OGN_Packet>, 32> FlashLog_FIFO;
|
FIFO<OGN_LogPacket<OGN_Packet>, 32> FlashLog_FIFO;
|
||||||
|
@ -292,12 +292,12 @@ static int FlashLog_Open(uint32_t Time) // open a new
|
||||||
if(FlashLog_File==0) FlashLog_Clean(0, 4); // if the file cannot be open clean again
|
if(FlashLog_File==0) FlashLog_Clean(0, 4); // if the file cannot be open clean again
|
||||||
return FlashLog_File!=0; } // 1=success, 0=failure: new log file could not be open
|
return FlashLog_File!=0; } // 1=success, 0=failure: new log file could not be open
|
||||||
|
|
||||||
static void FlashLog_Reopen(void)
|
static void FlashLog_Reopen(void) // force close and re-open the current log file
|
||||||
{ if(FlashLog_File)
|
{ if(FlashLog_File) // if log File is open
|
||||||
{ fclose(FlashLog_File);
|
{ fclose(FlashLog_File); // close it
|
||||||
FlashLog_File = fopen(FlashLog_FileName, "ab");
|
FlashLog_File = fopen(FlashLog_FileName, "ab"); // open it again for append with same filename
|
||||||
FlashLog_FileFlush = ftell(FlashLog_File); }
|
FlashLog_FileFlush = ftell(FlashLog_File); } // track how much has been pysically written
|
||||||
FlashLog_SaveReq=0; }
|
FlashLog_SaveReq=0; } // clear q possible request to save the file
|
||||||
|
|
||||||
static int FlashLog_Record(OGN_LogPacket<OGN_Packet> *Packet, int Packets, uint32_t Time) // log a batch of OGN packets
|
static int FlashLog_Record(OGN_LogPacket<OGN_Packet> *Packet, int Packets, uint32_t Time) // log a batch of OGN packets
|
||||||
{ if(FlashLog_File) // if log file already open
|
{ if(FlashLog_File) // if log file already open
|
||||||
|
@ -381,27 +381,23 @@ void vTaskLOG(void* pvParameters)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TickType_t PrevTick = 0;
|
TickType_t PrevTick = 0; // [ms] Time when packets stored the last time
|
||||||
for( ; ; )
|
for( ; ; )
|
||||||
{ // vTaskDelay(200); // wait idle 0.2sec
|
{ vTaskDelay(1);
|
||||||
if(FlashLog_SaveReq) FlashLog_Reopen(); // if requested then save the current log (close + reopen)
|
bool Flying = Flight.inFlight(); // if the aircraft flying ?
|
||||||
TickType_t Tick=xTaskGetTickCount(); // system tick count now
|
|
||||||
size_t Packets = FlashLog_FIFO.Full(); // how many packets in the queue ?
|
size_t Packets = FlashLog_FIFO.Full(); // how many packets in the queue ?
|
||||||
// #ifdef DEBUG_PRINT
|
if(Flying) // when flying
|
||||||
// xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
|
{ if(FlashLog_SaveReq) FlashLog_Reopen(); // if requested then save the current log (close + reopen)
|
||||||
// Format_String(CONS_UART_Write, "TaskLOG() ");
|
TickType_t Tick=xTaskGetTickCount(); // system tick count now
|
||||||
// Format_UnsDec(CONS_UART_Write, Tick, 4, 3);
|
if(Packets==0) { PrevTick=Tick; vTaskDelay(100); continue; } // if none: then give up
|
||||||
// Format_String(CONS_UART_Write, "(");
|
if(Packets>=8) { Copy(); PrevTick=Tick; continue; } // if 8 or more packets then copy them to the log file
|
||||||
// Format_UnsDec(CONS_UART_Write, PrevTick, 4, 3);
|
TickType_t Diff = Tick-PrevTick; // time since last log action
|
||||||
// Format_String(CONS_UART_Write, ")s: ");
|
if(Diff>=8000) { Copy(); PrevTick=Tick; continue; } // if more than 8.0sec than copy the packets
|
||||||
// Format_UnsDec(CONS_UART_Write, Packets);
|
} else // when not flying
|
||||||
// Format_String(CONS_UART_Write, " packets\n");
|
{ if(FlashLog_File) { fclose(FlashLog_File); FlashLog_File=0; } // if file open then close it
|
||||||
// xSemaphoreGive(CONS_Mutex);
|
while(FlashLog_FIFO.Full()>=FlashLog_FIFO.Len/2) // flush the packet queue but keep it half-full
|
||||||
// #endif
|
{ FlashLog_FIFO.Read(); vTaskDelay(1); }
|
||||||
if(Packets==0) { PrevTick=Tick; vTaskDelay(100); continue; } // if none: then give up
|
}
|
||||||
if(Packets>=8) { Copy(); PrevTick=Tick; continue; } // if 8 or more packets then copy them to the log file
|
|
||||||
TickType_t Diff = Tick-PrevTick; // time since last log action
|
|
||||||
if(Diff>=8000) { Copy(); PrevTick=Tick; continue; } // if more than 8.0sec than copy the packets
|
|
||||||
vTaskDelay(100); }
|
vTaskDelay(100); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,12 @@ inline uint8_t NMEA_AppendCheckCRNL(char *NMEA, uint8_t Len) { return NMEA_Appen
|
||||||
if(Data[4]!='S') return 0;
|
if(Data[4]!='S') return 0;
|
||||||
return Data[5]=='V'; }
|
return Data[5]=='V'; }
|
||||||
|
|
||||||
|
uint8_t isBDGSV(void) const // BEIDOU satellite data
|
||||||
|
{ if(!isBD()) return 0;
|
||||||
|
if(Data[3]!='G') return 0;
|
||||||
|
if(Data[4]!='S') return 0;
|
||||||
|
return Data[5]=='V'; }
|
||||||
|
|
||||||
uint8_t isGPTXT(void) const // GPS test message
|
uint8_t isGPTXT(void) const // GPS test message
|
||||||
{ if(!isGP()) return 0;
|
{ if(!isGP()) return 0;
|
||||||
if(Data[3]!='T') return 0;
|
if(Data[3]!='T') return 0;
|
||||||
|
|
14
main/ogn.h
14
main/ogn.h
|
@ -980,13 +980,13 @@ class GPS_Position: public GPS_Time
|
||||||
int PrintTime(char *Out) const { return sprintf(Out, "%02d:%02d:%02d.%03d", Hour, Min, Sec, mSec ); }
|
int PrintTime(char *Out) const { return sprintf(Out, "%02d:%02d:%02d.%03d", Hour, Min, Sec, mSec ); }
|
||||||
|
|
||||||
void Print(void) const
|
void Print(void) const
|
||||||
{ printf("Time/Date = "); PrintDateTime(); printf(" "); // printf(" = %10ld.%03dsec\n", (long int)UnixTime, mSec);
|
{ printf("Time/Date: "); PrintDateTime();
|
||||||
printf("FixQuality/Mode=%d/%d: %d satellites DOP/H/V=%3.1f/%3.1f/%3.1f ", FixQuality, FixMode, Satellites, 0.1*PDOP, 0.1*HDOP, 0.1*VDOP);
|
printf(" FixQual/Mode=%d/%d: %d sats DOP/H/V=%3.1f/%3.1f/%3.1f", FixQuality, FixMode, Satellites, 0.1*PDOP, 0.1*HDOP, 0.1*VDOP);
|
||||||
printf("FixQuality=%d: %d satellites HDOP=%3.1f ", FixQuality, Satellites, 0.1*HDOP);
|
printf(" Lat/Lon/Alt = [%+10.6f,%+10.6f]deg %+3.1f(%+3.1f)m LatCos=%+6.3f", 0.0001/60*Latitude, 0.0001/60*Longitude, 0.1*Altitude, 0.1*GeoidSeparation, 1.0/(1<<12)*LatitudeCosine);
|
||||||
printf("Lat/Lon/Alt = [%+10.6f,%+10.6f]deg %+3.1f(%+3.1f)m LatCosine=%+6.3f ", 0.0001/60*Latitude, 0.0001/60*Longitude, 0.1*Altitude, 0.1*GeoidSeparation, 1.0/(1<<12)*LatitudeCosine);
|
printf(" Speed/Heading = %3.1fm/s %05.1fdeg", 0.1*Speed, 0.1*Heading);
|
||||||
printf("Speed/Heading = %3.1fm/s %05.1fdeg ", 0.1*Speed, 0.1*Heading);
|
printf(" Climb = %+5.1fm/s", 0.1*ClimbRate);
|
||||||
printf("Climb = %+5.1fm/s Turn = %+5.1fdeg/sec\n", 0.1*ClimbRate, 0.1*TurnRate);
|
printf(" Turn = %+5.1fdeg/s", 0.1*TurnRate);
|
||||||
}
|
printf("\n"); }
|
||||||
|
|
||||||
int Print(char *Out) const
|
int Print(char *Out) const
|
||||||
{ int Len=0;
|
{ int Len=0;
|
||||||
|
|
|
@ -489,7 +489,7 @@ extern "C"
|
||||||
xSemaphoreGive(CONS_Mutex); }
|
xSemaphoreGive(CONS_Mutex); }
|
||||||
}
|
}
|
||||||
else // if no WAN reception expected or possible
|
else // if no WAN reception expected or possible
|
||||||
#else // WITH_LORAWAN
|
#endif // WITH_LORAWAN
|
||||||
// if(TimeSync_msTime()<260);
|
// if(TimeSync_msTime()<260);
|
||||||
{ uint32_t RxRssiSum=0; uint16_t RxRssiCount=0; // measure the average RSSI for lower frequency
|
{ uint32_t RxRssiSum=0; uint16_t RxRssiCount=0; // measure the average RSSI for lower frequency
|
||||||
do
|
do
|
||||||
|
@ -513,7 +513,7 @@ extern "C"
|
||||||
xSemaphoreGive(CONS_Mutex);
|
xSemaphoreGive(CONS_Mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
// #endif // WITH_LORAWAN
|
||||||
|
|
||||||
TRX.setModeStandby(); // switch to standy
|
TRX.setModeStandby(); // switch to standy
|
||||||
vTaskDelay(1);
|
vTaskDelay(1);
|
||||||
|
|
Ładowanie…
Reference in New Issue