burst-link-protocol 1.1.4__cp312-abi3-win32.whl → 1.1.5__cp312-abi3-win32.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.
burst_interface_c.pyd CHANGED
Binary file
@@ -1,5 +1,5 @@
1
1
  from burst_interface_c import BurstInterfaceC
2
2
  from .main import BurstInterfacePy
3
- from .serial_burst_interface import SerialBurstInterface
3
+ from .serial_burst_interface import SerialBurstInterface, BurstSerialStatistics
4
4
 
5
- __all__ = ["BurstInterfaceC", "BurstInterfacePy", "SerialBurstInterface"]
5
+ __all__ = ["BurstInterfaceC", "BurstInterfacePy", "SerialBurstInterface", "BurstSerialStatistics"]
@@ -1,7 +1,8 @@
1
1
  from cobs import cobs
2
- from crc import Calculator,Crc16
2
+ from crc import Calculator, Crc16
3
+
4
+ crc = Calculator(Crc16.IBM_3740) # type: ignore
3
5
 
4
- crc = Calculator(Crc16.IBM_3740)
5
6
 
6
7
  class BurstInterfacePy:
7
8
  buffer = b""
@@ -10,9 +11,8 @@ class BurstInterfacePy:
10
11
  pass
11
12
 
12
13
  @staticmethod
13
- def crc16( data: bytes) -> bytes:
14
+ def crc16(data: bytes) -> bytes:
14
15
  return crc.checksum(data).to_bytes(2, "big")
15
-
16
16
 
17
17
  @staticmethod
18
18
  def encode_packet(packet: bytes) -> bytes:
@@ -38,4 +38,3 @@ class BurstInterfacePy:
38
38
  # Add last packet to buffer
39
39
  self.buffer = separated_packets.pop()
40
40
  return [self.decode_packet(packet) for packet in separated_packets]
41
-
@@ -1,4 +1,4 @@
1
- from burst_interface_c import BurstInterfaceC
1
+ from burst_interface_c import BurstInterfaceC
2
2
  import serial
3
3
  import time
4
4
  import threading
@@ -6,6 +6,7 @@ import asyncio
6
6
  import janus
7
7
  from pydantic import BaseModel, Field
8
8
 
9
+
9
10
  def to_si(value: float, suffix: str) -> str:
10
11
  """
11
12
  Convert a value to a string with SI suffix.
@@ -34,9 +35,9 @@ class BurstSerialStatistics(BaseModel):
34
35
  overflow_errors: int = 0
35
36
  decode_errors: int = 0
36
37
 
37
- handled_bytes_per_second: float = 0
38
- processed_bytes_per_second: float = 0
39
- processed_packets_per_second: float = 0
38
+ handled_bytes_per_second: float = 0.0
39
+ processed_bytes_per_second: float = 0.0
40
+ processed_packets_per_second: float = 0.0
40
41
 
41
42
  def update(
42
43
  self,
@@ -47,21 +48,14 @@ class BurstSerialStatistics(BaseModel):
47
48
  overflow_errors,
48
49
  decode_errors,
49
50
  ):
50
-
51
51
  now = time.time()
52
52
  if now - self.last_update_timestamp > 1:
53
53
  delta_time = now - self.last_update_timestamp
54
54
  self.last_update_timestamp = now
55
55
 
56
- self.handled_bytes_per_second = (
57
- (bytes_handled - self.bytes_handled) / delta_time
58
- )
59
- self.processed_bytes_per_second = (
60
- (bytes_processed - self.bytes_processed) / delta_time
61
- )
62
- self.processed_packets_per_second = (
63
- (packets_processed - self.packets_processed) / delta_time
64
- )
56
+ self.handled_bytes_per_second = (bytes_handled - self.bytes_handled) / delta_time
57
+ self.processed_bytes_per_second = (bytes_processed - self.bytes_processed) / delta_time
58
+ self.processed_packets_per_second = (packets_processed - self.packets_processed) / delta_time
65
59
 
66
60
  self.bytes_handled = bytes_handled
67
61
  self.bytes_processed = bytes_processed
@@ -74,12 +68,16 @@ class BurstSerialStatistics(BaseModel):
74
68
 
75
69
  def __str__(self):
76
70
  return (
77
- f"Byte Raw: {to_si(self.bytes_handled, 'B')} ({to_si(self.handled_bytes_per_second*8, 'bps')}), "
78
- f"Bytes processed: {to_si(self.bytes_processed, 'B')} ({to_si(self.processed_bytes_per_second*8, 'bps')}), "
71
+ f"Byte Raw: {to_si(self.bytes_handled, 'B')} ({to_si(self.handled_bytes_per_second * 8, 'bps')}), "
72
+ f"Bytes processed: {to_si(self.bytes_processed, 'B')} ({to_si(self.processed_bytes_per_second * 8, 'bps')}), "
79
73
  f"Packets processed: {self.packets_processed} ({to_si(self.processed_packets_per_second, 'packets/s')}), "
80
74
  f"Errors (CRC: {self.crc_errors}, Overflow: {self.overflow_errors}, Decode: {self.decode_errors})"
81
75
  )
82
76
 
77
+ def to_dict(self):
78
+ return self.model_dump(exclude={"last_update_timestamp"})
79
+
80
+
83
81
  class SerialBurstInterface:
84
82
  debug_timings = False
85
83
  debug_io = False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: burst-link-protocol
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: Binary Utility for Reliable Stream Transfer (BURST) is a library for encoding and decoding binary data streams into and from a byte stream.
5
5
  Author-Email: Floris vernieuwe <floris@vernieuwe.eu>
6
6
  License-File: LICENSE
@@ -0,0 +1,9 @@
1
+ burst_interface_c.pyd,sha256=WZofKQi-sAoctwQNpFyde5O04KSDJoT2nr2TSXljM_E,334848
2
+ burst_interface_c.pyi,sha256=qoGRk5fn2FwTtK-Uwh0KJjyqKVfe7Sg2m6nwMKARSO0,554
3
+ burst_link_protocol/__init__.py,sha256=HGHjJJlQQyngb2o_MomABI50TsrWFotISUnPwVsWkhw,266
4
+ burst_link_protocol/main.py,sha256=bCRA9otWoT__amrSDT06qbO45hLou5Zne7lYl7_GrpA,1221
5
+ burst_link_protocol/serial_burst_interface.py,sha256=xg6oE_ywaRScdsRyRBYklRLjFAJqM9FFHI1DmWBlYWY,7860
6
+ burst_link_protocol-1.1.5.dist-info/METADATA,sha256=RBftwGhSNW8G89OfxFcnFGQ_EJY8r0z3Rp8VMuwH20Y,2599
7
+ burst_link_protocol-1.1.5.dist-info/WHEEL,sha256=kRhi8c01fH1DIJ2nDWZ71s61vdPGe0_TjVg1M_p5teY,101
8
+ burst_link_protocol-1.1.5.dist-info/licenses/LICENSE,sha256=ES97GlwZLdiS8tIJLfRhCRha2fXrcp6sl3D0jDUoh98,17097
9
+ burst_link_protocol-1.1.5.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- burst_interface_c.pyd,sha256=GUZaVxPGnHjW3M4ZBJsz7JRj92UzhFD4rrlFx9Sq68k,334848
2
- burst_interface_c.pyi,sha256=qoGRk5fn2FwTtK-Uwh0KJjyqKVfe7Sg2m6nwMKARSO0,554
3
- burst_link_protocol/__init__.py,sha256=CeP2vD6WrzeXvMla7nzp3zbOAJqbi4sOYpM1gviF-Xk,218
4
- burst_link_protocol/main.py,sha256=Eicgf3yp8DxnI5SspCKD7jm5C4tNZWKKBoYdCfGrUis,1211
5
- burst_link_protocol/serial_burst_interface.py,sha256=DurK-J8OlRuzkGrP7DNJLbemVa4zJYqHhqCrT0NflOs,7858
6
- burst_link_protocol-1.1.4.dist-info/METADATA,sha256=grJVqJRLZaG6QEXc1jF-8EDBVkFWXTOp1-kMYawrZ2I,2599
7
- burst_link_protocol-1.1.4.dist-info/WHEEL,sha256=kRhi8c01fH1DIJ2nDWZ71s61vdPGe0_TjVg1M_p5teY,101
8
- burst_link_protocol-1.1.4.dist-info/licenses/LICENSE,sha256=ES97GlwZLdiS8tIJLfRhCRha2fXrcp6sl3D0jDUoh98,17097
9
- burst_link_protocol-1.1.4.dist-info/RECORD,,