connectors/LPC/LPCBootProto.py
author Lolitech
Thu, 03 Jun 2010 17:23:11 +0200
changeset 548 1428fd553988
parent 545 627e5c636a4f
child 567 72b51ec5be64
permissions -rw-r--r--
Some fixes in LPCApp{Obj,Proto}, to be continued.
from LPCProto import *

class LPCBootProto(LPCProto):
    def HandleTransaction(self, transaction):
        self.TransactionLock.acquire()
        try:
            transaction.SetPseudoFile(self.serialPort)
            res = transaction.ExchangeData()
        finally:
            self.TransactionLock.release()
        return "Stopped", res
    
class LPCBootTransaction:
    def __init__(self, optdata = ""):
        self.OptData = optdata
        self.pseudofile = None
        
    def SetPseudoFile(self, pseudofile):
        self.pseudofile = pseudofile
        
    def SendData(self):
        res = self.pseudofile.write(self.OptData)
        return True 

    def GetData(self):
        pass # not impl

    def ExchangeData(self): 
        pass

class LOADTransaction(LPCBootTransaction):
    def __init__(self, data):
        LPCBootTransaction.__init__(self, data)
    ExchangeData = LPCBootTransaction.SendData