--- a/Beremiz.py Tue Feb 01 17:28:41 2011 +0100
+++ b/Beremiz.py Thu Feb 03 18:20:47 2011 +0100
@@ -278,6 +278,10 @@
def write_error(self, s):
self.write(s,self.red_yellow)
+ def writeyield(self, s):
+ self.write(s)
+ wx.GetApp().Yield()
+
def flush(self):
self.output.SetValue("")
--- a/connectors/LPC/LPCBootObject.py Tue Feb 01 17:28:41 2011 +0100
+++ b/connectors/LPC/LPCBootObject.py Thu Feb 03 18:20:47 2011 +0100
@@ -38,7 +38,7 @@
self.PLCStatus = "Stopped"
def NewPLC(self, md5sum, data, extrafiles):
- self.successfully_transfered = self.HandleSerialTransaction(LOADTransaction(data))
+ self.successfully_transfered = self.HandleSerialTransaction(LOADTransaction(data, self.PLCprint))
return self.successfully_transfered
def MatchMD5(self, MD5):
--- 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))
--- a/connectors/LPC/LPCObject.py Tue Feb 01 17:28:41 2011 +0100
+++ b/connectors/LPC/LPCObject.py Thu Feb 03 18:20:47 2011 +0100
@@ -24,11 +24,13 @@
from LPCProto import *
+
+
class LPCObject():
def __init__(self, pluginsroot, comportstr):
self.PLCStatus = "Disconnected"
self.pluginsroot = pluginsroot
- self.PLCprint = pluginsroot.logger.write
+ self.PLCprint = pluginsroot.logger.writeyield
self._Idxs = []
comport = int(comportstr[3:]) - 1
try:
@@ -43,7 +45,7 @@
try:
self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction)
return res
- except LPCProtoError,e:
+ except Exception,e:
self.pluginsroot.logger.write_error(str(e)+"\n")
self.SerialConnection.close()
self.SerialConnection = None