From 73244615a82098f9d9ed4f6ce5477e13077f89ee Mon Sep 17 00:00:00 2001 From: "Hansi, dl9rdz" Date: Tue, 14 Sep 2021 22:43:01 +0200 Subject: [PATCH] avoid rs92 decode stack overflow, remove unused code --- RX_FSK/RX_FSK.ino | 4 ++++ RX_FSK/data/index.html | 2 ++ RX_FSK/src/geteph.cpp | 7 +++++++ RX_FSK/src/geteph.h | 8 ++++++++ RX_FSK/src/rs92gps.cpp | 27 ++++++++++++++++++++------- platformio.ini | 4 ++-- 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/RX_FSK/RX_FSK.ino b/RX_FSK/RX_FSK.ino index b4c3d9c..239806d 100644 --- a/RX_FSK/RX_FSK.ino +++ b/RX_FSK/RX_FSK.ino @@ -159,6 +159,9 @@ String processor(const String& var) { snprintf(tmpstr, 128, "Fingerprint %d (%s)", sonde.fingerprint, fpstr); return String(tmpstr); } + if (var == "EPHSTATE") { + return String(ephtxt[ephstate]); + } return String(); } @@ -2838,6 +2841,7 @@ void loopWifiScan() { } if (hasRS92) { geteph(); + if(ephstate==EPH_PENDING) ephstate=EPH_ERROR; get_eph("/brdc"); } delay(3000); diff --git a/RX_FSK/data/index.html b/RX_FSK/data/index.html index 6b4b088..e5f75ad 100755 --- a/RX_FSK/data/index.html +++ b/RX_FSK/data/index.html @@ -65,6 +65,8 @@
Autodetect info: %AUTODETECT_INFO%

+ RS92 RINEX eph state: %EPHSTATE%
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of diff --git a/RX_FSK/src/geteph.cpp b/RX_FSK/src/geteph.cpp index a898a55..898e72a 100644 --- a/RX_FSK/src/geteph.cpp +++ b/RX_FSK/src/geteph.cpp @@ -12,6 +12,9 @@ extern WiFiClient client; //static const char *ftpserver = "www.ngs.noaa.gov"; char outbuf[128]; +uint8_t ephstate = EPH_NOTUSED; +//enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD }; +char *ephtxt[] = { "Disabled", "Pending", "Time error", "Fetch error", "Read error", "Good" }; uint8_t getreply() { String s = client.readStringUntil('\n'); @@ -45,10 +48,12 @@ void writeFully(File &file, uint8_t *buf, size_t len) void geteph() { // Set current time via network... + ephstate = EPH_PENDING; struct tm tinfo; configTime(0, 0, "pool.ntp.org"); bool ok = getLocalTime(&tinfo, 2000); // wait max 2 seconds to get current time via ntp if(!ok) { + ephstate = EPH_TIMEERR; Serial.println("Failed to get current date/time"); return; } @@ -66,6 +71,7 @@ void geteph() { if(tsstr && strlen(tsstr)>=9) { if(strcmp(nowstr, ts.c_str())<=0) { Serial.println("local brdc is up to date\n"); + ephstate = EPH_GOOD; return; } } @@ -221,6 +227,7 @@ void geteph() { snprintf(buf, 16, "Done: %d B ",total); buf[16]=0; disp.rdis->drawString(0,5*dispys,buf); + ephstate = EPH_GOOD; delay(1000); free(obuf); diff --git a/RX_FSK/src/geteph.h b/RX_FSK/src/geteph.h index f985417..908208d 100644 --- a/RX_FSK/src/geteph.h +++ b/RX_FSK/src/geteph.h @@ -1,3 +1,11 @@ +#include +#ifndef GETEPH_H +#define GETEPH_H void geteph(); +enum EPHSTATE { EPH_NOTUSED, EPH_PENDING, EPH_TIMEERR, EPH_ERROR, EPH_EPHERROR, EPH_GOOD }; + +extern uint8_t ephstate; +extern char *ephtxt[]; +#endif diff --git a/RX_FSK/src/rs92gps.cpp b/RX_FSK/src/rs92gps.cpp index 2c36797..4c31707 100644 --- a/RX_FSK/src/rs92gps.cpp +++ b/RX_FSK/src/rs92gps.cpp @@ -50,13 +50,14 @@ #include #include "nav_gps_vel.h" #include "rs92gps.h" +#include "geteph.h" #include "Sonde.h" gpx_t gpx; -int option_verbose = 0, // ausfuehrliche Anzeige +const int option_verbose = 0, // ausfuehrliche Anzeige option_raw = 1, // rohe Frames option_inv = 0, // invertiert Signal option_res = 0, // genauere Bitmessung @@ -827,27 +828,33 @@ int naiv_2Dfix(int N, SAT_t sats[], double alt) { int get_GPSkoord(int N) { double lat, lon, alt, rx_cl_bias; double vH, vD, vU; - double lat1s, lon1s, alt1s, - lat0 , lon0 , alt0 , pos0_ecef[3]; - double pos_ecef[3], pos1s_ecef[3], dpos_ecef[3], + double pos_ecef[3], dpos_ecef[3], vel_ecef[3], dvel_ecef[3]; double gdop, gdop0 = 1000.0; //double hdop, vdop, pdop; - int i0, i1, i2, i3, j, k, n; + int i0, i1, i2, i3, j; int nav_ret = 0; int num = 0; SAT_t Sat_A[4]; +#if 0 + int k, n; + double lat1s, lon1s, alt1s, + lat0 , lon0 , alt0 , pos0_ecef[3]; + double pos1s_ecef[3]; SAT_t Sat_B[12]; // N <= 12 SAT_t Sat_B1s[12]; SAT_t Sat_C[12]; // 11 - double diter = 0; int exN = -1; +#endif + double diter = 0; +#if 0 if (option_vergps == 8) { fprintf(stdout, " sats: "); for (j = 0; j < N; j++) fprintf(stdout, "%02d ", prn[j]); fprintf(stdout, "\n"); } +#endif gpx.lat = gpx.lon = gpx.alt = 0; @@ -878,6 +885,7 @@ int get_GPSkoord(int N) { for (j=0; j<3; j++) vel_ecef[j] += dvel_ecef[j]; get_GPSvel(lat, lon, vel_ecef, &vH, &vD, &vU); } +#if 0 if (option_vergps == 8) { // gdop = sqrt(DOP[0]+DOP[1]+DOP[2]+DOP[3]); // s.o. //hdop = sqrt(DOP[0]+DOP[1]); @@ -898,6 +906,7 @@ int get_GPSkoord(int N) { fprintf(stdout, "\n"); } } +#endif } else gdop = -1; @@ -921,6 +930,7 @@ int get_GPSkoord(int N) { }}}} } +#if 0 if (option_vergps == 8 || option_vergps == 2) { for (j = 0; j < N; j++) Sat_B[j] = sat[prn[j]]; @@ -1047,6 +1057,7 @@ int get_GPSkoord(int N) { } } +#endif return num; } @@ -1184,7 +1195,9 @@ void get_eph(const char *file) { if (ephs) { ephem = 1; almanac = 0; - } + } else { + ephstate = EPH_EPHERROR; + } Serial.printf("reading RNX done, result is %d, ephs=%p\n", ephem, ephs); if (!option_der) d_err = 1000; } diff --git a/platformio.ini b/platformio.ini index 44b3fd5..da20385 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,12 +10,12 @@ [platformio] src_dir = RX_FSK -lib_dir = libraries +lib_dir = RX_FSK data_dir = RX_FSK/data [extra] lib_deps_builtin = - SondeLib + src lib_deps_external = olikraus/U8g2 @ ^2.28.8 AXP202X_Library