DLMS-SPODES-client 0.19.19__py3-none-any.whl → 0.19.21__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.
@@ -260,12 +260,12 @@ class Client:
260
260
  case _: raise ValueError(F"can't calculate channel index by media: {self.media}")
261
261
 
262
262
  def get_frame(self, read_data: bytearray, reply: GXReplyData) -> frame.Frame | None:
263
+ reply.complete = False
263
264
  while len(read_data) != 0:
264
265
  new_frame = frame.Frame.try_from(read_data)
265
- reply.complete = True
266
- if new_frame is None:
267
- reply.complete = False
266
+ if not isinstance(new_frame, frame.Frame):
268
267
  return None
268
+ reply.complete = True
269
269
  if new_frame.is_for_me(self.DA, self.SA):
270
270
  self.received_frames.append(new_frame)
271
271
  if new_frame.is_segmentation:
@@ -319,7 +319,7 @@ class Client:
319
319
  len_ = _GXCommon.getObjectCount(reply.data)
320
320
  if len_ > reply.data.size - reply.data.position:
321
321
  reply.complete = False
322
- return
322
+ return result.Error.from_e(RuntimeError("not enouth reply data size"))
323
323
  GXDLMS.getDataFromBlock(reply.data, index)
324
324
  if (bc & 0x80) == 0:
325
325
  reply.moreData = (RequestTypes(reply.moreData | RequestTypes.GBT))
@@ -758,22 +758,19 @@ class Client:
758
758
  self.log(logL.INFO, F"TX: {send_frame.content.hex(" ")}")
759
759
  attempt: int = 1
760
760
  while attempt < 3:
761
- try:
762
- await asyncio.wait_for( # todo: don't work exception!!!! Why????
763
- fut=self.media.receive(recv_buf),
764
- timeout=self.com_profile.parameters.inactivity_time_out) # todo: only for HDLC
765
- if self.__is_frame(notify, recv_buf, reply):
766
- break
767
- elif notify.data.size != 0:
768
- if not notify.isMoreData():
769
- notify.clear()
770
- continue
771
- else:
772
- """our frame not was found"""
773
- except TimeoutError as e:
774
- self.log(logL.WARN, F'Data send failed: {e}. Try to resend {attempt+1}/3. RX_buffer: {recv_buf.hex(" ")}')
761
+ if not await self.media.receive(recv_buf): # todo: make for BLE
762
+ self.log(logL.WARN, F'Data receive failed: Try to resend {attempt + 1}/3. RX_buffer: {recv_buf.hex(" ")}')
775
763
  await self.media.send(send_frame.content)
776
764
  attempt += 1
765
+ continue
766
+ if self.__is_frame(notify, recv_buf, reply):
767
+ break
768
+ if notify.data.size != 0:
769
+ if not notify.isMoreData():
770
+ notify.clear()
771
+ continue
772
+ else:
773
+ """our frame not was found"""
777
774
  else:
778
775
  return result.Error.from_e(TimeoutError("Failed to receive reply from the device in given time"), "read data block")
779
776
  recv_buf.clear()
@@ -1356,6 +1356,35 @@ class Execute2(SimpleCopy, OK):
1356
1356
  return result.Error.from_e(e)
1357
1357
 
1358
1358
 
1359
+ @dataclass
1360
+ class GetTimeDelta(SimpleCopy, Simple[float]):
1361
+ """Read and return <time delta> in second: """
1362
+ msg: str = "Read Clock.time"
1363
+
1364
+ async def exchange(self, c: Client) -> result.SimpleOrError[float]:
1365
+ acc = result.ErrorAccumulator()
1366
+ obj = c._objects.clock
1367
+ if isinstance(
1368
+ res_read_tz := await ReadObjAttr(
1369
+ obj=obj,
1370
+ index=3
1371
+ ).exchange(c),
1372
+ result.Error):
1373
+ return res_read_tz
1374
+ tz = datetime.timezone(datetime.timedelta(minutes=int(res_read_tz.value)))
1375
+ if isinstance(
1376
+ res_read := await ReadObjAttr(
1377
+ obj=obj,
1378
+ index=2
1379
+ ).exchange(c),
1380
+ result.Error):
1381
+ return res_read
1382
+ value = datetime.datetime.now(tz=tz)
1383
+ value2 = res_read.value.to_datetime().replace(tzinfo=tz)
1384
+ return result.Simple((value2 - value).total_seconds()).append_err(acc.err)
1385
+
1386
+
1387
+
1359
1388
  @dataclass
1360
1389
  class WriteTime(SimpleCopy, Simple[float]):
1361
1390
  """Write and return <record time> in second: """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DLMS_SPODES_client
3
- Version: 0.19.19
3
+ Version: 0.19.21
4
4
  Summary: dlms-spodes
5
5
  Author-email: Serj Kotilevski <youserj@outlook.com>
6
6
  Project-URL: Source, https://github.com/youserj/SPODESclient_prj
@@ -1,12 +1,12 @@
1
1
  DLMS_SPODES_client/FCS16.py,sha256=RhoN4fX7eesKWfWCkRT_uWNfiQHqFd3T6lRwxfamUqw,2697
2
2
  DLMS_SPODES_client/__init__.py,sha256=6wphXvqkodng7h4nKNmkfldbaxf--IDVGfT0yNbas-o,449
3
- DLMS_SPODES_client/client.py,sha256=T_8nI6_tCWK6Us74gjIM_2I8EtETs4dQX4ygFmnV70A,112333
3
+ DLMS_SPODES_client/client.py,sha256=lsMLRLfgbISLOpaUPJme0-4631A0ZgQBOAVqjkQjvH4,112156
4
4
  DLMS_SPODES_client/logger.py,sha256=zAbihLloMU99w8Sw3djQ0cwItzyGq0Fz8DI9_suazv4,1913
5
5
  DLMS_SPODES_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  DLMS_SPODES_client/services.py,sha256=xM_-h322V1bGBcw9cJh7XOSUMTL3_E-GX89-z3YwIYw,3909
7
7
  DLMS_SPODES_client/session.py,sha256=nPzXujpmGSTFFvhyZRjgH_RLX1DS9moRddUEZuf-QEE,12760
8
8
  DLMS_SPODES_client/settings.py,sha256=6mitGe9UYeEgL61sf933MJ-S5N-ReoxvXqiI3agBGYE,1623
9
- DLMS_SPODES_client/task.py,sha256=42nfG3b30NCLUxw4PH0nsTv63N_Ulrxqb-ihKk42Dgo,76850
9
+ DLMS_SPODES_client/task.py,sha256=wJEYw4Ld8cBAi2eMzvNvNAc69DaCV33Vjssv7f8smlA,77844
10
10
  DLMS_SPODES_client/gurux_common/enums/TraceLevel.py,sha256=Ne0Rn3c9ACqQjmde_ksbiQxIUv6nXsPQRnhkGwIv3QI,521
11
11
  DLMS_SPODES_client/gurux_common/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  DLMS_SPODES_client/gurux_dlms/AesGcmParameter.py,sha256=HJt0uvxtkqKEkvfiqXTMNsiayN15AgPJa9_iMSSFZsQ,1429
@@ -54,8 +54,8 @@ DLMS_SPODES_client/gurux_dlms/enums/Task.py,sha256=chuOL6-IMxBvABUZtoFcaYaQQB4GZ
54
54
  DLMS_SPODES_client/gurux_dlms/enums/VdeStateError.py,sha256=qT87LMbIYEs3TYPIp3N-dR2Tcg9KhKyiELwhVl5U-tw,233
55
55
  DLMS_SPODES_client/gurux_dlms/enums/__init__.py,sha256=F_sgGwNmmdpbKvP1klJQUNiLXxU2BtZ-LgEI9e6xP8g,1314
56
56
  DLMS_SPODES_client/gurux_dlms/internal/_GXCommon.py,sha256=7D9EYcfiZxwbk8sfpHv7s2nYqrbmGf-Tbwv2T-gqmgk,53226
57
- dlms_spodes_client-0.19.19.dist-info/METADATA,sha256=SWD9H2Un2xHu6ysMHdkj6Fl580t6rOjLd7b5A-P8eRs,986
58
- dlms_spodes_client-0.19.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
59
- dlms_spodes_client-0.19.19.dist-info/entry_points.txt,sha256=Z6UTeQjjCf2k1Y3Bjs0s7yr-UYSWb-TvJMuG2K2MApw,70
60
- dlms_spodes_client-0.19.19.dist-info/top_level.txt,sha256=rh_3Uig5bc6J_lKni01btol7dX_IgIJulNtGjGehmBE,19
61
- dlms_spodes_client-0.19.19.dist-info/RECORD,,
57
+ dlms_spodes_client-0.19.21.dist-info/METADATA,sha256=diEibtEXXEZhLaSqJgunuNJ2uMuN5pjSTAtl3QSPVqU,986
58
+ dlms_spodes_client-0.19.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
59
+ dlms_spodes_client-0.19.21.dist-info/entry_points.txt,sha256=Z6UTeQjjCf2k1Y3Bjs0s7yr-UYSWb-TvJMuG2K2MApw,70
60
+ dlms_spodes_client-0.19.21.dist-info/top_level.txt,sha256=rh_3Uig5bc6J_lKni01btol7dX_IgIJulNtGjGehmBE,19
61
+ dlms_spodes_client-0.19.21.dist-info/RECORD,,