From b3a92c8b2d46488b611fe60c6b2c47401efae44c Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Sun, 21 Apr 2019 19:33:09 +0200 Subject: dp-master: Data_Exchange: Wait with error reaction until a couple of telegrams have been sent. Signed-off-by: Michael Buesch --- pyprofibus/dp_master.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyprofibus/dp_master.py b/pyprofibus/dp_master.py index 6fd0e50..01ddabb 100644 --- a/pyprofibus/dp_master.py +++ b/pyprofibus/dp_master.py @@ -71,6 +71,9 @@ class DpSlaveState(object): self.pendingReqTimeout = TimeLimit() self.shortAckReceived = False + # Data_Exchange context + self.dxStartTime = 0.0 + # Received telegrams self.rxQueue = [] @@ -468,8 +471,11 @@ class DpMaster(object): self.__debugMsg("Initialization finished. " "Running Data_Exchange with slave %d..." %\ slave.slaveDesc.slaveAddr) + slave.dxStartTime = monotonic_time() - if slave.pendingReqTimeout.exceed(): + if slave.pendingReq and slave.pendingReqTimeout.exceed(): + self.__debugMsg("Data_Exchange timeout with slave %d" % ( + slave.slaveDesc.slaveAddr)) slave.faultDeb.fault() slave.pendingReq = None @@ -512,7 +518,7 @@ class DpMaster(object): # communication lost self.__debugMsg("Communication lost in Data_Exchange.") slave.setState(slave.STATE_INIT) - elif faultCount >= 3: + elif faultCount >= 3 and monotonic_time() >= slave.dxStartTime + 0.2: # Diagnose the slave self.__debugMsg("Many errors in Data_Exchange. " "Requesting diagnostic information...") -- cgit v1.2.3