diff --git a/src/ebusd/bushandler.cpp b/src/ebusd/bushandler.cpp index fc8e45c7..f6ce51b2 100644 --- a/src/ebusd/bushandler.cpp +++ b/src/ebusd/bushandler.cpp @@ -607,7 +607,7 @@ result_t BusHandler::setState(BusState state, result_t result, bool firstRepetit if (master != SYN && !m_seenAddresses[master]) { m_seenAddresses[master] = true; m_masterCount++; - if (m_autoLockCount) + if (m_autoLockCount && m_masterCount>m_lockCount) m_lockCount = m_masterCount; logNotice(lf_bus, "new master %2.2x", master); } @@ -673,7 +673,7 @@ void BusHandler::receiveCompleted() unsigned char srcAddress = m_command[0], dstAddress = m_command[1]; if (isMaster(srcAddress) && !m_seenAddresses[srcAddress]) { m_masterCount++; - if (m_autoLockCount) + if (m_autoLockCount && m_masterCount>m_lockCount) m_lockCount = m_masterCount; logNotice(lf_bus, "new master %2.2x", srcAddress); } @@ -685,7 +685,7 @@ void BusHandler::receiveCompleted() logInfo(lf_update, "update MM cmd: %s", m_command.getDataStr().c_str()); if (!m_seenAddresses[dstAddress]) { m_masterCount++; - if (m_autoLockCount) + if (m_autoLockCount && m_masterCount>m_lockCount) m_lockCount = m_masterCount; logNotice(lf_bus, "new master %2.2x", dstAddress); } @@ -697,7 +697,7 @@ void BusHandler::receiveCompleted() if (masterAddr != SYN && !m_seenAddresses[masterAddr]) { m_seenAddresses[masterAddr] = true; m_masterCount++; - if (m_autoLockCount) + if (m_autoLockCount && m_masterCount>m_lockCount) m_lockCount = m_masterCount; logNotice(lf_bus, "new master %2.2x", masterAddr); } diff --git a/src/ebusd/bushandler.h b/src/ebusd/bushandler.h index 369c7f89..fa6f0d2c 100644 --- a/src/ebusd/bushandler.h +++ b/src/ebusd/bushandler.h @@ -270,7 +270,7 @@ public: m_ownMasterAddress(ownAddress), m_ownSlaveAddress((unsigned char)(ownAddress+5)), m_answer(answer), m_busLostRetries(busLostRetries), m_failedSendRetries(failedSendRetries), m_busAcquireTimeout(busAcquireTimeout), m_slaveRecvTimeout(slaveRecvTimeout), - m_masterCount(1), m_autoLockCount(lockCount==0), m_lockCount(lockCount==0 ? 1 : lockCount), m_remainLockCount(m_autoLockCount), + m_masterCount(1), m_autoLockCount(lockCount==0), m_lockCount(lockCount<=3 ? 3 : lockCount), m_remainLockCount(m_autoLockCount), m_pollInterval(pollInterval), m_lastReceive(0), m_lastPoll(0), m_currentRequest(NULL), m_nextSendPos(0), m_symPerSec(0), m_maxSymPerSec(0),