Do not stop wmbusmeters while resetting.

pull/143/head
Fredrik Öhrström 2020-08-10 21:20:54 +02:00
rodzic 0bc6d81b95
commit 99876d175b
2 zmienionych plików z 10 dodań i 11 usunięć

Wyświetl plik

@ -694,7 +694,6 @@ void SerialCommunicationManagerImp::stop()
{ {
debug("(serial) stopping manager\n"); debug("(serial) stopping manager\n");
running_ = false; running_ = false;
assert(0);
if (main_thread_ != 0) if (main_thread_ != 0)
{ {
if (signalsInstalled()) if (signalsInstalled())
@ -846,8 +845,9 @@ void *SerialCommunicationManagerImp::eventLoop()
} }
pthread_mutex_unlock(&devices_lock_); pthread_mutex_unlock(&devices_lock_);
if (!all_working) if (!all_working && resetting_ == false)
{ {
debug("(serial) not all devices working, emergency exit!\n");
stop(); stop();
break; break;
} }
@ -968,8 +968,9 @@ void *SerialCommunicationManagerImp::eventLoop()
} }
} }
if (non_working.size() > 0) if (non_working.size() > 0 && resetting_ == false)
{ {
debug("(serial) non working devices found, exiting.\n");
stop(); stop();
break; break;
} }

Wyświetl plik

@ -3401,9 +3401,8 @@ bool WMBusCommonImplementation::reset()
resetting = true; resetting = true;
serial()->manager()->resetInitiated(); serial()->manager()->resetInitiated();
serial()->close(); serial()->close();
fprintf(stderr, "STOPPED serial, sleeping....\n"); // Give the device 3 seconds to shut down properly.
usleep(3000*1000); // Sleep for two seconds. usleep(3000*1000);
fprintf(stderr, "DONE sleeping\n");
} }
AccessCheck rc = serial()->open(false); AccessCheck rc = serial()->open(false);
@ -3418,7 +3417,6 @@ bool WMBusCommonImplementation::reset()
// Invoke any other device specific resets for this device. // Invoke any other device specific resets for this device.
deviceReset(); deviceReset();
debug("(GURKA) %d\n", resetting);
if (resetting) serial()->manager()->resetCompleted(); if (resetting) serial()->manager()->resetCompleted();
// If init, then no link modes are configured. // If init, then no link modes are configured.
@ -3437,7 +3435,7 @@ void WMBusCommonImplementation::checkStatus()
{ {
string msg; string msg;
strprintf(msg, "Hit max protocol errors(%d)! Resetting device %s %s!", protocol_error_count_, toString(type()), device().c_str()); strprintf(msg, "Hit max protocol errors(%d)! Resetting device %s %s!", protocol_error_count_, toString(type()), device().c_str());
logAlarm("PROTOCOL_ERROR", msg); logAlarm("device_failure", msg);
bool ok = reset(); bool ok = reset();
if (ok) if (ok)
{ {
@ -3447,7 +3445,7 @@ void WMBusCommonImplementation::checkStatus()
} }
strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str()); strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str());
logAlarm("WMBUS_DEVICE_ERROR", msg); logAlarm("device_failure", msg);
manager_->stop(); manager_->stop();
return; return;
} }
@ -3480,7 +3478,7 @@ void WMBusCommonImplementation::checkStatus()
timeout_, now.c_str(), expected_activity_.c_str(), timeout_, now.c_str(), expected_activity_.c_str(),
since, toString(type()), device().c_str()); since, toString(type()), device().c_str());
logAlarm("TIMEOUT_ERROR", msg); logAlarm("inactivity", msg);
bool ok = reset(); bool ok = reset();
if (ok) if (ok)
@ -3490,7 +3488,7 @@ void WMBusCommonImplementation::checkStatus()
else else
{ {
strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str()); strprintf(msg, "Failed to reset wmbus device %s %s! Emergency exit!", toString(type()), device().c_str());
logAlarm("WMBUS_DEVICE_ERROR", msg); logAlarm("device_failure", msg);
manager_->stop(); manager_->stop();
} }
} }