From f6f50c57f8cc7c45d5d66dfb2b0f3db55d768013 Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Sat, 19 Sep 2020 03:08:51 +0100 Subject: [PATCH] Add status packet print when downloading the log file --- main/log.cpp | 7 ++++--- main/ogn1.h | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/main/log.cpp b/main/log.cpp index 00a69aa..e43f166 100644 --- a/main/log.cpp +++ b/main/log.cpp @@ -174,7 +174,7 @@ int FlashLog_ListFiles(void) // return Files; } */ -int FlashLog_ListFile(const char *FileName, uint32_t FileTime) // print the content, thue every packet of the given log file in APRS format +int FlashLog_ListFile(const char *FileName, uint32_t FileTime) // print the content, thus every packet of the given log file in APRS format { char Line[128]; // xSemaphoreTake(CONS_Mutex, portMAX_DELAY); // Format_String(CONS_UART_Write, "FlashLog_ListFile("); @@ -187,10 +187,11 @@ int FlashLog_ListFile(const char *FileName, uint32_t FileTime) // print the c for( ; ; ) { if(fread(&Packet, Packet.Bytes, 1, File)!=1) break; // read the next packet if(!Packet.isCorrect()) continue; - if(Packet.Packet.Header.NonPos) continue; // skip non-position packets (although we could print them too) + // if(Packet.Packet.Header.NonPos) continue; // skip non-position packets (although we could print them too) uint32_t Time = Packet.getTime(FileTime); // [sec] get exact time from short time in the packet and the file start time - xSemaphoreTake(CONS_Mutex, portMAX_DELAY); uint8_t Len=Packet.Packet.WriteAPRS(Line, Time); // print the packet in the APRS format + if(Len==0) continue; // if cannot be printed for whatever reason + xSemaphoreTake(CONS_Mutex, portMAX_DELAY); Format_String(CONS_UART_Write, Line, 0, Len); // send the APRS to the console xSemaphoreGive(CONS_Mutex); vTaskDelay(10); // limit the printout to some 100 packet/sec diff --git a/main/ogn1.h b/main/ogn1.h index e45ae17..08ae411 100644 --- a/main/ogn1.h +++ b/main/ogn1.h @@ -175,14 +175,31 @@ class OGN1_Packet // Packet structure for the OGN tracker { printf(" %02X", Byte()[Idx]); } printf("\n"); } - int WriteDeviceStatus(char *Out) + uint8_t WriteStatus(char *Out) + { uint8_t Len=0; + Out[Len++]=' '; Out[Len++]='h'; Len+=Format_Hex(Out+Len, (uint8_t)Status.Hardware); + Out[Len++]=' '; Out[Len++]='v'; Len+=Format_Hex(Out+Len, (uint8_t)Status.Firmware); + Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, Status.Satellites); Out[Len++]='s'; Out[Len++]='a'; Out[Len++]='t'; + Out[Len++]='/'; Out[Len++]='0'+Status.FixQuality; + Out[Len++]='/'; Len+=Format_UnsDec(Out+Len, Status.SatSNR+8); Out[Len++]='d'; Out[Len++]='B'; + Out[Len++]=' '; Len+=Format_SignDec(Out+Len, DecodeAltitude(), 1, 0, 1); Out[Len++]='m'; + Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, (((uint32_t)Status.Pressure<<3)+5)/10, 2, 1); Out[Len++]='h'; Out[Len++]='P'; Out[Len++]='a'; + Out[Len++]=' '; Len+=Format_SignDec(Out+Len, DecodeTemperature(), 2, 1); Out[Len++]='d'; Out[Len++]='e'; Out[Len++]='g'; Out[Len++]='C'; + Out[Len++]=' '; Len+=Format_SignDec(Out+Len, DecodeHumidity(), 2, 1); Out[Len++]='%'; + Out[Len++]=' '; Len+=Format_SignDec(Out+Len, ((uint32_t)DecodeVoltage()*100+32)>>6, 3, 2); Out[Len++]='V'; + Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, Status.TxPower+4); + Out[Len++]='/'; Out[Len++]='-'; Len+=Format_UnsDec(Out+Len, 5*Status.RadioNoise, 2, 1); Out[Len++]='d'; Out[Len++]='B'; Out[Len++]='m'; + Out[Len++]=' '; Len+=Format_UnsDec(Out+Len, (1<4) DiffSec-=60; // difference should always be zero or negative, but can be small positive for predicted positions Time+=DiffSec; } // get out the correct position time - Msg[Len++] = '/'; + Msg[Len++] = Header.NonPos?'>':'/'; Len+=Format_HHMMSS(Msg+Len, Time); Msg[Len++] = 'h'; + if(Header.NonPos) { Len+=WriteStatus(Msg+Len); Msg[Len++]='\n'; Msg[Len]=0; return Len; } + const char *Icon = getAprsIcon(Position.AcftType); int32_t Lat = DecodeLatitude();