mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 05:06:32 +00:00
Revert uart buffer size increase
Revert uart buffer size increase but visit uart buffer reads more often to solve possible uart buffer overrun caused by sleep
This commit is contained in:
parent
001b6e4895
commit
4aa1c18d82
@ -1232,7 +1232,7 @@ void SerialInput(void)
|
|||||||
}
|
}
|
||||||
else if ((serial_in_byte_counter == INPUT_BUFFER_SIZE)
|
else if ((serial_in_byte_counter == INPUT_BUFFER_SIZE)
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
// || Serial.hasOverrun() // Default ESP8266 Serial buffer size is 256. Tasmota increases to INPUT_BUFFER_SIZE
|
|| Serial.hasOverrun() // Default ESP8266 Serial buffer size is 256. Tasmota increases to INPUT_BUFFER_SIZE
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
serial_buffer_overrun = true;
|
serial_buffer_overrun = true;
|
||||||
|
@ -198,8 +198,7 @@ char web_log[WEB_LOG_SIZE] = {'\0'}; // Web log buffer
|
|||||||
* Main
|
* Main
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
void setup(void)
|
void setup(void) {
|
||||||
{
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#ifdef DISABLE_ESP32_BROWNOUT
|
#ifdef DISABLE_ESP32_BROWNOUT
|
||||||
DisableBrownout(); // Workaround possible weak LDO resulting in brownout detection during Wifi connection
|
DisableBrownout(); // Workaround possible weak LDO resulting in brownout detection during Wifi connection
|
||||||
@ -216,7 +215,7 @@ void setup(void)
|
|||||||
RtcRebootSave();
|
RtcRebootSave();
|
||||||
|
|
||||||
Serial.begin(APP_BAUDRATE);
|
Serial.begin(APP_BAUDRATE);
|
||||||
Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
// Serial.setRxBufferSize(INPUT_BUFFER_SIZE); // Default is 256 chars
|
||||||
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
seriallog_level = LOG_LEVEL_INFO; // Allow specific serial messages until config loaded
|
||||||
|
|
||||||
snprintf_P(my_version, sizeof(my_version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0
|
snprintf_P(my_version, sizeof(my_version), PSTR("%d.%d.%d"), VERSION >> 24 & 0xff, VERSION >> 16 & 0xff, VERSION >> 8 & 0xff); // Release version 6.3.0
|
||||||
@ -325,8 +324,7 @@ void setup(void)
|
|||||||
XsnsCall(FUNC_INIT);
|
XsnsCall(FUNC_INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BacklogLoop(void)
|
void BacklogLoop(void) {
|
||||||
{
|
|
||||||
if (TimeReached(backlog_delay)) {
|
if (TimeReached(backlog_delay)) {
|
||||||
if (!BACKLOG_EMPTY && !backlog_mutex) {
|
if (!BACKLOG_EMPTY && !backlog_mutex) {
|
||||||
#ifdef SUPPORT_IF_STATEMENT
|
#ifdef SUPPORT_IF_STATEMENT
|
||||||
@ -345,8 +343,18 @@ void BacklogLoop(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void)
|
void SleepDelay(uint32_t mseconds) {
|
||||||
{
|
if (mseconds) {
|
||||||
|
for (uint32_t wait = 0; wait < mseconds; wait++) {
|
||||||
|
delay(1);
|
||||||
|
if (Serial.available()) { break; } // We need to service serial buffer ASAP as otherwise we get uart buffer overrun
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delay(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(void) {
|
||||||
uint32_t my_sleep = millis();
|
uint32_t my_sleep = millis();
|
||||||
|
|
||||||
XdrvCall(FUNC_LOOP);
|
XdrvCall(FUNC_LOOP);
|
||||||
@ -398,13 +406,13 @@ void loop(void)
|
|||||||
|
|
||||||
if (Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep
|
if (Settings.flag3.sleep_normal) { // SetOption60 - Enable normal sleep instead of dynamic sleep
|
||||||
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
|
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
|
||||||
delay(ssleep); // https://github.com/esp8266/Arduino/issues/2021
|
SleepDelay(ssleep); // https://github.com/esp8266/Arduino/issues/2021
|
||||||
} else {
|
} else {
|
||||||
if (my_activity < (uint32_t)ssleep) {
|
if (my_activity < (uint32_t)ssleep) {
|
||||||
delay((uint32_t)ssleep - my_activity); // Provide time for background tasks like wifi
|
SleepDelay((uint32_t)ssleep - my_activity); // Provide time for background tasks like wifi
|
||||||
} else {
|
} else {
|
||||||
if (global_state.wifi_down) {
|
if (global_state.wifi_down) {
|
||||||
delay(my_activity /2); // If wifi down and my_activity > setoption36 then force loop delay to 1/3 of my_activity period
|
SleepDelay(my_activity /2); // If wifi down and my_activity > setoption36 then force loop delay to 1/3 of my_activity period
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user