File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change 48
48
ser .write (bytes ("r" ,"ASCII" ))
49
49
numBytes = 0
50
50
f = open (name , 'ab' )
51
+ #I just read the data and put it into a file.
52
+ #TODO - Checksum scheme as when burning
51
53
while (numBytes < romsize ):
52
54
while ser .inWaiting ()== 0 :
53
55
print ("Reading from eprom. Current porcentage:{:.2%}" .format (numBytes / romsize ),end = '\r ' )
66
68
ser .write (b"\x55 " )
67
69
ser .write (bytes ("w" ,"ASCII" ))
68
70
time .sleep (0.001 )
71
+ #send address of the block first
69
72
ser .write (struct .pack (">B" ,i >> 8 ))
70
73
CHK = i >> 8
71
74
time .sleep (0.001 )
74
77
time .sleep (0.001 )
75
78
data = f .read (128 );
76
79
#print(data)
80
+
81
+ #Gets checksum from xoring the package
77
82
for j in range (len (data )):
78
83
CHK = CHK ^ data [j ]
79
84
time .sleep (0.001 )
80
85
print ("Writing data. Current porcentage:{:.2%}" .format (i / numsectors ),end = '\r ' )
81
86
#print("CHK:", CHK)
82
87
response = ~ CHK
88
+
89
+ #keeps trying while the replied checksum is not correct
83
90
while response != CHK :
84
91
ser .write (data )
85
92
ser .write (struct .pack (">B" ,CHK & 0xFF ))
104
111
print ("Written by Robson Couto\n " )
105
112
#Blank check
106
113
if (option == 4 ):
114
+ #same as reading
107
115
ser .flushInput ()
108
116
ser .write (b"\x55 " )
109
117
ser .write (bytes ("r" ,"ASCII" ))
118
126
if ord (data )!= 255 :
119
127
blank = 0
120
128
break
129
+ #Ends check on first byte not erased
121
130
if blank == 1 :
122
131
print ("\n The chip is blank\n " )
123
132
else :
133
142
print ("Eprom size changed to " ,romsize / (1024 * 1024 ),"MB\n " )
134
143
else :
135
144
print ("Eprom size changed to " ,romsize / (1024 ),"KB\n " )
136
-
145
+
137
146
if (option == 6 ):
138
147
print ("See ya!" )
139
148
break
You can’t perform that action at this time.
0 commit comments