Skip to content

Commit 1d4bccb

Browse files
committed
More comments
1 parent d9424a7 commit 1d4bccb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

eprom.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
ser.write(bytes("r","ASCII"))
4949
numBytes=0
5050
f = open(name, 'ab')
51+
#I just read the data and put it into a file.
52+
#TODO - Checksum scheme as when burning
5153
while (numBytes<romsize):
5254
while ser.inWaiting()==0:
5355
print("Reading from eprom. Current porcentage:{:.2%}".format(numBytes/romsize),end='\r')
@@ -66,6 +68,7 @@
6668
ser.write(b"\x55")
6769
ser.write(bytes("w","ASCII" ))
6870
time.sleep(0.001)
71+
#send address of the block first
6972
ser.write(struct.pack(">B",i>>8))
7073
CHK=i>>8
7174
time.sleep(0.001)
@@ -74,12 +77,16 @@
7477
time.sleep(0.001)
7578
data=f.read(128);
7679
#print(data)
80+
81+
#Gets checksum from xoring the package
7782
for j in range(len(data)):
7883
CHK=CHK^data[j]
7984
time.sleep(0.001)
8085
print("Writing data. Current porcentage:{:.2%}".format(i/numsectors),end='\r')
8186
#print("CHK:", CHK)
8287
response=~CHK
88+
89+
#keeps trying while the replied checksum is not correct
8390
while response!=CHK:
8491
ser.write(data)
8592
ser.write(struct.pack(">B",CHK&0xFF))
@@ -104,6 +111,7 @@
104111
print("Written by Robson Couto\n")
105112
#Blank check
106113
if(option==4):
114+
#same as reading
107115
ser.flushInput()
108116
ser.write(b"\x55")
109117
ser.write(bytes("r","ASCII"))
@@ -118,6 +126,7 @@
118126
if ord(data)!=255:
119127
blank=0
120128
break
129+
#Ends check on first byte not erased
121130
if blank==1:
122131
print("\nThe chip is blank\n")
123132
else:
@@ -133,7 +142,7 @@
133142
print("Eprom size changed to ",romsize/(1024*1024),"MB\n")
134143
else:
135144
print("Eprom size changed to ",romsize/(1024),"KB\n")
136-
145+
137146
if(option==6):
138147
print("See ya!")
139148
break

0 commit comments

Comments
 (0)