protobin 0.0.35__tar.gz → 0.0.36__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: protobin
3
- Version: 0.0.35
3
+ Version: 0.0.36
4
4
  Summary: Python library for encode and decode data in protobin format
5
5
  Project-URL: Homepage, https://github.com/drmelectronic/protobin-python
6
6
  Project-URL: Bug Tracker, https://github.com/drmelectronic/protobin-python/issues
@@ -114,7 +114,7 @@ class Protocol:
114
114
  raise InputError(f'{format_key} is not available format, these are the all availables formats {self.formats.keys()}')
115
115
  format = self.formats[format_key]
116
116
  binary = format.encode(data)
117
- if self.fake_prefix:
117
+ if self.fake_prefix and format.header:
118
118
  binary = bytes(self.fake_prefix) + binary + self.get_crc(binary)
119
119
  elif format.crc and self.crc16:
120
120
  binary = len(binary).to_bytes(self.length, 'big', signed=False) + binary + self.get_crc(binary)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "protobin"
7
- version = "0.0.35"
7
+ version = "0.0.36"
8
8
  authors = [
9
9
  { name="Daniel Robles", email="drm.electronic@gmail.com" },
10
10
  ]
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "length": 8,
3
+ "fake_prefix": [0, 0, 0, 1],
3
4
  "crc": {"poly": "0x18005", "init": "0x0000", "reverse": true, "byte_order": "big", "size": 4},
4
5
  "formats": {
5
6
  "login": {
@@ -569,6 +569,7 @@ report:
569
569
  self.assertEqual(recv, {'serial': '356307042441013'})
570
570
  binary2 = client.encode(recv, 'login')
571
571
  self.assertEqual(binary, binary2)
572
+ print(binary2)
572
573
 
573
574
  def test_position_binary(self):
574
575
  data = {'positions':
@@ -644,7 +645,7 @@ report:
644
645
  data = {'status': 'E', 'direction': 'A', 'next_next_control': '', 'next_next_time': ' ', 'next_control': '', 'next_time': ' ', 'previous_control': '', 'delay': 0, 'front_control': '', 'back_control': '', 'back_back_control': '', 'datero_bus_-1': 0, 'datero_dif_-1': 0, 'datero_bus_0': 0, 'datero_dif_0': 0, 'datero_bus_1': 0, 'datero_dif_1': 0, 'datero_bus_2': 0, 'datero_dif_2': 0, 'datero_bus_3': 256, 'datero_dif_3': 0, 'datero_bus_4': 0, 'datero_dif_4': 0, 'datero_bus_5': 0, 'datero_dif_5': 0}
645
646
  client = Protocol(file='codec8.json')
646
647
  binary = client.encode(data, 'status3')
647
- self.assertEqual(b'\x00\x00\x00\x00\x00\x00\x00*s=EA\x00 \x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb6\xd6', binary)
648
+ self.assertEqual(b'\x00\x00\x00\x01s=EA\x00 \x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb6\xd6', binary)
648
649
  header, recv = client.decode(binary)
649
650
  self.assertEqual(data, recv)
650
651
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes