-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (47 loc) · 1.73 KB
/
main.py
File metadata and controls
67 lines (47 loc) · 1.73 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import LPC8xx_Bootloader
import time
#----------------------------------------------------------------------
def bootload(idNum):
bootLoad812.flushReadBuffer()
bootLoad812.BMSbootloaderStart(idNum)
time.sleep(2)
response = bootLoad812.checkRepsonse()
if(response == '{09RB00000000000016}'):
print 'Bootoader response correct. Starting...'
time.sleep(1)
bootLoad812.checkRepsonse()
time.sleep(1)
bootLoad812.sendSyncAndSetup()
time.sleep(1)
bootLoad812.sendFirmware('PangeaBMS_LPC812.bin')
time.sleep(1)
bootLoad812.sendGoCommand()
else:
print 'Failed to receive bootloader response'
#----------------------------------------------------------------------
def getStatus(idNum):
bootLoad812.flushReadBuffer()
bootLoad812.BMSgetStatus(idNum)
time.sleep(1)
print bootLoad812.checkRepsonse()
#----------------------------------------------------------------------
def changeAddress(idFrom, idTo):
bootLoad812.flushReadBuffer()
bootLoad812.BMSchangeAddress(idFrom, idTo)
time.sleep(1)
print bootLoad812.checkRepsonse()
#----------------------------------------------------------------------
if __name__ == '__main__':
#RAM_ADDR = 0x10000300q
#PAGE_SIZE = 0x40
#SECTOR_SIZE = 0x400
#FLASH_SIZE = 0x4000
bootLoad812 = LPC8xx_Bootloader.LPC8xx_Bootloader(0x10000300, 0x40, 0x400, 0x4000)
#bootLoad812.openPort('/dev/tty.usbserial-FTVSIABB', 57600)
bootLoad812.openPort('/dev/tty.usbserial-FTVSD4UR', 57600)
targetID = 27
changeAddress(99, targetID)
getStatus(targetID)
#getStatus(99)
#changeAddress(99, 1)
bootLoad812.closePort()