protobin 0.0.40__tar.gz → 0.0.41__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.40 → protobin-0.0.41}/PKG-INFO +1 -1
- {protobin-0.0.40 → protobin-0.0.41}/protobin/fields.py +1 -1
- {protobin-0.0.40 → protobin-0.0.41}/pyproject.toml +1 -1
- {protobin-0.0.40 → protobin-0.0.41}/tests/tests.py +34 -0
- {protobin-0.0.40 → protobin-0.0.41}/.gitignore +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/LICENSE.txt +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/README.md +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/protobin/__init__.py +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/protobin/errors.py +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/protobin/interfaces.py +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/protobin/protocol.py +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/protobin/singleton.py +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/tests/codec8.json +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/tests/demo.json +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/tests/demo.yaml +0 -0
- {protobin-0.0.40 → protobin-0.0.41}/tests/teltonika.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: protobin
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.41
|
|
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
|
|
@@ -299,7 +299,7 @@ class FlagsField(FieldBase):
|
|
|
299
299
|
def __init__(self, k, js):
|
|
300
300
|
super().__init__(k, js)
|
|
301
301
|
self.keys = self.key.split(',')
|
|
302
|
-
self.length = len(self.
|
|
302
|
+
self.length = len(self.keys)
|
|
303
303
|
self.bytes = math.ceil(self.length / 8)
|
|
304
304
|
|
|
305
305
|
def __repr__(self):
|
|
@@ -777,3 +777,37 @@ report:
|
|
|
777
777
|
binary = client.encode(data, 'message')
|
|
778
778
|
print(binary)
|
|
779
779
|
self.assertEqual(binary, b'M=\x11prueba de mensaje48')
|
|
780
|
+
|
|
781
|
+
def test_history_geofence_ms(self):
|
|
782
|
+
codec = {
|
|
783
|
+
"formats":{
|
|
784
|
+
"history_geofence_ms": {
|
|
785
|
+
"header": "$",
|
|
786
|
+
"fields": {
|
|
787
|
+
"items": {
|
|
788
|
+
"type": "array",
|
|
789
|
+
"array": {
|
|
790
|
+
"id": {"bytes": 2, "type": "unsigned"},
|
|
791
|
+
"orden" : {"bytes": 1, "type": "unsigned"},
|
|
792
|
+
"longitud": {"bytes": 4, "type": "float", "decimals": 6},
|
|
793
|
+
"latitud": {"bytes": 4, "type": "float", "decimals": 6},
|
|
794
|
+
"radio": {"bytes": 2, "type": "unsigned"},
|
|
795
|
+
"ruta": {"bytes": 1, "type": "unsigned"},
|
|
796
|
+
"lado,control,datear,activo": {"type": "flags"},
|
|
797
|
+
"nombre": {"bytes": 15, "type": "char"},
|
|
798
|
+
"timestamp":{"bytes": 6, "decimals": 3, "type": "timestamp"},
|
|
799
|
+
"type": {"bytes": 1, "type": "char"}
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
"next": {"bytes": 1, "type": "char"}
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
data = {'items': [{'id': 2, 'lado': False, 'ruta': 2, 'audio': 'HU', 'orden': 8, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'FINAL', 'control': True, 'latitud': -12.0627343, 'retorno': True, 'sagrado': False, 'longitud': -77.0153672, 'terminal': True, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 486000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 5, 'lado': False, 'ruta': 2, 'audio': 'UN', 'orden': 2, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'UNIVERITARIA', 'control': True, 'latitud': -12.0500755, 'retorno': False, 'sagrado': False, 'longitud': -77.0772618, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 518000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 6, 'lado': False, 'ruta': 2, 'audio': 'CA', 'orden': 3, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'CARCAMO', 'control': True, 'latitud': -12.0472635, 'retorno': False, 'sagrado': False, 'longitud': -77.0508689, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 528000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 7, 'lado': False, 'ruta': 2, 'audio': '2 ', 'orden': 4, 'radio': 70, 'activo': True, 'datear': True, 'nombre': '2 DE MAYO', 'control': True, 'latitud': -12.0465238, 'retorno': False, 'sagrado': False, 'longitud': -77.043466, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 536000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 8, 'lado': False, 'ruta': 2, 'audio': 'PL', 'orden': 5, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'PLAZA SAN MARTIN', 'control': True, 'latitud': -12.0511405, 'retorno': False, 'sagrado': False, 'longitud': -77.0355159, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 544000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 13, 'lado': True, 'ruta': 2, 'audio': 'AB', 'orden': 4, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'ABANCAY', 'control': True, 'latitud': -12.0547289, 'retorno': False, 'sagrado': False, 'longitud': -77.0298779, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 585000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 14, 'lado': True, 'ruta': 2, 'audio': 'PL', 'orden': 5, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'PLAZA SAN MARTIN', 'control': True, 'latitud': -12.0520219, 'retorno': False, 'sagrado': False, 'longitud': -77.0339656, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 593000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 15, 'lado': True, 'ruta': 2, 'audio': '2 ', 'orden': 6, 'radio': 70, 'activo': True, 'datear': True, 'nombre': '2 DE MAYO', 'control': True, 'latitud': -12.0467074, 'retorno': False, 'sagrado': False, 'longitud': -77.0421463, 'terminal': False, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 601000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}, {'id': 17, 'lado': True, 'ruta': 2, 'audio': 'TE', 'orden': 9, 'radio': 70, 'activo': True, 'datear': True, 'nombre': 'TERMINAL', 'control': True, 'latitud': -12.0492046, 'retorno': False, 'sagrado': False, 'longitud': -77.088908, 'terminal': True, 'timestamp': datetime.datetime(2020, 7, 27, 14, 12, 14, 618000), 'refrecuenciar': False, 'type': '+', 'tabla': 'G'}], 'next': 'P'}
|
|
808
|
+
client = Protocol(js=codec, server=None)
|
|
809
|
+
binary = client.encode(data, 'history_geofence_ms')
|
|
810
|
+
rasp = b'$=\t\x00\x02\x08\xfbh\xd6\xb9\xffG\xef\xf2\x00F\x02\x07FINAL \x01s\x91\xb0\x90\x96+\x00\x05\x02\xfbg\xe4\xf2\xffH!d\x00F\x02\x07UNIVERITARIA \x01s\x91\xb0\x90\xb6+\x00\x06\x03\xfbhL\x0b\xffH,`\x00F\x02\x07CARCAMO \x01s\x91\xb0\x90\xc0+\x00\x07\x04\xfbhh\xf6\xffH/D\x00F\x02\x072 DE MAYO \x01s\x91\xb0\x90\xc8+\x00\x08\x05\xfbh\x88\x04\xffH\x1d<\x00F\x02\x07PLAZA SAN MARTI\x01s\x91\xb0\x90\xd0+\x00\r\x04\xfbh\x9e\n\xffH\x0f7\x00F\x02\x0fABANCAY \x01s\x91\xb0\x90\xf9+\x00\x0e\x05\xfbh\x8e\x12\xffH\x19\xca\x00F\x02\x0fPLAZA SAN MARTI\x01s\x91\xb0\x91\x01+\x00\x0f\x06\xfbhn\x1e\xffH.\x8d\x00F\x02\x0f2 DE MAYO \x01s\x91\xb0\x91\t+\x00\x11\t\xfbg\xb7t\xffH$\xcb\x00F\x02\x0fTERMINAL \x01s\x91\xb0\x91\x1a+P'
|
|
811
|
+
self.assertEqual(binary, rasp)
|
|
812
|
+
h, recv = client.decode(binary)
|
|
813
|
+
print(recv)
|
|
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
|
|
File without changes
|
|
File without changes
|