32 def __init__(self): |
32 def __init__(self): |
33 LPCBootTransaction.__init__(self, "md5\n") |
33 LPCBootTransaction.__init__(self, "md5\n") |
34 ExchangeData = LPCBootTransaction.SendData |
34 ExchangeData = LPCBootTransaction.SendData |
35 |
35 |
36 class LOADTransaction(LPCBootTransaction): |
36 class LOADTransaction(LPCBootTransaction): |
37 def __init__(self, data): |
37 def __init__(self, data, PLCprint): |
|
38 self.PLCprint = PLCprint |
38 LPCBootTransaction.__init__(self, data) |
39 LPCBootTransaction.__init__(self, data) |
39 ExchangeData = LPCBootTransaction.SendData |
|
40 |
40 |
|
41 def sendDataHook(self): |
|
42 #file("fw.bin","w").write(self.OptData) |
|
43 data = self.OptData |
|
44 loptdata = len(self.OptData) |
|
45 count=0 |
|
46 self.PLCprint("%dkB:" % (loptdata/1024)) |
|
47 while len(data)>0: |
|
48 res = self.pseudofile.write(data[:loptdata/100]) |
|
49 data = data[res:] |
|
50 count += 1 |
|
51 if count % 10 == 0 : |
|
52 self.PLCprint("%d%%" % count) |
|
53 else : |
|
54 self.PLCprint(".") |
|
55 self.PLCprint("\n") |
|
56 return True |
|
57 ExchangeData = sendDataHook |
|
58 |
|
59 if __name__ == "__main__": |
|
60 TestConnection = LPCBootProto(2,115200,1200) |
|
61 mystr=file("fw.bin").read() |
|
62 def mylog(blah): |
|
63 print blah, |
|
64 |
|
65 TestConnection.HandleTransaction(LOADTransaction(mystr, mylog)) |