File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 2
2
import serial ,time #You need the pyserial library
3
3
import struct
4
4
5
- ser = serial .Serial ('/dev/ttyACM0' , 230400 , timeout = 0 )
5
+ ser = serial .Serial ('/dev/ttyACM0' , 250000 , timeout = 0 )
6
6
#time.sleep(10);#my arduino bugs if data is written to the port after opening it
7
+ #filename='sonic.bin'#name of the rom, bin format
8
+ #f=open(name,'rb');
9
+ #with open(filename,'rb') as f:
7
10
romsize = 1024
8
11
9
12
while True :
32
35
f = open (name , 'ab' )#yes, that simple
33
36
while (numBytes < romsize ):
34
37
while ser .inWaiting ()== 0 :
35
- print ("waiting... \n " , numBytes )
38
+ print ("Waiting. Current porcentage:%.2f" % ( numBytes * 100 / romsize ), "%" , end = ' \r ' )
36
39
time .sleep (0.1 )
37
40
data = ser .read (1 )#must read the bytes and put in a file
38
41
f .write (data )
49
52
time .sleep (0.001 )
50
53
ser .write (struct .pack (">B" ,i >> 8 ))
51
54
CHK = i >> 8
55
+ #CHK=ord(CHK)
52
56
time .sleep (0.001 )
53
57
ser .write (struct .pack (">B" ,i & 0xFF ))
54
58
CHK ^= i & 0xFF
55
59
time .sleep (0.001 )
56
60
data = f .read (128 );
57
61
print (data )
62
+ #print("CHK:", CHK)
58
63
for j in range (len (data )):
59
64
CHK = CHK ^ data [j ]
60
65
time .sleep (0.001 )
61
66
print ("Sector:" ,i )
62
67
print ("CHK:" , CHK )
68
+ #ser.write(data)
63
69
response = ~ CHK
64
70
while response != CHK :
65
71
ser .write (data )
You can’t perform that action at this time.
0 commit comments