protobin 0.0.35__tar.gz → 0.0.37__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.
- {protobin-0.0.35 → protobin-0.0.37}/PKG-INFO +1 -1
- {protobin-0.0.35 → protobin-0.0.37}/protobin/protocol.py +8 -8
- {protobin-0.0.35 → protobin-0.0.37}/pyproject.toml +1 -1
- {protobin-0.0.35 → protobin-0.0.37}/tests/codec8.json +1 -0
- {protobin-0.0.35 → protobin-0.0.37}/tests/teltonika.json +1 -1
- {protobin-0.0.35 → protobin-0.0.37}/tests/tests.py +12 -11
- {protobin-0.0.35 → protobin-0.0.37}/.gitignore +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/LICENSE.txt +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/README.md +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/protobin/__init__.py +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/protobin/errors.py +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/protobin/fields.py +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/protobin/interfaces.py +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/protobin/singleton.py +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/tests/demo.json +0 -0
- {protobin-0.0.35 → protobin-0.0.37}/tests/demo.yaml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.37
|
|
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,8 +114,8 @@ 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:
|
|
118
|
-
binary =
|
|
117
|
+
if self.fake_prefix and format.header:
|
|
118
|
+
binary = 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)
|
|
121
121
|
|
|
@@ -132,12 +132,12 @@ class Protocol:
|
|
|
132
132
|
else:
|
|
133
133
|
if n > 4:
|
|
134
134
|
# comandos de pantalla con = o que tengan un igual más adelante por casualidad
|
|
135
|
-
if self.fake_prefix and binary[:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
else:
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
# if self.fake_prefix and int.from_bytes(binary[:self.fake_prefix - 1]) and binary[self.fake_prefix - 1]:
|
|
136
|
+
# # comandos
|
|
137
|
+
# binary = binary[4:]
|
|
138
|
+
# else:
|
|
139
|
+
# # codec8
|
|
140
|
+
binary = self.check_crc(binary)
|
|
141
141
|
n = binary.find(b'=')
|
|
142
142
|
if n > 4 or n == -1:
|
|
143
143
|
# si el igual está adelante no es parte del comando
|
|
@@ -561,15 +561,6 @@ report:
|
|
|
561
561
|
}}
|
|
562
562
|
})
|
|
563
563
|
|
|
564
|
-
def test_teltonika_login_hex(self):
|
|
565
|
-
hexdata = '000F333536333037303432343431303133'
|
|
566
|
-
binary = bytes.fromhex(hexdata)
|
|
567
|
-
client = Protocol(file='codec8.json', server=None)
|
|
568
|
-
recv = client.decode(binary, 'login')
|
|
569
|
-
self.assertEqual(recv, {'serial': '356307042441013'})
|
|
570
|
-
binary2 = client.encode(recv, 'login')
|
|
571
|
-
self.assertEqual(binary, binary2)
|
|
572
|
-
|
|
573
564
|
def test_position_binary(self):
|
|
574
565
|
data = {'positions':
|
|
575
566
|
[{'time': datetime.datetime(2024, 10, 18, 15, 57, 38),
|
|
@@ -644,7 +635,7 @@ report:
|
|
|
644
635
|
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
636
|
client = Protocol(file='codec8.json')
|
|
646
637
|
binary = client.encode(data, 'status3')
|
|
647
|
-
self.assertEqual(b'
|
|
638
|
+
self.assertEqual(b'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
639
|
header, recv = client.decode(binary)
|
|
649
640
|
self.assertEqual(data, recv)
|
|
650
641
|
|
|
@@ -712,10 +703,20 @@ report:
|
|
|
712
703
|
print(recv)
|
|
713
704
|
|
|
714
705
|
def test_status_teltonika(self):
|
|
715
|
-
pesquero = b'
|
|
706
|
+
pesquero = b'S=RA\x07IQUITOS14:05\x06LOBATO\x04\x07IGLESIA\x00f\x08\x00n\x05\x00\x96\x03\x01m\x08\x00\xb5\r\x01w\t\x00\x00o\xb4'
|
|
716
707
|
client = Protocol(file='teltonika.json', server=None)
|
|
717
708
|
header, recv = client.decode(pesquero)
|
|
718
709
|
print(recv)
|
|
719
710
|
binary = client.encode(recv, header)
|
|
720
711
|
print(binary)
|
|
721
712
|
self.assertEqual(pesquero, binary)
|
|
713
|
+
|
|
714
|
+
def test_teltonika_login_hex(self):
|
|
715
|
+
hexdata = '000F333536333037303432343431303133'
|
|
716
|
+
binary = bytes.fromhex(hexdata)
|
|
717
|
+
client = Protocol(file='codec8.json', server=None)
|
|
718
|
+
recv = client.decode(binary, 'login')
|
|
719
|
+
self.assertEqual(recv, {'serial': '356307042441013'})
|
|
720
|
+
binary2 = client.encode(recv, 'login')
|
|
721
|
+
self.assertEqual(binary, binary2)
|
|
722
|
+
print(binary2)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|