burst-link-protocol 0.1.0__cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Sign up to get free protection for your applications and to get access to all the features.
Binary file
burst_interface_c.pyi ADDED
@@ -0,0 +1,8 @@
1
+
2
+
3
+ class BurstInterfaceC:
4
+ def __init__(self) -> None: ...
5
+
6
+ def decode(self, data: bytes, fail_on_crc_error: bool = False) -> list: ...
7
+
8
+ def encode(self, packets: list) -> bytes: ...
@@ -0,0 +1,4 @@
1
+ from burst_interface_c import BurstInterfaceC
2
+ from .main import BurstInterfacePy
3
+
4
+ __all__ = ["BurstInterfaceC", "BurstInterfacePy"]
@@ -0,0 +1,41 @@
1
+ from cobs import cobs
2
+ from crc import Calculator,Crc16
3
+
4
+ crc = Calculator(Crc16.IBM_3740)
5
+
6
+ class BurstInterfacePy:
7
+ buffer = b""
8
+
9
+ def __init__(self):
10
+ pass
11
+
12
+ @staticmethod
13
+ def crc16( data: bytes) -> bytes:
14
+ return crc.checksum(data).to_bytes(2, "big")
15
+
16
+
17
+ @staticmethod
18
+ def encode_packet(packet: bytes) -> bytes:
19
+ packet_with_crc = packet + BurstInterfacePy.crc16(packet)
20
+ return cobs.encode(packet_with_crc) + b"\x00"
21
+
22
+ @staticmethod
23
+ def decode_packet(packet: bytes) -> bytes:
24
+ # decode and check crc
25
+ decoded = cobs.decode(packet)
26
+
27
+ if BurstInterfacePy.crc16(decoded[:-2]) != decoded[-2:]:
28
+ raise ValueError("CRC mismatch")
29
+
30
+ return decoded[:-2]
31
+
32
+ def encode(self, packets: list[bytes]) -> bytes:
33
+ return b"".join([self.encode_packet(packet) for packet in packets])
34
+
35
+ def decode(self, steam: bytes) -> list[bytes]:
36
+ self.buffer += steam
37
+ separated_packets = self.buffer.split(b"\x00")
38
+ # Add last packet to buffer
39
+ self.buffer = separated_packets.pop()
40
+ return [self.decode_packet(packet) for packet in separated_packets]
41
+
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.1
2
+ Name: burst-link-protocol
3
+ Version: 0.1.0
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
+ Author-Email: Floris vernieuwe <floris@vernieuwe.eu>
6
+ Requires-Python: <4.0,>=3.10
7
+ Requires-Dist: cobs<2.0.0,>=1.2.1
8
+ Requires-Dist: numpy<3.0.0,>=2.2.3
9
+ Requires-Dist: crc<8.0.0,>=7.1.0
10
+ Requires-Dist: pytest<9.0.0,>=8.3.4
11
+ Requires-Dist: pytest-cov<7.0.0,>=6.0.0
12
+ Requires-Dist: pytest-benchmark<6.0.0,>=5.1.0
13
+ Requires-Dist: scikit-build-core[pyproject]<0.11.0,>=0.10.7; extra == "dev"
14
+ Requires-Dist: nanobind<3.0.0,>=2.5.0; extra == "dev"
15
+ Requires-Dist: pytest<9.0.0,>=8.3.4; extra == "dev"
16
+ Requires-Dist: pytest-cov<7.0.0,>=6.0.0; extra == "dev"
17
+ Requires-Dist: pytest-benchmark<6.0.0,>=5.1.0; extra == "dev"
18
+ Provides-Extra: dev
@@ -0,0 +1,7 @@
1
+ burst_interface_c.abi3.so,sha256=N0Ahig71NAznM0rbpVuQDE7E1tcl2Lq13BoQVnRs2v4,2406632
2
+ burst_interface_c.pyi,sha256=x_agiw2iVgDi2qJOOwEpWXVsV14K6GtJgcMqOBqjASQ,193
3
+ burst_link_protocol/__init__.py,sha256=cyEhIzfFlNOtubh_JjZg6bGSGn_sPq8daTi4cYBKnxc,132
4
+ burst_link_protocol/main.py,sha256=Pu67bwI7Szk1Y_AdrFVRTBCvl0o45uhFJTd8b0KQl_E,1170
5
+ burst_link_protocol-0.1.0.dist-info/WHEEL,sha256=rgBe5lsrYLaaGsUAPsVBOLIXZSIXCdi-k4o-PLZto6A,154
6
+ burst_link_protocol-0.1.0.dist-info/METADATA,sha256=Be0-bsj_OGKhNPqgdNz6CC9NIJt9hOJMpv7tAQtngw0,838
7
+ burst_link_protocol-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: scikit-build-core 0.10.7
3
+ Root-Is-Purelib: false
4
+ Tag: cp312-abi3-manylinux_2_17_x86_64
5
+ Tag: cp312-abi3-manylinux2014_x86_64
6
+