Bug fix for NetIO with autorefresh=True

This commit is contained in:
2020-06-24 18:24:18 +02:00
parent a7802178e9
commit bf4b450bc6
3 changed files with 38 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ __author__ = "Sven Sager <akira@revpimodio.org>"
__copyright__ = "Copyright (C) 2018 Sven Sager"
__license__ = "LGPLv3"
__name__ = "revpimodio2"
__version__ = "2.5.0"
__version__ = "2.5.1"
# Global package values
OFF = 0

View File

@@ -463,6 +463,42 @@ class NetFH(Thread):
return bytes(self.__buff_recv)
def readinto(self, buffer: bytearray) -> int:
"""
Read data from network into a buffer.
:param buffer: Use Buffer to write bytes into
:return: Amount of read bytes
"""
if self.__config_changed:
raise ConfigChanged("configuration on revolution pi was changed")
if self.__sockend.is_set():
raise ValueError("read of closed file")
length = len(buffer)
with self.__socklock:
# b CM ii ii 00000000 b = 16
self._slavesock.sendall(pack(
"=c2sHH8xc",
HEADER_START, b'DA', self.__position, length, HEADER_STOP
))
self.__position += length
buffer.clear()
while length > 0:
count = self._slavesock.recv_into(
self.__buff_block,
min(length, self.__buff_size),
)
if count == 0:
self.__sockerr.set()
raise IOError("read error on network")
buffer += self.__buff_block[:count]
length -= count
return len(buffer)
def readpictory(self) -> bytes:
"""
Ruft die piCtory Konfiguration ab.

View File

@@ -17,7 +17,7 @@ setup(
license="LGPLv3",
name="revpimodio2",
version="2.5.0",
version="2.5.1",
packages=["revpimodio2"],
python_requires="~=3.2",