-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertTrame.py
executable file
·90 lines (71 loc) · 5.59 KB
/
convertTrame.py
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/python
#from colorama import init, Fore, Back, Style
from datetime import datetime
import sys
#init()
# 0302 0201 0201 0202 0202 0101 0101 0101 0102 0102 0102 0201 0102 0202 0201 01020 2020 1010 2
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 0304
# 0302020102010202020201010101010101020102010202010102020202010102020201010203020201020102020202010101010101010201020102020101020202020101020202010102030202010201020202020101010101010102010201020201010202020201010202020101020302020102010202020201010101010101020102010202010102020202010102020201010203020201020102020202010101010101010201020102020101020202020101020202010102030202010201020202020101010101010102010201020201010202020201010202020101020304
# Uniquement 2 lignes utiles et un trailer
# 0302020102010202020201010101010101020102010202010 1020202020101020202010102
# 0302020102010202020201010101010101020102010202010 2020202020101020202010102
# 0304
# 03020201020102020202010101010101010201020102020101020202020101020202010102
# 20;E9;DEBUG;Pulses=448;Pulses(uSec)=450,3990,420,1950,390,1950,420,900,390,2010,390,900,390,1950,390,1950,390,2010,420,1950,390,900,390,900,390,2010,420,900,390,900,420,900,420,960,390,1950,390,900,390,1950,390,2010,390,900,420,900,390,900,420,960,390,1950,390,1950,390,1950,390,2010,390,900,420,900,390,1950,420,2010,390,1950,420,1950,390,1950,420,960,390,3990,390,1950,390,1950,420,900,390,2010,390,900,390,1950,390,1950,390,2010,390,1950,390,900,420,900,390,2010,390,900,390,900,420,900,390,960,420,1950,390,900,390,1980,390,2010,420,900,390,900,390,900,390,960,390,1950,390,1950,390,1950,390,2010,390,900,390,900,420,1950,390,2010,390,1950,390,1950,390,1980,390,960,390,3990,390,1950,390,1950,390,900,420,2010,390,900,390,1950,390,1950,420,2010,390,1950,420,900,391,900,420,2010,390,900,420,900,390,900,390,960,390,1950,420,900,390,1950,420,2010,390,900,420,900,420,900,390,960,390,1980,390,1950,390,1950,390,2010,390,900,390,900,390,1950,390,2010,420,1950,390,1950,420,1950,390,960,420,3990,390,1950,390,1950,390,900,420,2010,390,900,390,1950,390,1950,390,2010,390,1950,390,900,390,900,390,2010,390,900,390,900,390,900,390,960,390,1950,420,900,390,1950,390,2010,390,900,390,900,390,900,390,960,390,1980,390,1980,390,1950,420,2010,390,900,390,900,390,1980,390,2010,390,1950,420,1950,390,1950,420,960,390,3990,390,1950,390,1950,390,900,390,2010,390,900,390,1950,420,1950,390,2010,420,1950,390,900,390,900,390,2010,390,900,390,900,390,900,390,960,420,1950,390,900,390,1950,390,2010,420,900,390,900,420,900,390,960,420,1980,390,2070,420,1950,390,2010,390,900,390,900,390,1950,390,2010,420,1950,390,1950,390,1950,390,960,420,3990,390,1950,390,1950,390,900,420,2010,390,900,390,1980,390,1950,390,2010,390,1950,420,900,390,900,420,2010,390,900,390,900,390,900,390,960,390,1950,390,930,390,1950,390,2010,390,900,390,900,420,900,390,960,420,1950,390,1950,390,1950,390,2010,390,900,390,900,420,1950,390,2010,420,1950,390,1950,390,1950,390,960,420,3990,390,6990;
longueur_trame = 37
l = ''
f = open(sys.argv[1], 'r')
#f = open('/var/www/html/log/rflink', 'r')
for l in f.readlines():
if ';DEBUG;Pulses=448;' in l:
debug = l.strip().split(' : ')[2]
timetmp = l.strip().split(' : ')[0]
time = timetmp[1:].split(']')[0]
# 2017-11-11 12:15:47
t = datetime.strptime(time, '%Y-%m-%d %H:%M:%S')
#print(t.strftime('%X %x %Z'))
#print(time)
# lines.append(debug)
# for l in lines:
trame = debug.split('=')[2].replace(';', '')
data = trame.split(',')
#print(data)
databin = ''
for d in data:
d = int(d)
if d < 600:
databin += ''
elif d < 1500:
databin += '0'
elif d < 3000:
databin += '1'
elif d < 6000:
databin += '2'
elif d < 9000:
databin += '3'
#print(databin)
#if databin[0:73] == databin[74:147]:
if (databin[0:longueur_trame - 1] == databin[longueur_trame:longueur_trame * 2 - 1]) and (databin[0:longueur_trame - 1] == databin[longueur_trame * 2:longueur_trame * 3 - 1]) and (databin[0:longueur_trame - 1] == databin[longueur_trame * 3:longueur_trame * 4 - 1]) and (databin[0:longueur_trame - 1] == databin[longueur_trame * 4:longueur_trame * 5 - 1]) and (databin[0:longueur_trame - 1] == databin[longueur_trame * 4:longueur_trame * 5 - 1]) and (databin[0:longueur_trame - 1] == databin[longueur_trame * 4:longueur_trame * 5 - 1]):
#print('6 OK')
# and (databin[0:longueur_trame - 1] == databin[longueur_trame * 4:longueur_trame * 5 - 1]):
#print(databin[0:longueur_trame - 1], 'OK')
pass
else:
print(databin[0:longueur_trame - 1], 'NOK')
# print(databin[74:147])
#print(databin)
databin = databin[1:37]
ID = databin[0:8] # ID
B = databin[8:10] # ???
CHANNEL = databin[10:12] # Channel
TEMP = databin[12:24] # TEMP
E = databin[24:28] # always 1
HUM = databin[28:37] # HUM
print("%s - ID:%d ??:%d CHANNEL:%d TEMP:%d 1:%d HUM:%d" % (t, int(ID, 2), int(B, 2), int(CHANNEL, 2) + 1, int(TEMP, 2), int(E, 2), int(HUM, 2)))
#print("ID:%s ??:%s Canal:%s TEMP:%s 1:%s HUM:%s " % (A, B, C, D, E, F))
f.close()