goodwe 0.4.4__py3-none-any.whl → 0.4.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- goodwe/protocol.py +17 -6
- {goodwe-0.4.4.dist-info → goodwe-0.4.5.dist-info}/METADATA +1 -1
- {goodwe-0.4.4.dist-info → goodwe-0.4.5.dist-info}/RECORD +6 -6
- {goodwe-0.4.4.dist-info → goodwe-0.4.5.dist-info}/LICENSE +0 -0
- {goodwe-0.4.4.dist-info → goodwe-0.4.5.dist-info}/WHEEL +0 -0
- {goodwe-0.4.4.dist-info → goodwe-0.4.5.dist-info}/top_level.txt +0 -0
goodwe/protocol.py
CHANGED
|
@@ -141,11 +141,13 @@ class UdpInverterProtocol(InverterProtocol, asyncio.DatagramProtocol):
|
|
|
141
141
|
logger.debug("Received response fragment (%d of %d): %s", ex.length, ex.expected, data.hex())
|
|
142
142
|
self._partial_data = data
|
|
143
143
|
self._partial_missing = ex.expected - ex.length
|
|
144
|
+
self._timer = asyncio.get_running_loop().call_later(self.timeout, self._retry_mechanism)
|
|
144
145
|
except asyncio.InvalidStateError:
|
|
145
146
|
logger.debug("Response already handled: %s", data.hex())
|
|
146
147
|
except RequestRejectedException as ex:
|
|
147
148
|
logger.debug("Received exception response: %s", data.hex())
|
|
148
|
-
self.response_future.
|
|
149
|
+
if self.response_future and not self.response_future.done():
|
|
150
|
+
self.response_future.set_exception(ex)
|
|
149
151
|
self._close_transport()
|
|
150
152
|
|
|
151
153
|
def error_received(self, exc: Exception) -> None:
|
|
@@ -284,11 +286,13 @@ class TcpInverterProtocol(InverterProtocol, asyncio.Protocol):
|
|
|
284
286
|
logger.debug("Received response fragment (%d of %d): %s", ex.length, ex.expected, data.hex())
|
|
285
287
|
self._partial_data = data
|
|
286
288
|
self._partial_missing = ex.expected - ex.length
|
|
289
|
+
self._timer = asyncio.get_running_loop().call_later(self.timeout, self._timeout_mechanism)
|
|
287
290
|
except asyncio.InvalidStateError:
|
|
288
291
|
logger.debug("Response already handled: %s", data.hex())
|
|
289
292
|
except RequestRejectedException as ex:
|
|
290
293
|
logger.debug("Received exception response: %s", data.hex())
|
|
291
|
-
self.response_future.
|
|
294
|
+
if self.response_future and not self.response_future.done():
|
|
295
|
+
self.response_future.set_exception(ex)
|
|
292
296
|
# self._close_transport()
|
|
293
297
|
|
|
294
298
|
def error_received(self, exc: Exception) -> None:
|
|
@@ -469,7 +473,7 @@ class Aa55ProtocolCommand(ProtocolCommand):
|
|
|
469
473
|
Quite probably it is some variation of the protocol used on RS-485 serial link,
|
|
470
474
|
extended/adapted to UDP transport layer.
|
|
471
475
|
|
|
472
|
-
Each request starts with header of 0xAA, 0x55, then 0xC0, 0x7F (
|
|
476
|
+
Each request starts with header of 0xAA, 0x55, then 0xC0, 0x7F (client addr, inverter addr)
|
|
473
477
|
followed by actual payload data.
|
|
474
478
|
It is suffixed with 2 bytes of plain checksum of header+payload.
|
|
475
479
|
|
|
@@ -485,7 +489,7 @@ class Aa55ProtocolCommand(ProtocolCommand):
|
|
|
485
489
|
+ payload
|
|
486
490
|
+ self._checksum(bytes.fromhex("AA55C07F" + payload)).hex()
|
|
487
491
|
),
|
|
488
|
-
lambda x: self.
|
|
492
|
+
lambda x: self._validate_aa55_response(x, response_type),
|
|
489
493
|
)
|
|
490
494
|
|
|
491
495
|
@staticmethod
|
|
@@ -496,7 +500,7 @@ class Aa55ProtocolCommand(ProtocolCommand):
|
|
|
496
500
|
return checksum.to_bytes(2, byteorder="big", signed=False)
|
|
497
501
|
|
|
498
502
|
@staticmethod
|
|
499
|
-
def
|
|
503
|
+
def _validate_aa55_response(data: bytes, response_type: str) -> bool:
|
|
500
504
|
"""
|
|
501
505
|
Validate the response.
|
|
502
506
|
data[0:3] is header
|
|
@@ -504,13 +508,20 @@ class Aa55ProtocolCommand(ProtocolCommand):
|
|
|
504
508
|
data[6] is response payload length
|
|
505
509
|
data[-2:] is checksum (plain sum of response data incl. header)
|
|
506
510
|
"""
|
|
507
|
-
if len(data) <= 8
|
|
511
|
+
if len(data) <= 8:
|
|
512
|
+
logger.debug("Response too short.")
|
|
513
|
+
return False
|
|
514
|
+
elif len(data) < data[6] + 9:
|
|
508
515
|
raise PartialResponseException(len(data), data[6] + 9)
|
|
516
|
+
elif len(data) > data[6] + 9:
|
|
517
|
+
logger.debug("Response invalid - too long (%d).", len(data))
|
|
518
|
+
return False
|
|
509
519
|
elif response_type:
|
|
510
520
|
data_rt_int = int.from_bytes(data[4:6], byteorder="big", signed=True)
|
|
511
521
|
if int(response_type, 16) != data_rt_int:
|
|
512
522
|
logger.debug("Response type unexpected: %04x, expected %s.", data_rt_int, response_type)
|
|
513
523
|
return False
|
|
524
|
+
|
|
514
525
|
checksum = 0
|
|
515
526
|
for each in data[:-2]:
|
|
516
527
|
checksum += each
|
|
@@ -7,10 +7,10 @@ goodwe/exceptions.py,sha256=dKMLxotjoR1ic8OVlw1joIJ4mKWD6oFtUMZ86fNM5ZE,1403
|
|
|
7
7
|
goodwe/inverter.py,sha256=86aMJzJjNOr1I_tCF5H6mBwzDTjLbGDKUL2hbi0XSxg,10459
|
|
8
8
|
goodwe/modbus.py,sha256=Mg_s_v8kbZgqXZM6ZUUxkZx2boAG8LkuDG5OiFKK2X4,8402
|
|
9
9
|
goodwe/model.py,sha256=dWBjMFJMnhZoUdDd9fGT54DERDANz4TirK0Wy8kWMbk,2068
|
|
10
|
-
goodwe/protocol.py,sha256=
|
|
10
|
+
goodwe/protocol.py,sha256=Ry1B-kki5F-AnsmpeUWuhP3eCCH1wrKKfDuT9BKfmvE,29140
|
|
11
11
|
goodwe/sensor.py,sha256=buPG8BcgZmRDqaMrLQUACLHB85U134qG6qo_ggsu48A,37679
|
|
12
|
-
goodwe-0.4.
|
|
13
|
-
goodwe-0.4.
|
|
14
|
-
goodwe-0.4.
|
|
15
|
-
goodwe-0.4.
|
|
16
|
-
goodwe-0.4.
|
|
12
|
+
goodwe-0.4.5.dist-info/LICENSE,sha256=aZAhk3lRdYT1YZV-IKRHISEcc_KNUmgfuNO3QhRamNM,1073
|
|
13
|
+
goodwe-0.4.5.dist-info/METADATA,sha256=9MoleSeCTePnmqw6x_u5WcBE0GXwVvCtxF-9s4hqEHw,3376
|
|
14
|
+
goodwe-0.4.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
15
|
+
goodwe-0.4.5.dist-info/top_level.txt,sha256=kKoiqiVvAxDaDJYMZZQLgHQj9cuWT1MXLfXElTDuf8s,7
|
|
16
|
+
goodwe-0.4.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|