mirror of
https://github.com/arendst/Tasmota.git
synced 2025-04-24 23:07:17 +00:00
Add heap and stack debug information
Add heap and stack debug information
This commit is contained in:
parent
9196b97a4f
commit
dc1c2abda7
@ -1,4 +1,5 @@
|
||||
/* 6.0.0a
|
||||
* Add heap and stack debug information
|
||||
* Add command SetOption28 to switch between hex or decimal Sonoff Bridge RF received data format (#3008)
|
||||
* Add command SetOption29 to switch between hex or decimal IR received data format
|
||||
* Add performance improvement when updating multiple individual WS2812 pixels (#3007)
|
||||
|
@ -194,7 +194,7 @@ enum LichtSubtypes {LST_NONE, LST_SINGLE, LST_COLDWARM, LST_RGB, LST_RGBW, LST_R
|
||||
enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MAX};
|
||||
|
||||
enum XsnsFunctions {FUNC_PRE_INIT, FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_SECOND, FUNC_PREP_BEFORE_TELEPERIOD, FUNC_JSON_APPEND, FUNC_WEB_APPEND, FUNC_SAVE_BEFORE_RESTART,
|
||||
FUNC_COMMAND, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SHOW_SENSOR, FUNC_RULES_PROCESS};
|
||||
FUNC_COMMAND, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SHOW_SENSOR, FUNC_RULES_PROCESS, FUNC_FREE_MEM};
|
||||
|
||||
const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 };
|
||||
|
||||
|
@ -391,6 +391,8 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
|
||||
uint16_t index;
|
||||
uint32_t address;
|
||||
|
||||
ShowFreeMem(PSTR("MqttDataHandler"));
|
||||
|
||||
strncpy(topicBuf, topic, sizeof(topicBuf));
|
||||
for (i = 0; i < data_len; i++) {
|
||||
if (!isspace(data[i])) break;
|
||||
@ -1266,6 +1268,7 @@ void ExecuteCommand(char *cmnd, int source)
|
||||
char *start;
|
||||
char *token;
|
||||
|
||||
ShowFreeMem(PSTR("ExecuteCommand"));
|
||||
ShowSource(source);
|
||||
|
||||
token = strtok(cmnd, " ");
|
||||
|
@ -204,6 +204,8 @@ void MqttPublishDirect(const char* topic, boolean retained)
|
||||
char sretained[CMDSZ];
|
||||
char slog_type[10];
|
||||
|
||||
ShowFreeMem(PSTR("MqttPublishDirect"));
|
||||
|
||||
sretained[0] = '\0';
|
||||
snprintf_P(slog_type, sizeof(slog_type), PSTR(D_LOG_RESULT));
|
||||
|
||||
|
@ -343,6 +343,8 @@ bool RulesProcessEvent(char *json_event)
|
||||
{
|
||||
bool serviced = false;
|
||||
|
||||
ShowFreeMem(PSTR("RulesProcessEvent"));
|
||||
|
||||
String event_saved = json_event;
|
||||
event_saved.toUpperCase();
|
||||
|
||||
|
@ -165,11 +165,11 @@ void CpuLoadLoop()
|
||||
#if defined(F_CPU) && (F_CPU == 160000000L)
|
||||
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *800) );
|
||||
CPU_loops = CPU_loops / CPU_load_check;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
#else
|
||||
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *400) );
|
||||
CPU_loops = CPU_loops / CPU_load_check;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
CPU_last_millis = CPU_last_loop_time;
|
||||
@ -180,6 +180,26 @@ void CpuLoadLoop()
|
||||
|
||||
/*******************************************************************************************/
|
||||
|
||||
extern "C" {
|
||||
#include <cont.h>
|
||||
extern cont_t g_cont;
|
||||
}
|
||||
|
||||
void DebugFreeMem()
|
||||
{
|
||||
// https://github.com/esp8266/Arduino/issues/2557
|
||||
register uint32_t *sp asm("a1");
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d, UnmodifiedStack %d (%s)"),
|
||||
// ESP.getFreeHeap(), 4 * (sp - g_cont.stack), cont_get_free_stack(&g_cont), XdrvMailbox.data);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"),
|
||||
ESP.getFreeHeap(), 4 * (sp - g_cont.stack), XdrvMailbox.data);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
/*******************************************************************************************/
|
||||
|
||||
void DebugCfgDump(char* parms)
|
||||
{
|
||||
#define CFG_COLS 16
|
||||
@ -347,6 +367,9 @@ boolean Xdrv99(byte function)
|
||||
case FUNC_COMMAND:
|
||||
result = DebugCommand();
|
||||
break;
|
||||
case FUNC_FREE_MEM:
|
||||
DebugFreeMem();
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -176,6 +176,14 @@ boolean XdrvRulesProcess()
|
||||
return XdrvCall(FUNC_RULES_PROCESS);
|
||||
}
|
||||
|
||||
void ShowFreeMem(const char *where)
|
||||
{
|
||||
char stemp[20];
|
||||
snprintf_P(stemp, sizeof(stemp), where);
|
||||
XdrvMailbox.data = stemp;
|
||||
XdrvCall(FUNC_FREE_MEM);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Function call to all xdrv
|
||||
*
|
||||
@ -191,6 +199,7 @@ boolean XdrvRulesProcess()
|
||||
* FUNC_EVERY_SECOND
|
||||
* FUNC_EVERY_50_MSECOND
|
||||
* FUNC_RULES_PROCESS
|
||||
* FUNC_FREE_MEM
|
||||
\*********************************************************************************************/
|
||||
|
||||
boolean XdrvCall(byte Function)
|
||||
|
Loading…
x
Reference in New Issue
Block a user