added return type to suspendDebug
authorEdouard Tisserant
Thu, 22 Sep 2011 17:33:34 +0200
changeset 614 eed1dcf311a1
parent 613 be0ceea3b6dd
child 615 72bc3e53a1fa
added return type to suspendDebug
runtime/PLCObject.py
targets/Linux/plc_Linux_main.c
targets/Win32/plc_Win32_main.c
--- a/runtime/PLCObject.py	Thu Sep 22 17:00:56 2011 +0200
+++ b/runtime/PLCObject.py	Thu Sep 22 17:33:34 2011 +0200
@@ -136,7 +136,7 @@
             self._GetDebugData.argtypes = [ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_uint32), ctypes.POINTER(ctypes.c_void_p)]
 
             self._suspendDebug = self.PLClibraryHandle.suspendDebug
-            self._suspendDebug.restype = None
+            self._suspendDebug.restype = ctypes.c_int
             self._suspendDebug.argtypes = [ctypes.c_int]
 
             self._resumeDebug = self.PLClibraryHandle.resumeDebug
@@ -161,7 +161,7 @@
         self._IterDebugData = lambda x,y:None
         self._FreeDebugData = lambda:None
         self._GetDebugData = lambda:-1
-        self._suspendDebug = lambda x:None
+        self._suspendDebug = lambda x:-1
         self._resumeDebug = lambda:None
         self._PythonIterator = lambda:""
         self.PLClibraryHandle = None
@@ -329,18 +329,18 @@
         """
         if idxs:
             # suspend but dont disable
-            self._suspendDebug(False)
-            # keep a copy of requested idx
-            self._Idxs = idxs[:]
-            self._ResetDebugVariables()
-            for idx,iectype,force in idxs:
-                if force !=None:
-                    c_type,unpack_func, pack_func = \
-                        TypeTranslator.get(iectype,
-                                                (None,None,None))
-                    force = ctypes.byref(pack_func(c_type,force)) 
-                self._RegisterDebugVariable(idx, force)
-            self._resumeDebug()
+            if self._suspendDebug(False) == 0:
+                # keep a copy of requested idx
+                self._Idxs = idxs[:]
+                self._ResetDebugVariables()
+                for idx,iectype,force in idxs:
+                    if force !=None:
+                        c_type,unpack_func, pack_func = \
+                            TypeTranslator.get(iectype,
+                                                    (None,None,None))
+                        force = ctypes.byref(pack_func(c_type,force)) 
+                    self._RegisterDebugVariable(idx, force)
+                self._resumeDebug()
         else:
             self._suspendDebug(True)
             self._Idxs =  []
--- a/targets/Linux/plc_Linux_main.c	Thu Sep 22 17:00:56 2011 +0200
+++ b/targets/Linux/plc_Linux_main.c	Thu Sep 22 17:33:34 2011 +0200
@@ -10,7 +10,6 @@
 #include <pthread.h>
 #include <locale.h>
 
-/* provided by POUS.C */
 extern unsigned long long common_ticktime__;
 
 long AtomicCompareExchange(long* atomicvar,long compared, long exchange)
@@ -158,7 +157,7 @@
     pthread_mutex_unlock(&debug_wait_mutex);
 }
 
-void suspendDebug(int disable)
+int suspendDebug(int disable)
 {
     /* Prevent PLC to enter debug code */
     pthread_mutex_lock(&debug_mutex);
@@ -166,6 +165,7 @@
     __DEBUG = !disable;
     if (disable)
     	pthread_mutex_unlock(&debug_mutex);
+    return 0;
 }
 
 void resumeDebug(void)
--- a/targets/Win32/plc_Win32_main.c	Thu Sep 22 17:00:56 2011 +0200
+++ b/targets/Win32/plc_Win32_main.c	Thu Sep 22 17:33:34 2011 +0200
@@ -183,14 +183,14 @@
     ReleaseSemaphore(debug_wait_sem, 1, NULL);
 }
 
-void suspendDebug(int disable)
+int suspendDebug(int disable)
 {
     /* Prevent PLC to enter debug code */
     WaitForSingleObject(debug_sem, INFINITE);
-    /*__DEBUG is protected by this mutex */
     __DEBUG = !disable;
     if(disable)
         ReleaseSemaphore(debug_sem, 1, NULL);
+    return 0;
 }
 
 void resumeDebug()