mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-29 18:05:42 +00:00
include file/lineno in critical error logs
This commit is contained in:
parent
c27d479a9f
commit
babc1b3613
@ -4,5 +4,8 @@
|
|||||||
|
|
||||||
#include "mesh/generated/mesh.pb.h" // For CriticalErrorCode
|
#include "mesh/generated/mesh.pb.h" // For CriticalErrorCode
|
||||||
|
|
||||||
|
/// A macro that include filename and line
|
||||||
|
#define RECORD_CRITICALERROR(code) (code, __LINE__, __FILE__)
|
||||||
|
|
||||||
/// Record an error that should be reported via analytics
|
/// Record an error that should be reported via analytics
|
||||||
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0);
|
void recordCriticalError(CriticalErrorCode code = CriticalErrorCode_Unspecified, uint32_t address = 0, const char *filename = NULL);
|
||||||
|
@ -43,7 +43,7 @@ bool UBloxGPS::setupGPS()
|
|||||||
DEBUG_MSG("Connected to UBLOX GPS successfully\n");
|
DEBUG_MSG("Connected to UBLOX GPS successfully\n");
|
||||||
|
|
||||||
if (!setUBXMode())
|
if (!setUBXMode())
|
||||||
recordCriticalError(CriticalErrorCode_UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
|
RECORD_CRITICALERROR(CriticalErrorCode_UBloxInitFailed); // Don't halt the boot if saving the config fails, but do report the bug
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -466,7 +466,7 @@ void setup()
|
|||||||
// Do this after service.init (because that clears error_code)
|
// Do this after service.init (because that clears error_code)
|
||||||
#ifdef AXP192_SLAVE_ADDRESS
|
#ifdef AXP192_SLAVE_ADDRESS
|
||||||
if (!axp192_found)
|
if (!axp192_found)
|
||||||
recordCriticalError(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
|
RECORD_CRITICALERROR(CriticalErrorCode_NoAXP192); // Record a hardware fault for missing hardware
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Don't call screen setup until after nodedb is setup (because we need
|
// Don't call screen setup until after nodedb is setup (because we need
|
||||||
@ -557,7 +557,7 @@ void setup()
|
|||||||
airTime = new AirTime();
|
airTime = new AirTime();
|
||||||
|
|
||||||
if (!rIf)
|
if (!rIf)
|
||||||
recordCriticalError(CriticalErrorCode_NoRadio);
|
RECORD_CRITICALERROR(CriticalErrorCode_NoRadio);
|
||||||
else
|
else
|
||||||
router->addInterface(rIf);
|
router->addInterface(rIf);
|
||||||
|
|
||||||
|
@ -541,12 +541,15 @@ NodeInfo *NodeDB::getOrCreateNode(NodeNum n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Record an error that should be reported via analytics
|
/// Record an error that should be reported via analytics
|
||||||
void recordCriticalError(CriticalErrorCode code, uint32_t address)
|
void recordCriticalError(CriticalErrorCode code, uint32_t address, const char *filename)
|
||||||
{
|
{
|
||||||
// Print error to screen and serial port
|
// Print error to screen and serial port
|
||||||
String lcd = String("Critical error ") + code + "!\n";
|
String lcd = String("Critical error ") + code + "!\n";
|
||||||
screen->print(lcd.c_str());
|
screen->print(lcd.c_str());
|
||||||
DEBUG_MSG("NOTE! Recording critical error %d, address=%lx\n", code, address);
|
if(filename)
|
||||||
|
DEBUG_MSG("NOTE! Recording critical error %d at %s:%lx\n", code, filename, address);
|
||||||
|
else
|
||||||
|
DEBUG_MSG("NOTE! Recording critical error %d, address=%lx\n", code, address);
|
||||||
|
|
||||||
// Record error to DB
|
// Record error to DB
|
||||||
myNodeInfo.error_code = code;
|
myNodeInfo.error_code = code;
|
||||||
|
@ -94,15 +94,15 @@ bool RF95Interface::reconfigure()
|
|||||||
// configure publicly accessible settings
|
// configure publicly accessible settings
|
||||||
int err = lora->setSpreadingFactor(sf);
|
int err = lora->setSpreadingFactor(sf);
|
||||||
if (err != ERR_NONE)
|
if (err != ERR_NONE)
|
||||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setBandwidth(bw);
|
err = lora->setBandwidth(bw);
|
||||||
if (err != ERR_NONE)
|
if (err != ERR_NONE)
|
||||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setCodingRate(cr);
|
err = lora->setCodingRate(cr);
|
||||||
if (err != ERR_NONE)
|
if (err != ERR_NONE)
|
||||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
err = lora->setSyncWord(syncWord);
|
err = lora->setSyncWord(syncWord);
|
||||||
assert(err == ERR_NONE);
|
assert(err == ERR_NONE);
|
||||||
@ -115,13 +115,13 @@ bool RF95Interface::reconfigure()
|
|||||||
|
|
||||||
err = lora->setFrequency(freq);
|
err = lora->setFrequency(freq);
|
||||||
if (err != ERR_NONE)
|
if (err != ERR_NONE)
|
||||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
if (power > MAX_POWER) // This chip has lower power limits than some
|
if (power > MAX_POWER) // This chip has lower power limits than some
|
||||||
power = MAX_POWER;
|
power = MAX_POWER;
|
||||||
err = lora->setOutputPower(power);
|
err = lora->setOutputPower(power);
|
||||||
if (err != ERR_NONE)
|
if (err != ERR_NONE)
|
||||||
recordCriticalError(CriticalErrorCode_InvalidRadioSetting);
|
RECORD_CRITICALERROR(CriticalErrorCode_InvalidRadioSetting);
|
||||||
|
|
||||||
startReceive(); // restart receiving
|
startReceive(); // restart receiving
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ bool RadioLibInterface::canSendImmediately()
|
|||||||
// TX IRQ from the radio, the radio is probably broken.
|
// TX IRQ from the radio, the radio is probably broken.
|
||||||
if (busyTx && (millis() - lastTxStart > 60000)) {
|
if (busyTx && (millis() - lastTxStart > 60000)) {
|
||||||
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
|
DEBUG_MSG("Hardware Failure! busyTx for more than 60s\n");
|
||||||
recordCriticalError(CriticalErrorCode_TransmitFailed);
|
RECORD_CRITICALERROR(CriticalErrorCode_TransmitFailed);
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
|
if (busyTx && (millis() - lastTxStart > 65000)) // After 5s more, reboot
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
@ -46,7 +46,8 @@ typedef enum _CriticalErrorCode {
|
|||||||
CriticalErrorCode_NoAXP192 = 6,
|
CriticalErrorCode_NoAXP192 = 6,
|
||||||
CriticalErrorCode_InvalidRadioSetting = 7,
|
CriticalErrorCode_InvalidRadioSetting = 7,
|
||||||
CriticalErrorCode_TransmitFailed = 8,
|
CriticalErrorCode_TransmitFailed = 8,
|
||||||
CriticalErrorCode_Brownout = 9
|
CriticalErrorCode_Brownout = 9,
|
||||||
|
CriticalErrorCode_SX1262Failure = 10
|
||||||
} CriticalErrorCode;
|
} CriticalErrorCode;
|
||||||
|
|
||||||
typedef enum _Routing_Error {
|
typedef enum _Routing_Error {
|
||||||
@ -216,8 +217,8 @@ typedef struct _ToRadio {
|
|||||||
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
|
#define _Constants_ARRAYSIZE ((Constants)(Constants_DATA_PAYLOAD_LEN+1))
|
||||||
|
|
||||||
#define _CriticalErrorCode_MIN CriticalErrorCode_None
|
#define _CriticalErrorCode_MIN CriticalErrorCode_None
|
||||||
#define _CriticalErrorCode_MAX CriticalErrorCode_Brownout
|
#define _CriticalErrorCode_MAX CriticalErrorCode_SX1262Failure
|
||||||
#define _CriticalErrorCode_ARRAYSIZE ((CriticalErrorCode)(CriticalErrorCode_Brownout+1))
|
#define _CriticalErrorCode_ARRAYSIZE ((CriticalErrorCode)(CriticalErrorCode_SX1262Failure+1))
|
||||||
|
|
||||||
#define _Routing_Error_MIN Routing_Error_NONE
|
#define _Routing_Error_MIN Routing_Error_NONE
|
||||||
#define _Routing_Error_MAX Routing_Error_NOT_AUTHORIZED
|
#define _Routing_Error_MAX Routing_Error_NOT_AUTHORIZED
|
||||||
|
@ -108,7 +108,7 @@ void checkSDEvents()
|
|||||||
while (NRF_SUCCESS == sd_evt_get(&evt)) {
|
while (NRF_SUCCESS == sd_evt_get(&evt)) {
|
||||||
switch (evt) {
|
switch (evt) {
|
||||||
case NRF_EVT_POWER_FAILURE_WARNING:
|
case NRF_EVT_POWER_FAILURE_WARNING:
|
||||||
recordCriticalError(CriticalErrorCode_Brownout);
|
RECORD_CRITICALERROR(CriticalErrorCode_Brownout);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -118,7 +118,7 @@ void checkSDEvents()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (NRF_POWER->EVENTS_POFWARN)
|
if (NRF_POWER->EVENTS_POFWARN)
|
||||||
recordCriticalError(CriticalErrorCode_Brownout);
|
RECORD_CRITICALERROR(CriticalErrorCode_Brownout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ static void waitEnterSleep()
|
|||||||
delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
|
delay(100); // Kinda yucky - wait until radio says say we can shutdown (finished in process sends/receives)
|
||||||
|
|
||||||
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
|
if (millis() - now > 30 * 1000) { // If we wait too long just report an error and go to sleep
|
||||||
recordCriticalError(CriticalErrorCode_SleepEnterWait);
|
RECORD_CRITICALERROR(CriticalErrorCode_SleepEnterWait);
|
||||||
assert(0); // FIXME - for now we just restart, need to fix bug #167
|
assert(0); // FIXME - for now we just restart, need to fix bug #167
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user