forked from mtirado1/at89s8252-arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eraser.py
39 lines (35 loc) · 1.18 KB
/
eraser.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
import serial
import time
from config import *
# Serial port name
p = serialPort
print(p)
with serial.Serial(p, 9600) as ser:
time.sleep(2)
print(ser.readline().decode('utf-8'))
ser.write(b'\x50') # Enable programming
time.sleep(0.05)
print(ser.readline().decode('utf-8'))
print('Erasing...')
ser.write(b'\x53')
time.sleep(0.05)
print(ser.readline().decode('utf-8'))
# a = input('Programming done. Do you wish to verify? y/n: ')
# if a == 'Y' or a == 'y':
# print('Verifying...')
# err = False
# for i in range(0, len(ih.addresses())):
# addr = ih.addresses()[i]
# ser.write(b'\x52')
# ser.write(bytes([addr//256])) # high address byte
# ser.write(bytes([addr%256])) # low address byte
# k = int(ser.readline().decode('utf-8'), 16)
# if k != ih[addr]:
# print('Error at address' + hex(addr))
# print('Got %d, was %d' % (k, ih[addr]))
# err = True
# if not err:
# print('Verification complete.')
ser.write(b'\x40') # End programming
print(ser.readline().decode('utf-8'))
print('Done.')