mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-12-28 18:08:02 +01:00
NetFH braucht min. RevPiPyLoad 0.8.0 da hashwerte übertragen werden
NetFH wirft ConfigChanged bei geänderten piCtory oder replace_ios Dateien
This commit is contained in:
@@ -12,7 +12,7 @@ RevPiModIO Hauptklasse fuer Netzwerkzugriff.
|
|||||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
Global Attributes</h3>
|
Global Attributes</h3>
|
||||||
<table>
|
<table>
|
||||||
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_sysreplaceio</td></tr><tr><td>_syssync</td></tr>
|
<tr><td>__author__</td></tr><tr><td>__copyright__</td></tr><tr><td>__license__</td></tr><tr><td>_sysdeldirty</td></tr><tr><td>_sysexit</td></tr><tr><td>_sysflush</td></tr><tr><td>_syspictory</td></tr><tr><td>_syspictoryh</td></tr><tr><td>_sysreplaceio</td></tr><tr><td>_sysreplaceioh</td></tr><tr><td>_syssync</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
Classes</h3>
|
Classes</h3>
|
||||||
@@ -21,6 +21,9 @@ Classes</h3>
|
|||||||
<td><a style="color:#0000FF" href="#AclException">AclException</a></td>
|
<td><a style="color:#0000FF" href="#AclException">AclException</a></td>
|
||||||
<td>Probleme mit Berechtigungen.</td>
|
<td>Probleme mit Berechtigungen.</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
<td><a style="color:#0000FF" href="#ConfigChanged">ConfigChanged</a></td>
|
||||||
|
<td>Aenderung der piCtory oder replace_ios Datei.</td>
|
||||||
|
</tr><tr>
|
||||||
<td><a style="color:#0000FF" href="#NetFH">NetFH</a></td>
|
<td><a style="color:#0000FF" href="#NetFH">NetFH</a></td>
|
||||||
<td>Netzwerk File Handler fuer das Prozessabbild.</td>
|
<td>Netzwerk File Handler fuer das Prozessabbild.</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
@@ -69,6 +72,37 @@ Static Methods</h3>
|
|||||||
<tr><td>None</td></tr>
|
<tr><td>None</td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||||
|
<hr /><hr />
|
||||||
|
<a NAME="ConfigChanged" ID="ConfigChanged"></a>
|
||||||
|
<h2 style="background-color:#FFFFFF;color:#0000FF">ConfigChanged</h2>
|
||||||
|
<p>
|
||||||
|
Aenderung der piCtory oder replace_ios Datei.
|
||||||
|
</p>
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
Derived from</h3>
|
||||||
|
Exception
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
Class Attributes</h3>
|
||||||
|
<table>
|
||||||
|
<tr><td>None</td></tr>
|
||||||
|
</table>
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
Class Methods</h3>
|
||||||
|
<table>
|
||||||
|
<tr><td>None</td></tr>
|
||||||
|
</table>
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
Methods</h3>
|
||||||
|
<table>
|
||||||
|
<tr><td>None</td></tr>
|
||||||
|
</table>
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
Static Methods</h3>
|
||||||
|
<table>
|
||||||
|
<tr><td>None</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
<div align="right"><a style="color:#0000FF" href="#top">Up</a></div>
|
||||||
<hr /><hr />
|
<hr /><hr />
|
||||||
<a NAME="NetFH" ID="NetFH"></a>
|
<a NAME="NetFH" ID="NetFH"></a>
|
||||||
@@ -470,6 +504,9 @@ Methods</h3>
|
|||||||
<td><a style="color:#0000FF" href="#RevPiNetIO.disconnect">disconnect</a></td>
|
<td><a style="color:#0000FF" href="#RevPiNetIO.disconnect">disconnect</a></td>
|
||||||
<td>Trennt Verbindungen und beendet autorefresh inkl.</td>
|
<td>Trennt Verbindungen und beendet autorefresh inkl.</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
|
<td><a style="color:#0000FF" href="#RevPiNetIO.exit">exit</a></td>
|
||||||
|
<td>Beendet mainloop() und optional autorefresh.</td>
|
||||||
|
</tr><tr>
|
||||||
<td><a style="color:#0000FF" href="#RevPiNetIO.get_jconfigrsc">get_jconfigrsc</a></td>
|
<td><a style="color:#0000FF" href="#RevPiNetIO.get_jconfigrsc">get_jconfigrsc</a></td>
|
||||||
<td>Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.</td>
|
<td>Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
@@ -544,7 +581,18 @@ RevPiNetIO.disconnect</h3>
|
|||||||
<b>disconnect</b>(<i></i>)
|
<b>disconnect</b>(<i></i>)
|
||||||
<p>
|
<p>
|
||||||
Trennt Verbindungen und beendet autorefresh inkl. alle Threads.
|
Trennt Verbindungen und beendet autorefresh inkl. alle Threads.
|
||||||
</p><a NAME="RevPiNetIO.get_jconfigrsc" ID="RevPiNetIO.get_jconfigrsc"></a>
|
</p><a NAME="RevPiNetIO.exit" ID="RevPiNetIO.exit"></a>
|
||||||
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
|
RevPiNetIO.exit</h3>
|
||||||
|
<b>exit</b>(<i>full=True</i>)
|
||||||
|
<p>
|
||||||
|
Beendet mainloop() und optional autorefresh.
|
||||||
|
</p><dl>
|
||||||
|
<dt><b>See Also:</b></dt>
|
||||||
|
<dd>
|
||||||
|
<a style="color:#0000FF" href="#RevPiModIO.exit(...)">#RevPiModIO.exit(...)</a>
|
||||||
|
</dd>
|
||||||
|
</dl><a NAME="RevPiNetIO.get_jconfigrsc" ID="RevPiNetIO.get_jconfigrsc"></a>
|
||||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||||
RevPiNetIO.get_jconfigrsc</h3>
|
RevPiNetIO.get_jconfigrsc</h3>
|
||||||
<b>get_jconfigrsc</b>(<i></i>)
|
<b>get_jconfigrsc</b>(<i></i>)
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ revpimodio2.netio.NetFH?1(address, timeout=500)
|
|||||||
revpimodio2.netio.RevPiNetIO._create_myfh?5()
|
revpimodio2.netio.RevPiNetIO._create_myfh?5()
|
||||||
revpimodio2.netio.RevPiNetIO._get_cpreplaceio?5()
|
revpimodio2.netio.RevPiNetIO._get_cpreplaceio?5()
|
||||||
revpimodio2.netio.RevPiNetIO.disconnect?4()
|
revpimodio2.netio.RevPiNetIO.disconnect?4()
|
||||||
|
revpimodio2.netio.RevPiNetIO.exit?4(full=True)
|
||||||
revpimodio2.netio.RevPiNetIO.get_jconfigrsc?4()
|
revpimodio2.netio.RevPiNetIO.get_jconfigrsc?4()
|
||||||
revpimodio2.netio.RevPiNetIO.get_reconnecting?4()
|
revpimodio2.netio.RevPiNetIO.get_reconnecting?4()
|
||||||
revpimodio2.netio.RevPiNetIO.net_cleardefaultvalues?4(device=None)
|
revpimodio2.netio.RevPiNetIO.net_cleardefaultvalues?4(device=None)
|
||||||
@@ -224,6 +225,8 @@ revpimodio2.netio._sysdeldirty?8
|
|||||||
revpimodio2.netio._sysexit?8
|
revpimodio2.netio._sysexit?8
|
||||||
revpimodio2.netio._sysflush?8
|
revpimodio2.netio._sysflush?8
|
||||||
revpimodio2.netio._syspictory?8
|
revpimodio2.netio._syspictory?8
|
||||||
|
revpimodio2.netio._syspictoryh?8
|
||||||
revpimodio2.netio._sysreplaceio?8
|
revpimodio2.netio._sysreplaceio?8
|
||||||
|
revpimodio2.netio._sysreplaceioh?8
|
||||||
revpimodio2.netio._syssync?8
|
revpimodio2.netio._syssync?8
|
||||||
revpimodio2.summary.Summary?1(summary)
|
revpimodio2.summary.Summary?1(summary)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
AclException Exception
|
AclException Exception
|
||||||
Base Device
|
Base Device
|
||||||
|
ConfigChanged Exception
|
||||||
Connect Core
|
Connect Core
|
||||||
Core Base
|
Core Base
|
||||||
DeviceNotFoundError Exception
|
DeviceNotFoundError Exception
|
||||||
|
|||||||
@@ -22,8 +22,10 @@ _sysexit = b'\x01EX\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
|||||||
_sysdeldirty = b'\x01EY\x00\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x17'
|
_sysdeldirty = b'\x01EY\x00\x00\x00\x00\xFF\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
# piCtory Konfiguration laden
|
# piCtory Konfiguration laden
|
||||||
_syspictory = b'\x01PI\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
_syspictory = b'\x01PI\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
|
_syspictoryh = b'\x01PH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
# ReplaceIO Konfiguration laden
|
# ReplaceIO Konfiguration laden
|
||||||
_sysreplaceio = b'\x01RP\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
_sysreplaceio = b'\x01RP\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
|
_sysreplaceioh = b'\x01RH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
# Übertragene Bytes schreiben
|
# Übertragene Bytes schreiben
|
||||||
_sysflush = b'\x01SD\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x17'
|
_sysflush = b'\x01SD\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||||
|
|
||||||
@@ -35,6 +37,13 @@ class AclException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigChanged(Exception):
|
||||||
|
|
||||||
|
"""Aenderung der piCtory oder replace_ios Datei."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NetFH(Thread):
|
class NetFH(Thread):
|
||||||
|
|
||||||
"""Netzwerk File Handler fuer das Prozessabbild.
|
"""Netzwerk File Handler fuer das Prozessabbild.
|
||||||
@@ -59,9 +68,12 @@ class NetFH(Thread):
|
|||||||
self.daemon = True
|
self.daemon = True
|
||||||
|
|
||||||
self.__by_buff = b''
|
self.__by_buff = b''
|
||||||
|
self.__config_changed = False
|
||||||
self.__int_buff = 0
|
self.__int_buff = 0
|
||||||
self.__dictdirty = {}
|
self.__dictdirty = {}
|
||||||
self.__flusherr = False
|
self.__flusherr = False
|
||||||
|
self.__replace_ios_h = b''
|
||||||
|
self.__pictory_h = b''
|
||||||
self.__sockact = False
|
self.__sockact = False
|
||||||
self.__sockerr = Event()
|
self.__sockerr = Event()
|
||||||
self.__sockend = Event()
|
self.__sockend = Event()
|
||||||
@@ -134,6 +146,37 @@ class NetFH(Thread):
|
|||||||
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
try:
|
try:
|
||||||
so.connect(self._address)
|
so.connect(self._address)
|
||||||
|
|
||||||
|
# Hashwerte anfordern
|
||||||
|
so.sendall(_syspictoryh + _sysreplaceioh)
|
||||||
|
|
||||||
|
# Hashwerte empfangen
|
||||||
|
byte_buff = bytearray()
|
||||||
|
zero_byte = 0
|
||||||
|
while not self.__sockend.is_set() and zero_byte < 100 \
|
||||||
|
and len(byte_buff) < 32:
|
||||||
|
data = so.recv(32)
|
||||||
|
if data == b'':
|
||||||
|
zero_byte += 1
|
||||||
|
byte_buff += data
|
||||||
|
|
||||||
|
# Änderung an piCtory prüfen
|
||||||
|
if self.__pictory_h and byte_buff[:16] != self.__pictory_h:
|
||||||
|
self.__config_changed = True
|
||||||
|
self.close()
|
||||||
|
raise ConfigChanged(
|
||||||
|
"configuration on revolution pi was changed")
|
||||||
|
else:
|
||||||
|
self.__pictory_h = byte_buff[:16]
|
||||||
|
|
||||||
|
# Änderung an replace_ios prüfen
|
||||||
|
if self.__replace_ios_h and byte_buff[16:] != self.__replace_ios_h:
|
||||||
|
self.__config_changed = True
|
||||||
|
self.close()
|
||||||
|
raise ConfigChanged(
|
||||||
|
"configuration on revolution pi was changed")
|
||||||
|
else:
|
||||||
|
self.__replace_ios_h = byte_buff[16:]
|
||||||
except Exception:
|
except Exception:
|
||||||
so.close()
|
so.close()
|
||||||
else:
|
else:
|
||||||
@@ -174,6 +217,10 @@ class NetFH(Thread):
|
|||||||
def clear_dirtybytes(self, position=None):
|
def clear_dirtybytes(self, position=None):
|
||||||
"""Entfernt die konfigurierten Dirtybytes vom RevPi Slave.
|
"""Entfernt die konfigurierten Dirtybytes vom RevPi Slave.
|
||||||
@param position Startposition der Dirtybytes"""
|
@param position Startposition der Dirtybytes"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged(
|
||||||
|
"configuration on revolution pi was changed"
|
||||||
|
)
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("I/O operation on closed file")
|
raise ValueError("I/O operation on closed file")
|
||||||
|
|
||||||
@@ -243,6 +290,10 @@ class NetFH(Thread):
|
|||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
"""Schreibpuffer senden."""
|
"""Schreibpuffer senden."""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged(
|
||||||
|
"configuration on revolution pi was changed"
|
||||||
|
)
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("flush of closed file")
|
raise ValueError("flush of closed file")
|
||||||
|
|
||||||
@@ -295,6 +346,8 @@ class NetFH(Thread):
|
|||||||
"""IOCTL Befehle ueber das Netzwerk senden.
|
"""IOCTL Befehle ueber das Netzwerk senden.
|
||||||
@param request Request as <class 'int'>
|
@param request Request as <class 'int'>
|
||||||
@param arg Argument as <class 'byte'>"""
|
@param arg Argument as <class 'byte'>"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("read of closed file")
|
raise ValueError("read of closed file")
|
||||||
|
|
||||||
@@ -326,6 +379,8 @@ class NetFH(Thread):
|
|||||||
"""Daten ueber das Netzwerk lesen.
|
"""Daten ueber das Netzwerk lesen.
|
||||||
@param length Anzahl der Bytes
|
@param length Anzahl der Bytes
|
||||||
@return Gelesene <class 'bytes'>"""
|
@return Gelesene <class 'bytes'>"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("read of closed file")
|
raise ValueError("read of closed file")
|
||||||
|
|
||||||
@@ -443,6 +498,8 @@ class NetFH(Thread):
|
|||||||
def seek(self, position):
|
def seek(self, position):
|
||||||
"""Springt an angegebene Position.
|
"""Springt an angegebene Position.
|
||||||
@param position An diese Position springen"""
|
@param position An diese Position springen"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("seek of closed file")
|
raise ValueError("seek of closed file")
|
||||||
self.__position = int(position)
|
self.__position = int(position)
|
||||||
@@ -451,6 +508,8 @@ class NetFH(Thread):
|
|||||||
"""Konfiguriert Dirtybytes fuer Prozessabbild bei Verbindungsfehler.
|
"""Konfiguriert Dirtybytes fuer Prozessabbild bei Verbindungsfehler.
|
||||||
@param positon Startposition zum Schreiben
|
@param positon Startposition zum Schreiben
|
||||||
@param dirtybytes <class 'bytes'> die geschrieben werden sollen"""
|
@param dirtybytes <class 'bytes'> die geschrieben werden sollen"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("I/O operation on closed file")
|
raise ValueError("I/O operation on closed file")
|
||||||
|
|
||||||
@@ -519,6 +578,8 @@ class NetFH(Thread):
|
|||||||
def tell(self):
|
def tell(self):
|
||||||
"""Gibt aktuelle Position zurueck.
|
"""Gibt aktuelle Position zurueck.
|
||||||
@return int aktuelle Position"""
|
@return int aktuelle Position"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("I/O operation on closed file")
|
raise ValueError("I/O operation on closed file")
|
||||||
return self.__position
|
return self.__position
|
||||||
@@ -527,6 +588,8 @@ class NetFH(Thread):
|
|||||||
"""Daten ueber das Netzwerk schreiben.
|
"""Daten ueber das Netzwerk schreiben.
|
||||||
@param bytebuff Bytes zum schreiben
|
@param bytebuff Bytes zum schreiben
|
||||||
@return <class 'int'> Anzahl geschriebener bytes"""
|
@return <class 'int'> Anzahl geschriebener bytes"""
|
||||||
|
if self.__config_changed:
|
||||||
|
raise ConfigChanged("configuration on revolution pi was changed")
|
||||||
if self.__sockend.is_set():
|
if self.__sockend.is_set():
|
||||||
raise ValueError("write to closed file")
|
raise ValueError("write to closed file")
|
||||||
|
|
||||||
@@ -674,6 +737,14 @@ class RevPiNetIO(_RevPiModIO):
|
|||||||
"""Trennt Verbindungen und beendet autorefresh inkl. alle Threads."""
|
"""Trennt Verbindungen und beendet autorefresh inkl. alle Threads."""
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
|
||||||
|
def exit(self, full=True):
|
||||||
|
"""Beendet mainloop() und optional autorefresh.
|
||||||
|
@see #RevPiModIO.exit(...)"""
|
||||||
|
try:
|
||||||
|
super().exit(full)
|
||||||
|
except ConfigChanged:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_jconfigrsc(self):
|
def get_jconfigrsc(self):
|
||||||
"""Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.
|
"""Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.
|
||||||
@return <class 'dict'> der piCtory Konfiguration"""
|
@return <class 'dict'> der piCtory Konfiguration"""
|
||||||
|
|||||||
Reference in New Issue
Block a user