Fix exception 9 when syslog is enabled and NTP is just synced

Fix exception 9 when syslog is enabled and NTP is just synced (#5917)
This commit is contained in:
Theo Arends 2019-06-09 13:34:14 +02:00
parent 76919b2111
commit d3eaf7491d
4 changed files with 14 additions and 2 deletions

View File

@ -5,6 +5,7 @@
* Add some MQTT housekeeping which might solve issue (#5755) * Add some MQTT housekeeping which might solve issue (#5755)
* Add command SetOption65 0/1 and more Tuya Serial based device support (#5815) * Add command SetOption65 0/1 and more Tuya Serial based device support (#5815)
* Fix include of my_user_config.h in sonoff_aws_iot.cpp (#5930) * Fix include of my_user_config.h in sonoff_aws_iot.cpp (#5930)
* Fix exception 9 when syslog is enabled and NTP is just synced (#5917)
* *
* 6.5.0.14 20190602 * 6.5.0.14 20190602
* Change webserver HTML input, button, textarea, and select name based on id * Change webserver HTML input, button, textarea, and select name based on id

View File

@ -173,6 +173,7 @@ bool i2c_flg = false; // I2C configured
bool spi_flg = false; // SPI configured bool spi_flg = false; // SPI configured
bool soft_spi_flg = false; // Software SPI configured bool soft_spi_flg = false; // Software SPI configured
bool ntp_force_sync = false; // Force NTP sync bool ntp_force_sync = false; // Force NTP sync
bool ntp_synced_message = false; // NTP synced message flag
myio my_module; // Active copy of Module GPIOs (17 x 8 bits) myio my_module; // Active copy of Module GPIOs (17 x 8 bits)
gpio_flag my_module_flag; // Active copy of Template GPIO flags gpio_flag my_module_flag; // Active copy of Template GPIO flags
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits) StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
@ -1995,6 +1996,12 @@ void PerformEverySecond(void)
{ {
uptime++; uptime++;
if (ntp_synced_message) {
// Moved here to fix syslog UDP exception 9 during RtcSecond
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
ntp_synced_message = false;
}
if (BOOT_LOOP_TIME == uptime) { if (BOOT_LOOP_TIME == uptime) {
RtcReboot.fast_reboot_count = 0; RtcReboot.fast_reboot_count = 0;
RtcRebootSave(); RtcRebootSave();

View File

@ -1503,7 +1503,7 @@ void Syslog(void)
memmove(log_data + strlen(syslog_preamble), log_data, sizeof(log_data) - strlen(syslog_preamble)); memmove(log_data + strlen(syslog_preamble), log_data, sizeof(log_data) - strlen(syslog_preamble));
log_data[sizeof(log_data) -1] = '\0'; log_data[sizeof(log_data) -1] = '\0';
memcpy(log_data, syslog_preamble, strlen(syslog_preamble)); memcpy(log_data, syslog_preamble, strlen(syslog_preamble));
PortUdp.write(log_data); PortUdp.write(log_data, strlen(log_data));
PortUdp.endPacket(); PortUdp.endPacket();
delay(1); // Add time for UDP handling (#5512) delay(1); // Add time for UDP handling (#5512)
} else { } else {

View File

@ -365,7 +365,11 @@ void RtcSecond(void)
RtcTime.year = tmpTime.year + 1970; RtcTime.year = tmpTime.year + 1970;
daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year); daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
standard_time = RuleToTime(Settings.tflag[0], RtcTime.year); standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
// Do not use AddLog here if syslog is enabled. UDP will force exception 9
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
ntp_synced_message = true;
if (local_time < 1451602800) { // 2016-01-01 if (local_time < 1451602800) { // 2016-01-01
rules_flag.time_init = 1; rules_flag.time_init = 1;
} else { } else {