protobin 0.0.47__tar.gz → 0.0.48__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.47 → protobin-0.0.48}/PKG-INFO +1 -1
- {protobin-0.0.47 → protobin-0.0.48}/protobin/fields.py +4 -1
- {protobin-0.0.47 → protobin-0.0.48}/pyproject.toml +1 -1
- {protobin-0.0.47 → protobin-0.0.48}/tests/demo.json +33 -0
- {protobin-0.0.47 → protobin-0.0.48}/tests/tests.py +9 -0
- {protobin-0.0.47 → protobin-0.0.48}/.gitignore +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/LICENSE.txt +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/README.md +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/protobin/__init__.py +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/protobin/errors.py +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/protobin/interfaces.py +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/protobin/protocol.py +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/protobin/singleton.py +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/tests/codec8.json +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/tests/demo.yaml +0 -0
- {protobin-0.0.47 → protobin-0.0.48}/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.48
|
|
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
|
|
@@ -327,7 +327,10 @@ class DateTimeField(FieldBase):
|
|
|
327
327
|
S, binary = self.get_nible(binary)
|
|
328
328
|
if y == 0 and m == 0 and d == 0 and H == 0 and M == 0 and S == 0:
|
|
329
329
|
return None
|
|
330
|
-
|
|
330
|
+
try:
|
|
331
|
+
return datetime.datetime(2000 + y, m, d, H, M, S)
|
|
332
|
+
except:
|
|
333
|
+
return None
|
|
331
334
|
|
|
332
335
|
|
|
333
336
|
class FlagsField(FieldBase):
|
|
@@ -20,6 +20,39 @@
|
|
|
20
20
|
"schedule": {"type": "time"}
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
|
+
"report_alt": {
|
|
24
|
+
"header": "p",
|
|
25
|
+
"client": {
|
|
26
|
+
"positions": {
|
|
27
|
+
"type": "array", "array": {
|
|
28
|
+
"time": {"type": "datetime"},
|
|
29
|
+
"lng": {"bytes": 4, "type": "float", "decimals": 6},
|
|
30
|
+
"lat": {"bytes": 4, "type": "float", "decimals": 6},
|
|
31
|
+
"speed": {"bytes": 1, "type": "unsigned"},
|
|
32
|
+
"mark": {"bytes": 2, "type": "id"},
|
|
33
|
+
"busstop": {"bytes": 2, "type": "id"}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"trip": {"bytes": 4, "type": "id"},
|
|
37
|
+
"route": {"bytes": 1, "type": "id"},
|
|
38
|
+
"direction": {"type": "bool"},
|
|
39
|
+
"state": {"type": "char"},
|
|
40
|
+
"boletos": {
|
|
41
|
+
"type": "array", "array": {
|
|
42
|
+
"id": { "bytes": 2, "type": "unsigned"},
|
|
43
|
+
"cantidad": {"bytes": 2, "type": "unsigned"}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"sales": {"bytes": 3, "type": "unsigned"},
|
|
47
|
+
"events": {"type": "array", "array": {
|
|
48
|
+
"id": {"bytes": 2, "type": "unsigned"},
|
|
49
|
+
"value": {"bytes": 1, "type": "unsigned"}}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"server": {
|
|
53
|
+
"positions": {"bytes": 1, "type": "unsigned"}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
23
56
|
"report": {
|
|
24
57
|
"header": "PV",
|
|
25
58
|
"client": {
|
|
@@ -961,3 +961,12 @@ report:
|
|
|
961
961
|
binary = client.encode(data, 'flag_array')
|
|
962
962
|
h, recv = client.decode(binary)
|
|
963
963
|
self.assertEqual(data, recv)
|
|
964
|
+
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
def test_report_teltonika_alt(self):
|
|
968
|
+
server = Protocol(file='demo.json', server=True)
|
|
969
|
+
binary = b'p=\x03\x14\x07%\x10YP\xfbh.\x18\xffG\xaa\x8c\x18\x00\x16\xee\xfa\x14\x07%\x10YU\xfbh/\x06\xffG\xa9\xc6\x15\x00\x16\xee\xfay\x01\xe7$\xba\x10o}\x00\xf7\xc1m\x10\xc3R\n\xffh\xbb\x00\x04\x06\xf8\x01\x01R\x00\x00\x00\x00\x00'
|
|
970
|
+
h, recv = server.decode(binary)
|
|
971
|
+
self.assertEqual(h, 'report_alt')
|
|
972
|
+
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
|