From f24d63a70d3c11d22773a7f7942ba79d6748999f Mon Sep 17 00:00:00 2001 From: Pawel Jalocha Date: Sun, 20 Feb 2022 07:44:15 +0000 Subject: [PATCH] Read and convert .TLG files to APRS --- utils/makefile | 3 +++ utils/tlg2aprs.cc | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 utils/tlg2aprs.cc diff --git a/utils/makefile b/utils/makefile index 55e1c1f..f4a963e 100644 --- a/utils/makefile +++ b/utils/makefile @@ -1,6 +1,9 @@ read_log: read_log.cc g++ -Wall -Wno-misleading-indentation -O2 -o read_log read_log.cc format.cpp +tlg2aprs: tlg2aprs.cc + g++ -Wall -Wno-misleading-indentation -O2 -o tlg2aprs tlg2aprs.cc format.cpp ognconv.cpp + aprs2igc: aprs2igc.cc g++ -Wall -Wno-misleading-indentation -O2 -o aprs2igc aprs2igc.cc format.cpp ognconv.cpp diff --git a/utils/tlg2aprs.cc b/utils/tlg2aprs.cc new file mode 100644 index 0000000..5c8a219 --- /dev/null +++ b/utils/tlg2aprs.cc @@ -0,0 +1,38 @@ +#include +#include +#include +#include +#include + +#include "ogn1.h" +#include "ogn.h" + +static char Line[160]; + +static int ProcessFile(const char *FileName) +{ uint32_t FileTime=0; + const char *ShortName=FileName; + for( ; ; ) + { const char *Slash=strchr(ShortName, '/'); if(Slash==0) break; + ShortName=Slash+1; } + if(Read_Hex(FileTime, ShortName)!=8) printf("Not a TLG file: %s\n", ShortName); + FILE *File = fopen(FileName, "rb"); if(File==0) { printf("Cannot open %s for read\n", FileName); return 0; } + OGN_LogPacket Packet; + int Packets=0; + for( ; ; ) + { if(fread(&Packet, Packet.Bytes, 1, File)!=1) break; // read the next packet from the file + if(!Packet.isCorrect()) continue; // + uint32_t Time=Packet.getTime(FileTime); // [sec] get exact time from short time in the packet and the file start time + int Len=Packet.Packet.WriteAPRS(Line, Time); + if(Len==0) continue; + printf("%s\n", Line); } + fclose(File); return Packets; } + +int main(int argc, char *argv[]) +{ + + for(int arg=1; arg