From 6782e9431ac2fe7034f567d89070b370cf46235c Mon Sep 17 00:00:00 2001
From: NaruX
Date: Thu, 7 Mar 2019 12:50:35 +0100
Subject: [PATCH] Bessere Werte bei _gotioerror Debugflag um exakte
Fehlermeldungen zu bekommen
---
doc/revpimodio2.helper.html | 9 +++++++--
doc/revpimodio2.modio.html | 14 +++++++++++---
eric-revpimodio2.api | 6 +++---
revpimodio2.e4p | 2 +-
revpimodio2/device.py | 4 ++--
revpimodio2/helper.py | 12 ++++++++----
revpimodio2/io.py | 8 ++++----
revpimodio2/modio.py | 33 ++++++++++++++++++++++-----------
8 files changed, 58 insertions(+), 30 deletions(-)
diff --git a/doc/revpimodio2.helper.html b/doc/revpimodio2.helper.html
index 634fd01..0224b20 100644
--- a/doc/revpimodio2.helper.html
+++ b/doc/revpimodio2.helper.html
@@ -535,10 +535,15 @@ Aktuelle Fehleranzahl
ProcimgWriter._gotioerror
-_gotioerror()
+_gotioerror(e=None)
IOError Verwaltung fuer autorefresh.
-
+
+- e
+-
+Exception to log if debug is enabled
+
+
ProcimgWriter.get_maxioerrors
get_maxioerrors()
diff --git a/doc/revpimodio2.modio.html b/doc/revpimodio2.modio.html
index 0955981..2b6dead 100644
--- a/doc/revpimodio2.modio.html
+++ b/doc/revpimodio2.modio.html
@@ -158,7 +158,7 @@ Static Methods
RevPiModIO (Constructor)
-RevPiModIO(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False)
+RevPiModIO(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False, debug=False)
Instantiiert die Grundfunktionen.
@@ -305,10 +305,18 @@ True, wenn als Simulator gestartet
RevPiModIO._gotioerror
-_gotioerror(action)
+_gotioerror(action, e=None)
IOError Verwaltung fuer Prozessabbildzugriff.
-
+
+- action
+-
+Zusatzinformationen zum loggen
+
- e
+-
+Exception to log if debug is enabled
+
+
RevPiModIO._set_cycletime
_set_cycletime(milliseconds)
diff --git a/eric-revpimodio2.api b/eric-revpimodio2.api
index cda1ec5..346f981 100644
--- a/eric-revpimodio2.api
+++ b/eric-revpimodio2.api
@@ -81,7 +81,7 @@ revpimodio2.helper.EventCallback.stop?4()
revpimodio2.helper.EventCallback?1(func, name, value)
revpimodio2.helper.ProcimgWriter._collect_events?5(value)
revpimodio2.helper.ProcimgWriter._get_ioerrors?5()
-revpimodio2.helper.ProcimgWriter._gotioerror?5()
+revpimodio2.helper.ProcimgWriter._gotioerror?5(e=None)
revpimodio2.helper.ProcimgWriter.get_maxioerrors?4()
revpimodio2.helper.ProcimgWriter.get_refresh?4()
revpimodio2.helper.ProcimgWriter.ioerrors?7
@@ -149,7 +149,7 @@ revpimodio2.modio.RevPiModIO._get_maxioerrors?5()
revpimodio2.modio.RevPiModIO._get_monitoring?5()
revpimodio2.modio.RevPiModIO._get_procimg?5()
revpimodio2.modio.RevPiModIO._get_simulator?5()
-revpimodio2.modio.RevPiModIO._gotioerror?5(action)
+revpimodio2.modio.RevPiModIO._gotioerror?5(action, e=None)
revpimodio2.modio.RevPiModIO._set_cycletime?5(milliseconds)
revpimodio2.modio.RevPiModIO._set_maxioerrors?5(value)
revpimodio2.modio.RevPiModIO.autorefresh_all?4()
@@ -172,7 +172,7 @@ revpimodio2.modio.RevPiModIO.setdefaultvalues?4(device=None)
revpimodio2.modio.RevPiModIO.simulator?7
revpimodio2.modio.RevPiModIO.syncoutputs?4(device=None)
revpimodio2.modio.RevPiModIO.writeprocimg?4(device=None)
-revpimodio2.modio.RevPiModIO?1(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False)
+revpimodio2.modio.RevPiModIO?1(autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False, debug=False)
revpimodio2.modio.RevPiModIODriver?1(virtdev, autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None)
revpimodio2.modio.RevPiModIOSelected?1(deviceselection, autorefresh=False, monitoring=False, syncoutputs=True, procimg=None, configrsc=None, simulator=False)
revpimodio2.netio.NetFH._connect?5()
diff --git a/revpimodio2.e4p b/revpimodio2.e4p
index fcc94de..b03717f 100644
--- a/revpimodio2.e4p
+++ b/revpimodio2.e4p
@@ -1,7 +1,7 @@
-
+
en_US
diff --git a/revpimodio2/device.py b/revpimodio2/device.py
index 8741b46..4d70108 100644
--- a/revpimodio2/device.py
+++ b/revpimodio2/device.py
@@ -961,8 +961,8 @@ class Virtual(Gateway):
self._modio._myfh.write(self._ba_devdata[self._slc_inp])
if self._modio._buffedwrite:
self._modio._myfh.flush()
- except IOError:
- self._modio._gotioerror("write")
+ except IOError as e:
+ self._modio._gotioerror("write_inp_def", e)
workokay = False
finally:
self._modio._myfh_lck.release()
diff --git a/revpimodio2/helper.py b/revpimodio2/helper.py
index 328bafe..e6fd9e1 100644
--- a/revpimodio2/helper.py
+++ b/revpimodio2/helper.py
@@ -430,8 +430,10 @@ class ProcimgWriter(Thread):
@return Aktuelle Fehleranzahl"""
return self._ioerror
- def _gotioerror(self):
- """IOError Verwaltung fuer autorefresh."""
+ def _gotioerror(self, e=None):
+ """IOError Verwaltung fuer autorefresh.
+ @param e Exception to log if debug is enabled
+ """
self._ioerror += 1
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
raise RuntimeError(
@@ -443,6 +445,8 @@ class ProcimgWriter(Thread):
"count {0} io errors on process image".format(self._ioerror),
RuntimeWarning
)
+ if self._modio._debug and e is not None:
+ warnings.warn(str(e))
def get_maxioerrors(self):
"""Gibt die Anzahl der maximal erlaubten Fehler zurueck.
@@ -504,8 +508,8 @@ class ProcimgWriter(Thread):
if self._modio._buffedwrite:
fh.flush()
- except IOError:
- self._gotioerror()
+ except IOError as e:
+ self._gotioerror(e)
self.lck_refresh.release()
continue
diff --git a/revpimodio2/io.py b/revpimodio2/io.py
index 2a203d8..47432e9 100644
--- a/revpimodio2/io.py
+++ b/revpimodio2/io.py
@@ -836,8 +836,8 @@ class IntIOCounter(IntIO):
self._parentdevice._modio._myfh.ioctl(
19220, self.__ioctl_arg
)
- except Exception:
- self._parentdevice._modio._gotioerror("net_ioctl")
+ except Exception as e:
+ self._parentdevice._modio._gotioerror("net_ioctl", e)
elif self._parentdevice._modio._procimg != "/dev/piControl0":
# NOTE: Soll hier eine 0 in den Input geschrieben werden?
@@ -855,8 +855,8 @@ class IntIOCounter(IntIO):
self._parentdevice._modio._myfh,
19220, self.__ioctl_arg
)
- except Exception:
- self._parentdevice._modio._gotioerror("ioctl")
+ except Exception as e:
+ self._parentdevice._modio._gotioerror("ioctl", e)
class IntIOReplaceable(IntIO):
diff --git a/revpimodio2/modio.py b/revpimodio2/modio.py
index d486cd6..023e5a2 100644
--- a/revpimodio2/modio.py
+++ b/revpimodio2/modio.py
@@ -32,11 +32,11 @@ class RevPiModIO(object):
"_looprunning", "_lst_devselect", "_lst_refresh", "_maxioerrors", \
"_myfh", "_myfh_lck", "_monitoring", "_procimg", "_simulator", \
"_syncoutputs", "_th_mainloop", "_waitexit", \
- "core", "app", "device", "exitsignal", "io", "summary"
+ "core", "app", "device", "exitsignal", "io", "summary", "_debug"
def __init__(
self, autorefresh=False, monitoring=False, syncoutputs=True,
- procimg=None, configrsc=None, simulator=False):
+ procimg=None, configrsc=None, simulator=False, debug=False):
"""Instantiiert die Grundfunktionen.
@param autorefresh Wenn True, alle Devices zu autorefresh hinzufuegen
@@ -59,6 +59,7 @@ class RevPiModIO(object):
# Private Variablen
self.__cleanupfunc = None
self._buffedwrite = False
+ self._debug = debug
self._exit = Event()
self._imgwriter = None
self._ioerror = 0
@@ -316,8 +317,13 @@ class RevPiModIO(object):
@return True, wenn als Simulator gestartet"""
return self._simulator
- def _gotioerror(self, action):
- """IOError Verwaltung fuer Prozessabbildzugriff."""
+ def _gotioerror(self, action, e=None):
+ """IOError Verwaltung fuer Prozessabbildzugriff.
+
+ @param action Zusatzinformationen zum loggen
+ @param e Exception to log if debug is enabled
+
+ """
self._ioerror += 1
if self._maxioerrors != 0 and self._ioerror >= self._maxioerrors:
raise RuntimeError(
@@ -329,6 +335,8 @@ class RevPiModIO(object):
"".format(action, self._ioerror),
RuntimeWarning
)
+ if self._debug and e is not None:
+ warnings.warn(str(e))
def _set_cycletime(self, milliseconds):
"""Setzt Aktualisierungsrate der Prozessabbild-Synchronisierung.
@@ -692,8 +700,8 @@ class RevPiModIO(object):
try:
self._myfh.seek(0)
bytesbuff = self._myfh.read(self._length)
- except IOError:
- self._gotioerror("read")
+ except IOError as e:
+ self._gotioerror("readprocimg", e)
return False
finally:
self._myfh_lck.release()
@@ -769,8 +777,8 @@ class RevPiModIO(object):
try:
self._myfh.seek(0)
bytesbuff = self._myfh.read(self._length)
- except IOError:
- self._gotioerror("read")
+ except IOError as e:
+ self._gotioerror("syncoutputs", e)
return False
finally:
self._myfh_lck.release()
@@ -811,6 +819,7 @@ class RevPiModIO(object):
)
mylist = [dev]
+ e = None
workokay = True
for dev in mylist:
if not dev._selfupdate:
@@ -821,7 +830,8 @@ class RevPiModIO(object):
try:
self._myfh.seek(dev._slc_outoff.start)
self._myfh.write(dev._ba_devdata[dev._slc_out])
- except IOError:
+ except IOError as e:
+ e = e
workokay = False
finally:
self._myfh_lck.release()
@@ -831,11 +841,12 @@ class RevPiModIO(object):
if self._buffedwrite:
try:
self._myfh.flush()
- except IOError:
+ except IOError as e:
+ e = e
workokay = False
if not workokay:
- self._gotioerror("write")
+ self._gotioerror("writeprocimg", e)
return workokay