-
Notifications
You must be signed in to change notification settings - Fork 2
/
crc.py
89 lines (61 loc) · 2.64 KB
/
crc.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
def crc16(data: bytes) -> int:
crc = 0xE300
for b in data:
crc ^= b << 8
for j in range(0, 8):
if crc & 0b1000000000000000:
crc <<= 1
crc ^= 0x1021
else:
crc <<= 1
crc &= 0xFFFF
print(f"{b:#0{4}X}" + ', ' , end='')
print(f"{(crc >> 8):#0{4}X}" + ", " + f"{(crc & 0xFF):#0{4}X}" + ', 0xE3};', end='')
destination = 0xC0 #washer
#destination = 0x24 #dryer
sender = 0xBB
print("std::vector<uint8_t> fw_broadcast= {", end='')
crc16([0xE2, 0xFF , 0x08 , sender , 0x01])
print(" //FW broadcast message")
print("std::vector<uint8_t> erd2000= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x00])
print(" //State")
print("std::vector<uint8_t> erd2001= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x01])
print(" //Sub State")
print("std::vector<uint8_t> erd2002= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x02])
print(" //End of Cycle")
print("std::vector<uint8_t> erd2003= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x03])
print(" //Cycle Count")
print("std::vector<uint8_t> erd2007= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x07])
print(" //Cycle Time Remaining")
print("std::vector<uint8_t> erd200A= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x0A])
print(" //Cycle Setting")
print("std::vector<uint8_t> erd2012= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x12])
print(" //Door State")
print("std::vector<uint8_t> erd2013= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x13])
print(" //Washer Door Lock")
print("std::vector<uint8_t> erd2015= {", end='')
crc16([0xe2, destination, 0x0B, sender, 0xf0, 0x1, 0x20, 0x15] )
print(" //Washer Soil Level")
print("std::vector<uint8_t> erd2016= {", end='')
crc16([0xe2, destination, 0x0B, sender, 0xf0, 0x1, 0x20, 0x16] )
print(" //Washer Temp Level")
print("std::vector<uint8_t> erd2017= {", end='')
crc16([0xe2, destination, 0x0B, sender, 0xf0, 0x1, 0x20, 0x17] )
print(" //Washer Spin Level")
print("std::vector<uint8_t> erd2018= {", end='')
crc16([0xe2, destination, 0x0B, sender, 0xf0, 0x1, 0x20, 0x18] )
print(" //Washer Rinse Option")
print("std::vector<uint8_t> erd204D= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x4D])
print(" //Dryer Dryness Setting")
print("std::vector<uint8_t> erd2050= {", end='')
crc16([0xE2, destination, 0x0B, sender, 0xF0, 0x01, 0x20, 0x50])
print(" //Dryer Heat Setting")