File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -16,17 +16,20 @@ def cbreak():
16
16
17
17
class CRC :
18
18
def __init__ (self , file ):
19
- self .result = 0xAAAA
19
+ self .result = 0xFFFF
20
20
self .file = file
21
21
22
22
def write (self , data ):
23
23
while len (data ) > 0 :
24
24
if not self .file is None :
25
25
self .file .write (data [0 ])
26
- self .result = self .result ^ ord (data [0 ])
27
- self .result = (self .result >> 8 ) + ((self .result & 0xFF ) << 8 )
26
+ tmp = data
27
+ tmp = chr (ord (tmp [0 ]) ^ (self .result & 0xFF ))
28
+ tmp = chr (ord (tmp [0 ]) ^ ((ord (tmp [0 ]) << 4 ) & 0xFF ))
29
+ self .result = (((ord (tmp [0 ]) << 8 ) & 0xFFFF ) | (self .result >> 8 )) ^ ((ord (tmp [0 ]) >> 4 ) & 0xFF ) ^ ((ord (tmp [0 ]) << 3 ) & 0xFFFF )
28
30
data = data [1 :]
29
-
31
+
32
+
30
33
def write_crc (self ):
31
34
#print hex(self.result)
32
35
stdout .write (chr (self .result >> 8 ))
You can’t perform that action at this time.
0 commit comments