LPCconnector/LPCAppObject.py
changeset 29 86fb7dc2b54e
parent 0 51f5a3138405
child 30 9cd6bc93ed89
--- a/LPCconnector/LPCAppObject.py	Wed Mar 13 12:04:18 2013 +0900
+++ b/LPCconnector/LPCAppObject.py	Tue Mar 19 17:22:27 2013 +0900
@@ -45,8 +45,11 @@
         return self.PLCStatus
 
     def GetPLCstatus(self):
-        self.HandleSerialTransaction(GET_PLCIDTransaction())
-        return self.PLCStatus
+        strcounts = self.HandleSerialTransaction(GET_LOGCOUNTSTransaction())
+        ccounts = ctypes.cast(
+                      ctypes.c_char_p(strcounts),
+                      ctypes.POINTER(ctypes.c_uint32))
+        return (self.PLCStatus,)+tuple(int(ccounts[idx]) for idx in range(4))
 
     def MatchMD5(self, MD5):
         data = self.HandleSerialTransaction(GET_PLCIDTransaction())
@@ -118,3 +121,11 @@
             #PLCprint("Debug error - wrong buffer unpack !")
         return self.PLCStatus, None, [] 
 
+    def GetLogMessage(self, level, msgid):
+        strbuf = self.HandleSerialTransaction(GET_LOGMSGTransaction(level, msgid))
+        if len(strbuf) > 12:
+            cbuf = ctypes.cast(
+                          ctypes.c_char_p(strbuf[:12]),
+                          ctypes.POINTER(ctypes.c_uint32))
+            return (strbuf[12:],)+tuple(int(cbuf[idx]) for idx in range(3))
+        return None