mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +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">
|
||||
Global Attributes</h3>
|
||||
<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>
|
||||
<h3 style="background-color:#FFFFFF;color:#FF0000">
|
||||
Classes</h3>
|
||||
@@ -21,6 +21,9 @@ Classes</h3>
|
||||
<td><a style="color:#0000FF" href="#AclException">AclException</a></td>
|
||||
<td>Probleme mit Berechtigungen.</td>
|
||||
</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>Netzwerk File Handler fuer das Prozessabbild.</td>
|
||||
</tr><tr>
|
||||
@@ -69,6 +72,37 @@ Static Methods</h3>
|
||||
<tr><td>None</td></tr>
|
||||
</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>
|
||||
<hr /><hr />
|
||||
<a NAME="NetFH" ID="NetFH"></a>
|
||||
@@ -470,6 +504,9 @@ Methods</h3>
|
||||
<td><a style="color:#0000FF" href="#RevPiNetIO.disconnect">disconnect</a></td>
|
||||
<td>Trennt Verbindungen und beendet autorefresh inkl.</td>
|
||||
</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>Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.</td>
|
||||
</tr><tr>
|
||||
@@ -544,7 +581,18 @@ RevPiNetIO.disconnect</h3>
|
||||
<b>disconnect</b>(<i></i>)
|
||||
<p>
|
||||
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">
|
||||
RevPiNetIO.get_jconfigrsc</h3>
|
||||
<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._get_cpreplaceio?5()
|
||||
revpimodio2.netio.RevPiNetIO.disconnect?4()
|
||||
revpimodio2.netio.RevPiNetIO.exit?4(full=True)
|
||||
revpimodio2.netio.RevPiNetIO.get_jconfigrsc?4()
|
||||
revpimodio2.netio.RevPiNetIO.get_reconnecting?4()
|
||||
revpimodio2.netio.RevPiNetIO.net_cleardefaultvalues?4(device=None)
|
||||
@@ -224,6 +225,8 @@ revpimodio2.netio._sysdeldirty?8
|
||||
revpimodio2.netio._sysexit?8
|
||||
revpimodio2.netio._sysflush?8
|
||||
revpimodio2.netio._syspictory?8
|
||||
revpimodio2.netio._syspictoryh?8
|
||||
revpimodio2.netio._sysreplaceio?8
|
||||
revpimodio2.netio._sysreplaceioh?8
|
||||
revpimodio2.netio._syssync?8
|
||||
revpimodio2.summary.Summary?1(summary)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
AclException Exception
|
||||
Base Device
|
||||
ConfigChanged Exception
|
||||
Connect Core
|
||||
Core Base
|
||||
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'
|
||||
# piCtory Konfiguration laden
|
||||
_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
|
||||
_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
|
||||
_sysflush = b'\x01SD\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x00\x00\x00\x17'
|
||||
|
||||
@@ -35,6 +37,13 @@ class AclException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ConfigChanged(Exception):
|
||||
|
||||
"""Aenderung der piCtory oder replace_ios Datei."""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class NetFH(Thread):
|
||||
|
||||
"""Netzwerk File Handler fuer das Prozessabbild.
|
||||
@@ -59,9 +68,12 @@ class NetFH(Thread):
|
||||
self.daemon = True
|
||||
|
||||
self.__by_buff = b''
|
||||
self.__config_changed = False
|
||||
self.__int_buff = 0
|
||||
self.__dictdirty = {}
|
||||
self.__flusherr = False
|
||||
self.__replace_ios_h = b''
|
||||
self.__pictory_h = b''
|
||||
self.__sockact = False
|
||||
self.__sockerr = Event()
|
||||
self.__sockend = Event()
|
||||
@@ -134,6 +146,37 @@ class NetFH(Thread):
|
||||
so = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
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:
|
||||
so.close()
|
||||
else:
|
||||
@@ -174,6 +217,10 @@ class NetFH(Thread):
|
||||
def clear_dirtybytes(self, position=None):
|
||||
"""Entfernt die konfigurierten Dirtybytes vom RevPi Slave.
|
||||
@param position Startposition der Dirtybytes"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged(
|
||||
"configuration on revolution pi was changed"
|
||||
)
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("I/O operation on closed file")
|
||||
|
||||
@@ -243,6 +290,10 @@ class NetFH(Thread):
|
||||
|
||||
def flush(self):
|
||||
"""Schreibpuffer senden."""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged(
|
||||
"configuration on revolution pi was changed"
|
||||
)
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("flush of closed file")
|
||||
|
||||
@@ -295,6 +346,8 @@ class NetFH(Thread):
|
||||
"""IOCTL Befehle ueber das Netzwerk senden.
|
||||
@param request Request as <class 'int'>
|
||||
@param arg Argument as <class 'byte'>"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged("configuration on revolution pi was changed")
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("read of closed file")
|
||||
|
||||
@@ -326,6 +379,8 @@ class NetFH(Thread):
|
||||
"""Daten ueber das Netzwerk lesen.
|
||||
@param length Anzahl der Bytes
|
||||
@return Gelesene <class 'bytes'>"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged("configuration on revolution pi was changed")
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("read of closed file")
|
||||
|
||||
@@ -443,6 +498,8 @@ class NetFH(Thread):
|
||||
def seek(self, position):
|
||||
"""Springt an angegebene Position.
|
||||
@param position An diese Position springen"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged("configuration on revolution pi was changed")
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("seek of closed file")
|
||||
self.__position = int(position)
|
||||
@@ -451,6 +508,8 @@ class NetFH(Thread):
|
||||
"""Konfiguriert Dirtybytes fuer Prozessabbild bei Verbindungsfehler.
|
||||
@param positon Startposition zum Schreiben
|
||||
@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():
|
||||
raise ValueError("I/O operation on closed file")
|
||||
|
||||
@@ -519,6 +578,8 @@ class NetFH(Thread):
|
||||
def tell(self):
|
||||
"""Gibt aktuelle Position zurueck.
|
||||
@return int aktuelle Position"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged("configuration on revolution pi was changed")
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("I/O operation on closed file")
|
||||
return self.__position
|
||||
@@ -527,6 +588,8 @@ class NetFH(Thread):
|
||||
"""Daten ueber das Netzwerk schreiben.
|
||||
@param bytebuff Bytes zum schreiben
|
||||
@return <class 'int'> Anzahl geschriebener bytes"""
|
||||
if self.__config_changed:
|
||||
raise ConfigChanged("configuration on revolution pi was changed")
|
||||
if self.__sockend.is_set():
|
||||
raise ValueError("write to closed file")
|
||||
|
||||
@@ -674,6 +737,14 @@ class RevPiNetIO(_RevPiModIO):
|
||||
"""Trennt Verbindungen und beendet autorefresh inkl. alle Threads."""
|
||||
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):
|
||||
"""Laedt die piCotry Konfiguration und erstellt ein <class 'dict'>.
|
||||
@return <class 'dict'> der piCtory Konfiguration"""
|
||||
|
||||
Reference in New Issue
Block a user