mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
Fix rules related exception or watchdog
Fix rules related exception or watchdog by adding a rules mutex solving possible rule loops as in case of Var/Mem/Add/Sub/Mult and Scale (#8757)
This commit is contained in:
parent
46cbcdda46
commit
610f1cef00
@ -168,6 +168,7 @@ struct RULES {
|
|||||||
uint16_t vars_event = 0;
|
uint16_t vars_event = 0;
|
||||||
uint8_t mems_event = 0;
|
uint8_t mems_event = 0;
|
||||||
bool teleperiod = false;
|
bool teleperiod = false;
|
||||||
|
bool busy = false;
|
||||||
|
|
||||||
char event_data[100];
|
char event_data[100];
|
||||||
} Rules;
|
} Rules;
|
||||||
@ -564,7 +565,6 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
|
|||||||
|
|
||||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Match 1 %d"), match);
|
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Match 1 %d"), match);
|
||||||
|
|
||||||
|
|
||||||
if (bitRead(Settings.rule_once, rule_set)) {
|
if (bitRead(Settings.rule_once, rule_set)) {
|
||||||
if (match) { // Only allow match state changes
|
if (match) { // Only allow match state changes
|
||||||
if (!bitRead(Rules.triggers[rule_set], Rules.trigger_count[rule_set])) {
|
if (!bitRead(Rules.triggers[rule_set], Rules.trigger_count[rule_set])) {
|
||||||
@ -751,6 +751,9 @@ bool RulesProcessEvent(char *json_event)
|
|||||||
{
|
{
|
||||||
bool serviced = false;
|
bool serviced = false;
|
||||||
|
|
||||||
|
if (!Rules.busy) {
|
||||||
|
Rules.busy = true;
|
||||||
|
|
||||||
#ifdef USE_DEBUG_DRIVER
|
#ifdef USE_DEBUG_DRIVER
|
||||||
ShowFreeMem(PSTR("RulesProcessEvent"));
|
ShowFreeMem(PSTR("RulesProcessEvent"));
|
||||||
#endif
|
#endif
|
||||||
@ -774,6 +777,9 @@ bool RulesProcessEvent(char *json_event)
|
|||||||
if (RuleSetProcess(i, event_saved)) { serviced = true; }
|
if (RuleSetProcess(i, event_saved)) { serviced = true; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rules.busy = false;
|
||||||
|
}
|
||||||
return serviced;
|
return serviced;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,7 +802,7 @@ void RulesInit(void)
|
|||||||
|
|
||||||
void RulesEvery50ms(void)
|
void RulesEvery50ms(void)
|
||||||
{
|
{
|
||||||
if (Settings.rule_enabled) { // Any rule enabled
|
if (Settings.rule_enabled && !Rules.busy) { // Any rule enabled
|
||||||
char json_event[120];
|
char json_event[120];
|
||||||
|
|
||||||
if (-1 == Rules.new_power) { Rules.new_power = power; }
|
if (-1 == Rules.new_power) { Rules.new_power = power; }
|
||||||
@ -932,7 +938,7 @@ void RulesEvery100ms(void)
|
|||||||
|
|
||||||
void RulesEverySecond(void)
|
void RulesEverySecond(void)
|
||||||
{
|
{
|
||||||
if (Settings.rule_enabled) { // Any rule enabled
|
if (Settings.rule_enabled && !Rules.busy) { // Any rule enabled
|
||||||
char json_event[120];
|
char json_event[120];
|
||||||
|
|
||||||
if (RtcTime.valid) {
|
if (RtcTime.valid) {
|
||||||
@ -956,7 +962,7 @@ void RulesEverySecond(void)
|
|||||||
|
|
||||||
void RulesSaveBeforeRestart(void)
|
void RulesSaveBeforeRestart(void)
|
||||||
{
|
{
|
||||||
if (Settings.rule_enabled) { // Any rule enabled
|
if (Settings.rule_enabled && !Rules.busy) { // Any rule enabled
|
||||||
char json_event[32];
|
char json_event[32];
|
||||||
|
|
||||||
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));
|
strncpy_P(json_event, PSTR("{\"System\":{\"Save\":1}}"), sizeof(json_event));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user