aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2019-04-21 19:33:09 +0200
committerMichael Buesch <m@bues.ch>2019-04-21 19:49:57 +0200
commitb3a92c8b2d46488b611fe60c6b2c47401efae44c (patch)
treee3eecb0989ef5d616c4b647bac6e8db502e5475d
parent836e085a693a74d88e3b4f465c6230fa2685a8b7 (diff)
downloadpyprofibus-b3a92c8b2d46488b611fe60c6b2c47401efae44c.tar.xz
pyprofibus-b3a92c8b2d46488b611fe60c6b2c47401efae44c.zip
dp-master: Data_Exchange: Wait with error reaction
until a couple of telegrams have been sent. Signed-off-by: Michael Buesch <m@bues.ch>
-rw-r--r--pyprofibus/dp_master.py10
1 files 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...")
bues.ch cgit interface