connectors/LPC/LPCBootProto.py
changeset 571 427bf9130d12
parent 569 37af7286dd65
child 600 310455d73131
equal deleted inserted replaced
570:46abd6b2f639 571:427bf9130d12
    16         self.pseudofile = None
    16         self.pseudofile = None
    17         
    17         
    18     def SetPseudoFile(self, pseudofile):
    18     def SetPseudoFile(self, pseudofile):
    19         self.pseudofile = pseudofile
    19         self.pseudofile = pseudofile
    20         
    20         
    21     def SendData(self):
       
    22         res = self.pseudofile.write(self.OptData)
       
    23         return True 
       
    24 
       
    25     def GetData(self):
       
    26         pass # not impl
       
    27 
       
    28     def ExchangeData(self): 
    21     def ExchangeData(self): 
    29         pass
    22         self.pseudofile.write(self.OptData)
       
    23         return map(lambda x:self.pseudofile.readline(), xrange(self.expectedlines))
    30 
    24 
    31 class KEEPBOOTINGTransaction(LPCBootTransaction):
    25 class KEEPBOOTINGTransaction(LPCBootTransaction):
    32     def __init__(self):
    26     def __init__(self):
       
    27         self.expectedlines = 2
    33         LPCBootTransaction.__init__(self, "md5\n")
    28         LPCBootTransaction.__init__(self, "md5\n")
    34     ExchangeData = LPCBootTransaction.SendData
    29 
       
    30 class STARTTransaction(LPCBootTransaction):
       
    31     def __init__(self):
       
    32         self.expectedlines = 0
       
    33         LPCBootTransaction.__init__(self, "go\n")
       
    34 
       
    35 class CHECKMD5Transaction(LPCBootTransaction):
       
    36     def __init__(self, md5ref):
       
    37         self.expectedlines = 5 
       
    38         LPCBootTransaction.__init__(self, md5ref+"md5\n")
    35 
    39 
    36 class LOADTransaction(LPCBootTransaction):
    40 class LOADTransaction(LPCBootTransaction):
    37     def __init__(self, data, PLCprint):
    41     def __init__(self, data, PLCprint):
    38         self.PLCprint = PLCprint
    42         self.PLCprint = PLCprint
    39         LPCBootTransaction.__init__(self, data)
    43         LPCBootTransaction.__init__(self, data)
    40 
    44 
    41     def sendDataHook(self):
    45     def ExchangeData(self):
    42         #file("fw.bin","w").write(self.OptData)
    46         #file("fw.bin","w").write(self.OptData)
    43         data = self.OptData
    47         data = self.OptData
    44         loptdata = len(self.OptData)
    48         loptdata = len(self.OptData)
    45         count=0
    49         count=0
    46         self.PLCprint("%dkB:" % (loptdata/1024))
    50         self.PLCprint("%dkB:" % (loptdata/1024))
    52                 self.PLCprint("%d%%" % count)
    56                 self.PLCprint("%d%%" % count)
    53             else :
    57             else :
    54                 self.PLCprint(".")
    58                 self.PLCprint(".")
    55         self.PLCprint("\n")
    59         self.PLCprint("\n")
    56         return True
    60         return True
    57     ExchangeData = sendDataHook
       
    58 
    61 
    59 if __name__ == "__main__":
    62 if __name__ == "__main__":
       
    63     __builtins__.BMZ_DBG = True
    60     TestConnection = LPCBootProto(2,115200,1200)
    64     TestConnection = LPCBootProto(2,115200,1200)
    61     mystr=file("fw.bin").read()
    65     mystr=file("fw.bin").read()
    62     def mylog(blah):
    66     def mylog(blah):
    63         print blah,
    67         print blah,
    64 
    68