connectors/LPC/LPCBootProto.py
changeset 569 37af7286dd65
parent 567 72b51ec5be64
child 571 427bf9130d12
--- a/connectors/LPC/LPCBootProto.py	Tue Feb 01 17:28:41 2011 +0100
+++ b/connectors/LPC/LPCBootProto.py	Thu Feb 03 18:20:47 2011 +0100
@@ -34,7 +34,32 @@
     ExchangeData = LPCBootTransaction.SendData
 
 class LOADTransaction(LPCBootTransaction):
-    def __init__(self, data):
+    def __init__(self, data, PLCprint):
+        self.PLCprint = PLCprint
         LPCBootTransaction.__init__(self, data)
-    ExchangeData = LPCBootTransaction.SendData
 
+    def sendDataHook(self):
+        #file("fw.bin","w").write(self.OptData)
+        data = self.OptData
+        loptdata = len(self.OptData)
+        count=0
+        self.PLCprint("%dkB:" % (loptdata/1024))
+        while len(data)>0:
+            res = self.pseudofile.write(data[:loptdata/100])
+            data = data[res:]
+            count += 1
+            if count % 10 == 0 :
+                self.PLCprint("%d%%" % count)
+            else :
+                self.PLCprint(".")
+        self.PLCprint("\n")
+        return True
+    ExchangeData = sendDataHook
+
+if __name__ == "__main__":
+    TestConnection = LPCBootProto(2,115200,1200)
+    mystr=file("fw.bin").read()
+    def mylog(blah):
+        print blah,
+
+    TestConnection.HandleTransaction(LOADTransaction(mystr, mylog))