exception workaround

pull/193/head
Hansi, dl9rdz 2021-09-25 10:51:04 +02:00
rodzic 49bff43090
commit f30c9b6d89
4 zmienionych plików z 41 dodań i 37 usunięć

Wyświetl plik

@ -0,0 +1,18 @@
Important behaviour of WiFiClient:
If anything goes wrong in a read or write operation on a WiFiClient, it internally
will call WiFiClient.stop(), which sets _rxBuffer to NULL and connected to false.
Subsequently, any function call to WiFiClient that uses _rxBuffer will cause an
>>> Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
error and subsequent reboot.
available() is safe to call (it checks that rxBuffer is not null)
write() is safe to call (it checks that connected is true)
but read() and peek() are not.
This has been fixed in newer versions of the esp library, see
https://github.com/espressif/arduino-esp32/commit/cb7aef1e886ffe43213f9a090e0a8968205a41df#diff-0d8101826fd3df09b38bef2aeca6d093de76841daf38f65f4fefbf6b56da8f81
So there is at least one reason to eventually upgrade to 2.0.0. Currently we stick to 1.0.6.

Wyświetl plik

@ -3518,9 +3518,16 @@ void sondehub_station_update(WiFiClient * client, struct st_sondehub * conf) {
Serial.println(data); Serial.println(data);
Serial.println("Waiting for response"); Serial.println("Waiting for response");
// TODO: better do this asyncrhonously // TODO: better do this asyncrhonously
String response = client->readString(); // At least, do this safely. See Notes-on-Using-WiFiClient.txt for details
Serial.println(response); // If any of the client->print failed before (remote end closed connection),
Serial.println("Response done..."); // then calling client->read will cause a LoadProhibited exception
if(client->connected()) {
String response = client->readString();
Serial.println(response);
Serial.println("Response done...");
} else {
Serial.println("SH client connection closed\n");
}
//client->stop(); //client->stop();
} }

Wyświetl plik

@ -1363,7 +1363,6 @@ void Display::drawKilltimer(DispEntry *de) {
#define PI (3.1415926535897932384626433832795) #define PI (3.1415926535897932384626433832795)
#endif #endif
// defined by Arduino.h #define radians(x) ( (x)*180.0F/PI ) // defined by Arduino.h #define radians(x) ( (x)*180.0F/PI )
#define FAKEGPS 0
extern int lastCourse; // from RX_FSK.ino extern int lastCourse; // from RX_FSK.ino
@ -1376,42 +1375,22 @@ float calcLatLonDist(float lat1, float lon1, float lat2, float lon2) {
} }
void Display::calcGPS() { void Display::calcGPS() {
// base data float mylat = sonde.config.rxlat;
#if 0 float mylon = sonde.config.rxlon;
#if FAKEGPS bool valid = !(isnan(mylat)||isnan(mylon));
gpsValid = true; if( gpsPos.valid) {
gpsLat = 48.9; mylat = gpsPos.lat;
gpsLon = 13.3; mylon = gpsPos.lon;
gpsAlt = 33000; valid = true;
static int tmpc=0;
tmpc = (tmpc+5)%360;
gpsCourse = tmpc;
#else
gpsValid = nmea.isValid();
gpsLon = nmea.getLongitude()*0.000001;
gpsLat = nmea.getLatitude()*0.000001;
long alt = 0;
nmea.getAltitude(alt); gpsAlt=(int)(alt/1000);
gpsCourse = (int)(nmea.getCourse()/1000);
gpsCourseOld = false;
if(gpsCourse==0) {
// either north or not new
if(lastCourse!=0) // use old value...
{
gpsCourseOld = true;
gpsCourse = lastCourse;
}
} }
#endif
#endif
// distance // distance
if( gpsPos.valid && (sonde.si()->d.validPos&0x03)==0x03 && (layout->usegps&GPSUSE_DIST)) { if( valid && (sonde.si()->d.validPos&0x03)==0x03 && (layout->usegps&GPSUSE_DIST)) {
gpsDist = (int)calcLatLonDist(gpsPos.lat, gpsPos.lon, sonde.si()->d.lat, sonde.si()->d.lon); gpsDist = (int)calcLatLonDist(gpsPos.lat, gpsPos.lon, sonde.si()->d.lat, sonde.si()->d.lon);
} else { } else {
gpsDist = -1; gpsDist = -1;
} }
// bearing // bearing
if( gpsPos.valid && (sonde.si()->d.validPos&0x03)==0x03 && (layout->usegps&GPSUSE_BEARING)) { if( valid && (sonde.si()->d.validPos&0x03)==0x03 && (layout->usegps&GPSUSE_BEARING)) {
float lat1 = radians(gpsPos.lat); float lat1 = radians(gpsPos.lat);
float lat2 = radians(sonde.si()->d.lat); float lat2 = radians(sonde.si()->d.lat);
float lon1 = radians(gpsPos.lon); float lon1 = radians(gpsPos.lon);
@ -1471,7 +1450,7 @@ void Display::drawGPS(DispEntry *de) {
if( (sonde.si()->d.validPos&0x03)!=0x03 ) { if( (sonde.si()->d.validPos&0x03)!=0x03 ) {
snprintf(buf, 16, "no pos "); snprintf(buf, 16, "no pos ");
if(de->extra && *de->extra=='5') buf[5]=0; if(de->extra && *de->extra=='5') buf[5]=0;
} else if(!gpsPos.valid) { } else if( disp.gpsDist < 0 ) {
snprintf(buf, 16, "no gps "); snprintf(buf, 16, "no gps ");
if(de->extra && *de->extra=='5') buf[5]=0; if(de->extra && *de->extra=='5') buf[5]=0;
} else { } else {
@ -1491,7 +1470,7 @@ void Display::drawGPS(DispEntry *de) {
break; break;
case 'I': case 'I':
// dIrection // dIrection
if( (!gpsPos.valid) || ((sonde.si()->d.validPos&0x03)!=0x03 ) ) { if( disp.gpsDir<0 ) { // 0..360 valid, -1 invalid
drawString(de, "---"); drawString(de, "---");
break; break;
} }
@ -1503,7 +1482,7 @@ void Display::drawGPS(DispEntry *de) {
break; break;
case 'B': case 'B':
// relative bearing // relative bearing
if( (!gpsPos.valid) || ((sonde.si()->d.validPos&0x03)!=0x03 ) ) { if( disp.gpsBear < 0 ) { // 0..360 valid, -1 invalid
drawString(de, "---"); drawString(de, "---");
break; break;
} }

Wyświetl plik

@ -1,4 +1,4 @@
const char *version_name = "rdzTTGOsonde"; const char *version_name = "rdzTTGOsonde";
const char *version_id = "devel20210924c"; const char *version_id = "devel20210925";
const int SPIFFS_MAJOR=2; const int SPIFFS_MAJOR=2;
const int SPIFFS_MINOR=16; const int SPIFFS_MINOR=16;