Safer debug
authorEdouard TISSERANT <edouard.tisserant@gmail.com>
Sun, 06 Dec 2009 19:39:24 +0100
changeset 461 bcbc472c0ba8
parent 460 73a53278833b
child 462 274e83a5534e
Safer debug
plugger.py
runtime/PLCObject.py
--- a/plugger.py	Sun Dec 06 19:06:36 2009 +0100
+++ b/plugger.py	Sun Dec 06 19:39:24 2009 +0100
@@ -1692,11 +1692,13 @@
         """
         # This lock is used to avoid flooding wx event stack calling callafter
         self.debug_break = False
+        debug_getvar_retry = 0
         while (not self.debug_break) and (self._connector is not None):
             plc_status, debug_tick, debug_vars = self._connector.GetTraceVariables()
             #print debug_tick, debug_vars
             self.IECdebug_lock.acquire()
             if debug_vars is not None:
+                debug_getvar_retry = 0
                 if len(debug_vars) == len(self.TracedIECPath):
                     for IECPath,value in zip(self.TracedIECPath, debug_vars):
                         if value is not None:
@@ -1707,6 +1709,12 @@
                                  _("Debug data do not match requested variable count %d != %d\n")%(len(debug_vars), len(self.TracedIECPath)))
             else:
                 if plc_status == "Started":
+                    # Just in case, re-register debug registry to PLC
+                    if debug_getvar_retry == 0:
+                        wx.CallAfter(self.RegisterDebugVarToConnector)
+                        wx.CallAfter(self.logger.write_warning, 
+                                 _("Waiting debugger to recover...\n"))
+                    debug_getvar_retry += 1
                     # Be patient, tollerate PLC to come up before debugging
                     time.sleep(0.1)
                 else:
--- a/runtime/PLCObject.py	Sun Dec 06 19:06:36 2009 +0100
+++ b/runtime/PLCObject.py	Sun Dec 06 19:39:24 2009 +0100
@@ -399,7 +399,7 @@
                         break
             self._FreeDebugData()
             self.PLClibraryLock.release()
-            if offset == size:
+            if offset == size.value:
                 return self.PLCStatus, tick.value, res
             else:
                 PLCprint("Debug error - bad buffer unpack !")