-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
45 lines (37 loc) · 1.73 KB
/
test.py
File metadata and controls
45 lines (37 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import json
# stickerToIp = {}
# with open("../wisun-visualizer/leasedIP.json", "r") as leasedIP:
# st_python = json.load(leasedIP)
# visualizer_map = st_python["map"]
# for key in visualizer_map:
# ori = list(visualizer_map[key].split('-'))
# converted = []
# for i in range(0,8): converted.append(ori[2*i] + ori[2*i+1])
# stickerToIp[key] = ':'.join(converted[:4]) + "::" + ':'.join(converted[5:])
# print(stickerToIp)
import codecs
# s = b'\x02\x01\x00\x00\x01\x01\xff\x01\x01\x01\x01\x01\x01\x01\x01\x02\x02\x02\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x002A\xccf\xfe\xca\x00^0\x04\x00K\x12\x00\x08\xc5"\x04\x00K\x12\x00{3:\x87\x00\x08h\x00\x00\x00\x00\xfe\x80\x00\x00\x00\x00\x00\x00\x02\x12K\x00\x040^\x00\xd8'
s = b'EX\x02\x01\x00\x00\x01\x01\xff\x01\x01\x01\x01\x01\x01\x01\x01\x02\x02\x02\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00XA\xccf\xfe\xca\x00^0\x04\x00K\x12\x00\x08\xc5"\x04\x00K\x12\x00~3\xe1\x06c\x04\x00\x00\x00\x00\xee~\x00 \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d \x01\r\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\xf3\x11\xe81\x01check_reception\xf4o'
# s = b'\x01 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00d'
s = str(s)[2:-1]
hexList = []
i = 0
while i < len(s):
if s[i: i+2] == "\\x":
hexList.append( s[i+2: i+4] )
i += 4
elif s[i: i+2] == "\\r":
hexList.append( "0d" )
i += 2
else:
hexList.append( hex(ord(s[i]))[2:] )
i += 1
print(hexList)
# print(hexList[45:53])
print(hexList[102] == '01')
# l = ['08', 'c5', '22', '04', '00', '4b', '12', '00']
# print(':'.join(l))
# s = b'\x00\x63\x68\x65\x63\x6b\x5f\x72\x65\x63\x65\x70\x74\x69\x6f\x6e'
# load = str(s)
# isOcupied = '1' in load
# print(isOcupied)