merge
authorEdouard Tisserant
Thu, 21 Mar 2013 09:29:46 +0900
changeset 33 961cf0f80c25
parent 31 a9c9d1fc97d3 (diff)
parent 32 6942b30d13c4 (current diff)
child 34 b2fb188c9bff
merge
--- a/LPCconnector/LPCAppObject.py	Wed Mar 20 23:48:14 2013 +0100
+++ b/LPCconnector/LPCAppObject.py	Thu Mar 21 09:29:46 2013 +0900
@@ -25,7 +25,7 @@
 import ctypes
 from LPCAppProto import *
 from LPCObject import *
-from targets.typemapping import SameEndianessTypeTranslator as TypeTranslator
+from targets.typemapping import  LogLevelsCount, SameEndianessTypeTranslator as TypeTranslator
 
 class LPCAppObject(LPCObject):
     def connect(self,comport):
@@ -46,10 +46,13 @@
 
     def GetPLCstatus(self):
         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))
+        if len(strcounts) == LogLevelsCount * 4:
+            cstrcounts = ctypes.create_string_buffer(strcounts)
+            ccounts = ctypes.cast(cstrcounts, ctypes.POINTER(ctypes.c_uint32))
+            counts = [int(ccounts[idx]) for idx in xrange(LogLevelsCount)]
+        else :
+            counts = [0]*LogLevelsCount
+        return self.PLCStatus, counts 
 
     def MatchMD5(self, MD5):
         data = self.HandleSerialTransaction(GET_PLCIDTransaction())
@@ -97,12 +100,10 @@
         if strbuf is not None and len(strbuf) > 4 and self.PLCStatus == "Started":
             res=[]
             size = len(strbuf) - 4
-            tick = ctypes.cast(
-                    ctypes.c_char_p(strbuf[:4]),
-                    ctypes.POINTER(ctypes.c_int)).contents
-            buff = ctypes.cast(
-                      ctypes.c_char_p(strbuf[4:]),
-                      ctypes.c_void_p)
+            ctick = ctypes.create_string_buffer(strbuf[:4])
+            tick = ctypes.cast(ctick, ctypes.POINTER(ctypes.c_int)).contents
+            cbuff = ctypes.create_string_buffer(strbuf[4:])
+            buff = ctypes.cast(cbuff, ctypes.c_void_p)
             for idx, iectype, forced in self._Idxs:
                 cursor = ctypes.c_void_p(buff.value + offset)
                 c_type,unpack_func, pack_func = TypeTranslator.get(iectype, (None,None,None))
--- a/LPCtarget/plc_LPC_main.c	Wed Mar 20 23:48:14 2013 +0100
+++ b/LPCtarget/plc_LPC_main.c	Thu Mar 21 09:29:46 2013 +0900
@@ -32,7 +32,7 @@
 	return res;
 }
 
-long AtomicCompareExchange64(long long* atomicvar,long long compared, long long exchange)
+long long AtomicCompareExchange64(long long* atomicvar,long long compared, long long exchange)
 {
 	/* No need for real atomic op on LPC,
 	 * no possible preemption between debug and PLC */