From 78ce7b142d2d169927c6970dc32054ee116f8cf0 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 2 Jan 2021 12:23:30 +0100 Subject: [PATCH] Tune log string stack usage --- tasmota/xdrv_09_timers.ino | 2 +- tasmota/xdrv_99_debug.ino | 8 +++---- tasmota/xsns_36_mgc3130.ino | 48 +++++++++++++++++-------------------- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/tasmota/xdrv_09_timers.ino b/tasmota/xdrv_09_timers.ino index e2a66cfd0..c40045a31 100644 --- a/tasmota/xdrv_09_timers.ino +++ b/tasmota/xdrv_09_timers.ino @@ -880,7 +880,7 @@ void HandleTimerConfiguration(void) void TimerSaveSettings(void) { char tmp[MAX_TIMERS *12]; // Need space for MAX_TIMERS x 10 digit numbers separated by a comma - char message[LOGSZ]; + char message[32 + (MAX_TIMERS *11)]; // MQT: Timers 0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000 Timer timer; Settings.flag3.timers_enable = Webserver->hasArg("e0"); // CMND_TIMERS diff --git a/tasmota/xdrv_99_debug.ino b/tasmota/xdrv_99_debug.ino index c4aeda6e6..46bfa441e 100644 --- a/tasmota/xdrv_99_debug.ino +++ b/tasmota/xdrv_99_debug.ino @@ -258,7 +258,7 @@ void DebugRtcDump(char* parms) maxrow = srow + mrow; } - char log_data[LOGSZ]; + char log_data[100]; // 020: C7 2B 2E AB 70 E8 09 AE C8 88 3D EA 7C FF 48 2F | +. p = | H/| for (row = srow; row < maxrow; row++) { idx = row * CFG_COLS; snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); @@ -310,7 +310,7 @@ void DebugDump(uint32_t start, uint32_t size) { maxrow = srow + mrow; } - char log_data[LOGSZ]; + char log_data[150]; // 020: C7 2B 2E AB 70 E8 09 AE C8 88 3D EA 7C FF 48 2F 0E A7 D7 BF 02 0E D7 7D C9 6F B9 3A 1D 01 3F 28 | +. p = | H/ } o : ?(| for (row = srow; row < maxrow; row++) { idx = row * CFG_COLS; snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); @@ -361,7 +361,7 @@ void DebugCfgDump(char* parms) maxrow = srow + mrow; } - char log_data[LOGSZ]; + char log_data[100]; // 020: 6D 75 73 31 3A 38 30 2F 61 70 69 2F 61 72 64 75 |mus1:80/api/ardu| for (row = srow; row < maxrow; row++) { idx = row * CFG_COLS; snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), idx); @@ -397,7 +397,7 @@ void DebugCfgPeek(char* parms) uint16_t data16 = (buffer[address +1] << 8) + buffer[address]; uint32_t data32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + data16; - char log_data[LOGSZ]; + char log_data[100]; // 000: 09 12 00 10 | | 0x09 (9), 0x1209 (4617), 0x10001209 (268440073) snprintf_P(log_data, sizeof(log_data), PSTR("%03X:"), address); for (uint32_t i = 0; i < 4; i++) { snprintf_P(log_data, sizeof(log_data), PSTR("%s %02X"), log_data, buffer[address +i]); diff --git a/tasmota/xsns_36_mgc3130.ino b/tasmota/xsns_36_mgc3130.ino index 6ab7ed4d4..c68714419 100644 --- a/tasmota/xsns_36_mgc3130.ino +++ b/tasmota/xsns_36_mgc3130.ino @@ -238,7 +238,6 @@ void MGC3130_sendMessage(uint8_t data[], uint8_t length){ void MGC3130_handleGesture(){ - //char log[LOGSZ]; char edge[5]; if (MGC_data.out.gestureInfo.edgeFlick){ snprintf_P(edge, sizeof(edge), PSTR("ED_")); @@ -248,141 +247,138 @@ void MGC3130_handleGesture(){ } switch(MGC_data.out.gestureInfo.gestureCode){ case MGC3130_GESTURE_GARBAGE: - //snprintf_P(log, sizeof(log), PSTR("NONE")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("NONE")); break; case MGC3130_FLICK_WEST_EAST: - //snprintf_P(log, sizeof(log), PSTR("%sFL_WE"), edge); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_WE"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_WE"), edge); break; case MGC3130_FLICK_EAST_WEST: - //snprintf_P(log, sizeof(log), PSTR("%sFL_EW"), edge); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_EW"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_EW"), edge); break; case MGC3130_FLICK_SOUTH_NORTH: - //snprintf_P(log, sizeof(log), PSTR("%sFL_SN"), edge); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_SN"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_SN"), edge); break; case MGC3130_FLICK_NORTH_SOUTH: - //snprintf_P(log, sizeof(log), PSTR("%sFL_NS"), edge); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("%sFL_NS"), edge); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("%sFL_NS"), edge); break; case MGC3130_CIRCLE_CLOCKWISE: - //snprintf_P(log, sizeof(log), PSTR("CW")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CW")); break; case MGC3130_CIRCLE_CCLOCKWISE: - //snprintf_P(log, sizeof(log), PSTR("CCW")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("CCW")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("CCW")); break; } - //AddLog_P(LOG_LEVEL_DEBUG, log); } bool MGC3130_handleTouch(){ - //char log[LOGSZ]; bool success = false; // if we find a touch of higher order, we are done if (MGC_data.out.touchInfo.doubleTapCentre && !success){ - //snprintf_P(log, sizeof(log), PSTR("DTAP_CENTRE")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_C")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapEast && !success){ - //snprintf_P(log, sizeof(log), PSTR("DTAP_EAST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_E")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapNorth && !success){ - //snprintf_P(log, sizeof(log), PSTR("DTAP_NORTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_N")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapWest && !success){ - //snprintf_P(log, sizeof(log), PSTR("DTAP_WEST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_W")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.doubleTapSouth && !success){ - //snprintf_P(log, sizeof(log), PSTR("DTAP_SOUTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("DTAP_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("DT_S")); MGC3130_touchTimeout = 5; success = true; MGC3130_touchCounter = 1; } if (MGC_data.out.touchInfo.tapCentre && !success){ - //snprintf_P(log, sizeof(log), PSTR("TAP_CENTRE")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_C")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapEast && !success){ - //snprintf_P(log, sizeof(log), PSTR("TAP_EAST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_E")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapNorth && !success){ - //snprintf_P(log, sizeof(log), PSTR("TAP_NORTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_N")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapWest && !success){ - //snprintf_P(log, sizeof(log), PSTR("TAP_WEST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_W")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.tapSouth && !success){ - //snprintf_P(log, sizeof(log), PSTR("TAP_SOUTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TAP_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TP_S")); MGC3130_touchTimeout = 2; success = true; MGC3130_touchCounter = 1; } else if (MGC_data.out.touchInfo.touchCentre && !success){ - //snprintf_P(log, sizeof(log), PSTR("TOUCH_CENTRE")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_CENTRE")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_C")); success = true; MGC3130_touchCounter++; // This will reset to 0 after touching for approx. 1h and 50 minutes ;) } else if (MGC_data.out.touchInfo.touchEast && !success){ - //snprintf_P(log, sizeof(log), PSTR("TOUCH_EAST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_EAST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_E")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchNorth && !success){ - //snprintf_P(log, sizeof(log), PSTR("TOUCH_NORTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_NORTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_N")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchWest && !success){ - //snprintf_P(log, sizeof(log), PSTR("TOUCH_WEST")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_WEST")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_W")); success = true; MGC3130_touchCounter++; } else if (MGC_data.out.touchInfo.touchSouth && !success){ - //snprintf_P(log, sizeof(log), PSTR("TOUCH_SOUTH")); + //AddLog_P(LOG_LEVEL_DEBUG, PSTR("TOUCH_SOUTH")); snprintf_P(MGC3130_currentGesture, sizeof(MGC3130_currentGesture), PSTR("TH_S")); success = true; MGC3130_touchCounter++; } - //AddLog_P(LOG_LEVEL_DEBUG, log); return success; }