--- a/LPCconnector/LPCAppProto.py Wed Mar 13 12:04:18 2013 +0900
+++ b/LPCconnector/LPCAppProto.py Tue Mar 19 17:22:27 2013 +0900
@@ -23,9 +23,8 @@
return LPC_STATUS.get(current_plc_status,"Broken"), res
class LPCAppTransaction:
- def __init__(self, command, optdata = ""):
+ def __init__(self, command):
self.Command = command
- self.OptData = optdata
self.pseudofile = None
def SetPseudoFile(self, pseudofile):
@@ -46,12 +45,12 @@
return current_plc_status
return None
- def SendData(self):
- length = len(self.OptData)
+ def SendData(self, Data):
+ length = len(Data)
# transform length into a byte string
# we presuppose endianess of LPC same as PC
lengthstr = ctypes.string_at(ctypes.pointer(ctypes.c_int(length)),4)
- buffer = lengthstr + self.OptData
+ buffer = lengthstr + Data
return self.pseudofile.write(buffer)
def GetData(self):
@@ -82,8 +81,10 @@
class SET_TRACE_VARIABLETransaction(LPCAppTransaction):
def __init__(self, data):
- LPCAppTransaction.__init__(self, 0x04, data)
- ExchangeData = LPCAppTransaction.SendData
+ LPCAppTransaction.__init__(self, 0x04)
+ self.Data = data
+ def ExchangeData(self):
+ self.SendData(self.Data)
class GET_TRACE_VARIABLETransaction(LPCAppTransaction):
def __init__(self):
@@ -95,6 +96,21 @@
LPCAppTransaction.__init__(self, 0x07)
ExchangeData = LPCAppTransaction.GetData
+class GET_LOGCOUNTSTransaction(LPCAppTransaction):
+ def __init__(self):
+ LPCAppTransaction.__init__(self, 0x0B)
+ ExchangeData = LPCAppTransaction.GetData
+
+class GET_LOGMSGTransaction(LPCAppTransaction):
+ def __init__(self,level,msgid):
+ LPCAppTransaction.__init__(self, 0x0C)
+ msgidstr = ctypes.string_at(ctypes.pointer(ctypes.c_int(msgid)),4)
+ self.Data = chr(level)+msgidstr
+
+ def ExchangeData(self):
+ self.SendData(self.Data)
+ return self.GetData()
+
if __name__ == "__main__":
__builtins__.BMZ_DBG = True
TestConnection = LPCAppProto(6,115200,2)