log and count new masters, added master count to state command
This commit is contained in:
+26
-19
@@ -369,8 +369,7 @@ result_t BusHandler::handleSymbol()
|
||||
}
|
||||
// arbitration lost. if same priority class found, try again after next AUTO-SYN
|
||||
m_remainLockCount = isMaster(recvSymbol) ? 2 : 1; // number of SYN to wait for before next send try
|
||||
if ((recvSymbol & 0x0f) != (sendSymbol & 0x0f)
|
||||
&& m_lockCount > m_remainLockCount)
|
||||
if ((recvSymbol & 0x0f) != (sendSymbol & 0x0f) && m_lockCount > m_remainLockCount)
|
||||
// if different priority class found, try again after N AUTO-SYN symbols (at least next AUTO-SYN)
|
||||
m_remainLockCount = m_lockCount;
|
||||
setState(m_state, RESULT_ERR_BUS_LOST); // try again later
|
||||
@@ -604,12 +603,13 @@ result_t BusHandler::setState(BusState state, result_t result, bool firstRepetit
|
||||
logDebug(lf_bus, "notify request: %s", getResultCode(result));
|
||||
unsigned char dstAddress = m_currentRequest->m_master[1];
|
||||
if (result == RESULT_OK && isValidAddress(dstAddress, false) && !m_seenAddresses[dstAddress]) {
|
||||
if (m_autoLockCount) {
|
||||
unsigned char master = getMasterAddress(dstAddress);
|
||||
if (master != SYN && !m_seenAddresses[master]) {
|
||||
m_seenAddresses[master] = true;
|
||||
m_lockCount++;
|
||||
}
|
||||
unsigned char master = getMasterAddress(dstAddress);
|
||||
if (master != SYN && !m_seenAddresses[master]) {
|
||||
m_seenAddresses[master] = true;
|
||||
m_masterCount++;
|
||||
if (m_autoLockCount)
|
||||
m_lockCount = m_masterCount;
|
||||
logNotice(lf_bus, "new master %2.2x", master);
|
||||
}
|
||||
m_seenAddresses[dstAddress] = true;
|
||||
}
|
||||
@@ -671,28 +671,35 @@ result_t BusHandler::setState(BusState state, result_t result, bool firstRepetit
|
||||
void BusHandler::receiveCompleted()
|
||||
{
|
||||
unsigned char srcAddress = m_command[0], dstAddress = m_command[1];
|
||||
bool master = isMaster(dstAddress);
|
||||
if (m_autoLockCount && isMaster(srcAddress) && !m_seenAddresses[srcAddress]) {
|
||||
m_lockCount++;
|
||||
if (isMaster(srcAddress) && !m_seenAddresses[srcAddress]) {
|
||||
m_masterCount++;
|
||||
if (m_autoLockCount)
|
||||
m_lockCount = m_masterCount;
|
||||
logNotice(lf_bus, "new master %2.2x", srcAddress);
|
||||
}
|
||||
bool master = isMaster(dstAddress);
|
||||
m_seenAddresses[srcAddress] = true;
|
||||
if (dstAddress == BROADCAST)
|
||||
logInfo(lf_update, "update BC cmd: %s", m_command.getDataStr().c_str());
|
||||
else if (master) {
|
||||
logInfo(lf_update, "update MM cmd: %s", m_command.getDataStr().c_str());
|
||||
if (m_autoLockCount && !m_seenAddresses[dstAddress]) {
|
||||
m_lockCount++;
|
||||
if (!m_seenAddresses[dstAddress]) {
|
||||
m_masterCount++;
|
||||
if (m_autoLockCount)
|
||||
m_lockCount = m_masterCount;
|
||||
logNotice(lf_bus, "new master %2.2x", dstAddress);
|
||||
}
|
||||
m_seenAddresses[dstAddress] = true;
|
||||
}
|
||||
else {
|
||||
logInfo(lf_update, "update MS cmd: %s / %s", m_command.getDataStr().c_str(), m_response.getDataStr().c_str());
|
||||
if (m_autoLockCount) {
|
||||
unsigned char master = getMasterAddress(dstAddress);
|
||||
if (master != SYN && !m_seenAddresses[master]) {
|
||||
m_seenAddresses[master] = true;
|
||||
m_lockCount++;
|
||||
}
|
||||
unsigned char masterAddr = getMasterAddress(dstAddress);
|
||||
if (masterAddr != SYN && !m_seenAddresses[masterAddr]) {
|
||||
m_seenAddresses[masterAddr] = true;
|
||||
m_masterCount++;
|
||||
if (m_autoLockCount)
|
||||
m_lockCount = m_masterCount;
|
||||
logNotice(lf_bus, "new master %2.2x", masterAddr);
|
||||
}
|
||||
m_seenAddresses[dstAddress] = true;
|
||||
}
|
||||
|
||||
+10
-8
@@ -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_autoLockCount(lockCount==0), m_lockCount(lockCount==0 ? 1 : lockCount), m_remainLockCount(lockCount),
|
||||
m_masterCount(1), m_autoLockCount(lockCount==0), m_lockCount(lockCount==0 ? 1 : 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),
|
||||
@@ -302,13 +302,6 @@ public:
|
||||
*/
|
||||
virtual void run();
|
||||
|
||||
/**
|
||||
* Get the last received data for the @a Message.
|
||||
* @param message the @a Message instance.
|
||||
* @return the last received data for the @a Message, or the empty string if not available.
|
||||
*/
|
||||
string getReceivedData(Message* message);
|
||||
|
||||
/**
|
||||
* Initiate a scan of the slave addresses.
|
||||
* @param full true for a full scan (all slaves), false for scanning only already seen slaves.
|
||||
@@ -340,6 +333,12 @@ public:
|
||||
*/
|
||||
unsigned int getMaxSymbolRate() { return m_maxSymPerSec; }
|
||||
|
||||
/**
|
||||
* Return the number of masters already seen.
|
||||
* @return the number of masters already seen (including ebusd itself).
|
||||
*/
|
||||
unsigned int getMasterCount() { return m_masterCount; }
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
@@ -389,6 +388,9 @@ private:
|
||||
/** the maximum time in microseconds an addressed slave is expected to acknowledge. */
|
||||
const unsigned int m_slaveRecvTimeout;
|
||||
|
||||
/** the number of masters already seen. */
|
||||
unsigned int m_masterCount;
|
||||
|
||||
/** whether m_lockCount shall be detected automatically. */
|
||||
const bool m_autoLockCount;
|
||||
|
||||
|
||||
@@ -565,8 +565,9 @@ string MainLoop::executeState(vector<string> &args)
|
||||
if (m_busHandler->hasSignal()) {
|
||||
ostringstream result;
|
||||
result << "signal acquired, "
|
||||
<< static_cast<unsigned>(m_busHandler->getSymbolRate()) << " symbols/sec, max. "
|
||||
<< static_cast<unsigned>(m_busHandler->getMaxSymbolRate()) << " symbols/sec";
|
||||
<< static_cast<unsigned>(m_busHandler->getSymbolRate()) << " symbols/sec ("
|
||||
<< static_cast<unsigned>(m_busHandler->getMaxSymbolRate()) << " max), "
|
||||
<< static_cast<unsigned>(m_busHandler->getMasterCount()) << " masters";
|
||||
return result.str();
|
||||
}
|
||||
return "no signal";
|
||||
|
||||
Reference in New Issue
Block a user