class LPCBootProto(LPCProto):
def HandleTransaction(self, transaction):
transaction.SetPseudoFile(self.serialPort)
res = transaction.ExchangeData()
class LPCBootTransaction:
def __init__(self, optdata = ""):
def SetPseudoFile(self, pseudofile):
self.pseudofile = pseudofile
self.pseudofile.write(self.OptData)
return [self.pseudofile.readline() for x in range(self.expectedlines)]
class KEEPBOOTINGTransaction(LPCBootTransaction):
LPCBootTransaction.__init__(self, "md5\n")
class STARTTransaction(LPCBootTransaction):
LPCBootTransaction.__init__(self, "go\n")
class CHECKMD5Transaction(LPCBootTransaction):
def __init__(self, md5ref):
LPCBootTransaction.__init__(self, md5ref+"md5\n")
class LOADTransaction(LPCBootTransaction):
def __init__(self, data, PLCprint):
LPCBootTransaction.__init__(self, data)
#file("fw.bin","w").write(self.OptData)
loptdata = len(self.OptData)
#self.PLCprint("%dkB:" % (loptdata/1024))
res = self.pseudofile.write(data[:loptdata/100])
self.PLCprint("%d%%" % count)
if __name__ == "__main__":
TestConnection = LPCBootProto(2,115200,1200)
mystr=file("fw.bin").read()
TestConnection.HandleTransaction(LOADTransaction(mystr, mylog))