Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
Pawel Jalocha adcbeda815 Minor mods for packet printout 2022-05-12 03:41:06 +01:00
Pawel Jalocha f448e4cf8b Fix minor issue with average RSSI measurement 2022-05-12 03:40:27 +01:00
Pawel Jalocha 916765929b Record to internal flash only when flying 2022-05-12 03:39:45 +01:00
Pawel Jalocha 196589f2dc Count Beidou satellites for average SNR 2022-05-12 03:38:49 +01:00
5 zmienionych plików z 42 dodań i 39 usunięć

Wyświetl plik

@ -173,6 +173,7 @@ static void ProcessGSV(NMEA_RxMsg &GSV) // process GxGSV to extract
if(GSV.isGPGSV()) { SatSys=0; }
else if(GSV.isGLGSV()) { SatSys=1; }
else if(GSV.isGAGSV()) { SatSys=2; }
else if(GSV.isBDGSV()) { SatSys=3; }
else 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

Wyświetl plik

@ -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
#ifdef WITH_SPIFFS_FAT
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
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
char FlashLog_FileName[32]; // current log file name if open
static FILE *FlashLog_File=0; // current log file if open
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
char FlashLog_FileName[32]; // current log file name 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
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
return FlashLog_File!=0; } // 1=success, 0=failure: new log file could not be open
static void FlashLog_Reopen(void)
{ if(FlashLog_File)
{ fclose(FlashLog_File);
FlashLog_File = fopen(FlashLog_FileName, "ab");
FlashLog_FileFlush = ftell(FlashLog_File); }
FlashLog_SaveReq=0; }
static void FlashLog_Reopen(void) // force close and re-open the current log file
{ if(FlashLog_File) // if log File is open
{ fclose(FlashLog_File); // close it
FlashLog_File = fopen(FlashLog_FileName, "ab"); // open it again for append with same filename
FlashLog_FileFlush = ftell(FlashLog_File); } // track how much has been pysically written
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
{ if(FlashLog_File) // if log file already open
@ -381,27 +381,23 @@ void vTaskLOG(void* pvParameters)
#endif
#endif
TickType_t PrevTick = 0;
TickType_t PrevTick = 0; // [ms] Time when packets stored the last time
for( ; ; )
{ // vTaskDelay(200); // wait idle 0.2sec
if(FlashLog_SaveReq) FlashLog_Reopen(); // if requested then save the current log (close + reopen)
TickType_t Tick=xTaskGetTickCount(); // system tick count now
{ vTaskDelay(1);
bool Flying = Flight.inFlight(); // if the aircraft flying ?
size_t Packets = FlashLog_FIFO.Full(); // how many packets in the queue ?
// #ifdef DEBUG_PRINT
// xSemaphoreTake(CONS_Mutex, portMAX_DELAY);
// Format_String(CONS_UART_Write, "TaskLOG() ");
// Format_UnsDec(CONS_UART_Write, Tick, 4, 3);
// Format_String(CONS_UART_Write, "(");
// Format_UnsDec(CONS_UART_Write, PrevTick, 4, 3);
// Format_String(CONS_UART_Write, ")s: ");
// Format_UnsDec(CONS_UART_Write, Packets);
// Format_String(CONS_UART_Write, " packets\n");
// xSemaphoreGive(CONS_Mutex);
// #endif
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
if(Flying) // when flying
{ if(FlashLog_SaveReq) FlashLog_Reopen(); // if requested then save the current log (close + reopen)
TickType_t Tick=xTaskGetTickCount(); // system tick count now
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
} else // when not flying
{ if(FlashLog_File) { fclose(FlashLog_File); FlashLog_File=0; } // if file open then close it
while(FlashLog_FIFO.Full()>=FlashLog_FIFO.Len/2) // flush the packet queue but keep it half-full
{ FlashLog_FIFO.Read(); vTaskDelay(1); }
}
vTaskDelay(100); }
}

Wyświetl plik

@ -207,6 +207,12 @@ inline uint8_t NMEA_AppendCheckCRNL(char *NMEA, uint8_t Len) { return NMEA_Appen
if(Data[4]!='S') return 0;
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
{ if(!isGP()) return 0;
if(Data[3]!='T') return 0;

Wyświetl plik

@ -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 ); }
void Print(void) const
{ printf("Time/Date = "); PrintDateTime(); printf(" "); // printf(" = %10ld.%03dsec\n", (long int)UnixTime, mSec);
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("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 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("Climb = %+5.1fm/s Turn = %+5.1fdeg/sec\n", 0.1*ClimbRate, 0.1*TurnRate);
}
{ printf("Time/Date: "); PrintDateTime();
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(" 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(" Speed/Heading = %3.1fm/s %05.1fdeg", 0.1*Speed, 0.1*Heading);
printf(" Climb = %+5.1fm/s", 0.1*ClimbRate);
printf(" Turn = %+5.1fdeg/s", 0.1*TurnRate);
printf("\n"); }
int Print(char *Out) const
{ int Len=0;

Wyświetl plik

@ -489,7 +489,7 @@ extern "C"
xSemaphoreGive(CONS_Mutex); }
}
else // if no WAN reception expected or possible
#else // WITH_LORAWAN
#endif // WITH_LORAWAN
// if(TimeSync_msTime()<260);
{ uint32_t RxRssiSum=0; uint16_t RxRssiCount=0; // measure the average RSSI for lower frequency
do
@ -513,7 +513,7 @@ extern "C"
xSemaphoreGive(CONS_Mutex);
#endif
}
#endif
// #endif // WITH_LORAWAN
TRX.setModeStandby(); // switch to standy
vTaskDelay(1);