--- a/plugger.py Sun Dec 06 19:39:24 2009 +0100
+++ b/plugger.py Sun Dec 06 21:03:10 2009 +0100
@@ -1547,17 +1547,13 @@
if(self.previous_plcstate != status):
"Started" : [("_Run", False),
"Stopped" : [("_Run", True),
"Empty" : [("_Run", False),
"Disconnected" :[("_Run", False),
@@ -1578,13 +1574,6 @@
self.previous_plcstate, self.logger.write)(_("PLC is %s\n")%status)
self.AppFrame.RefreshAll()
- self._connector.StartPLC()
- self.UpdateMethodsFromPLCStatus()
def RegisterDebugVarToConnector(self):
@@ -1729,12 +1718,12 @@
self.logger.write_warning(_("Debug Thread couldn't be killed"))
if self.GetIECProgramsAndVariables():
- self._connector.StartPLC(debug=True)
+ self._connector.StartPLC() self.logger.write(_("Starting PLC (debug mode)\n"))
self.AppFrame.ResetGraphicViewers()
@@ -1914,15 +1903,6 @@
"tooltip" : _("Start PLC"),
- {"bitmap" : opjimg("Debug"),
- "tooltip" : _("Start PLC (debug mode)"),
-# {"bitmap" : opjimg("Debug"),
-# "name" : "Do_Test_Debug",
-# "tooltip" : "Test debug mode)",
-# "method" : "_Do_Test_Debug"},
{"bitmap" : opjimg("Stop"),
--- a/runtime/PLCObject.py Sun Dec 06 19:39:24 2009 +0100
+++ b/runtime/PLCObject.py Sun Dec 06 21:03:10 2009 +0100
@@ -143,6 +143,7 @@
self._suspendDebug = self.PLClibraryHandle.suspendDebug
self._suspendDebug.restype = None
+ self._suspendDebug.argtypes = [ctypes.c_int] self._resumeDebug = self.PLClibraryHandle.resumeDebug
self._resumeDebug.restype = None
@@ -215,16 +216,12 @@
self.website.PLCStopped()
self.python_threads_vars = None
- def PythonThreadProc(self, debug):
+ def PythonThreadProc(self): PLCprint("PythonThreadProc started")
c_argv = ctypes.c_char_p * len(self.argv)
if self._startPLC(len(self.argv),c_argv(*self.argv)) == 0:
- self._RegisterDebugVariable(idx)
self.PLCStatus = "Started"
self.evaluator(self.PrepareRuntimePy)
@@ -253,11 +250,11 @@
PLCprint("PythonThreadProc interrupted")
- def StartPLC(self, debug=False):
if self.CurrentPLCFilename is not None:
self.PLCStatus = "Started"
- self.PythonThread = Thread(target=self.PythonThreadProc, args=[debug])
+ self.PythonThread = Thread(target=self.PythonThreadProc) self.PythonThread.start()
@@ -335,13 +332,18 @@
Call ctype imported function to append
these indexes to registred variables in PLC debugger
- # keep a copy of requested idx
- self._ResetDebugVariables()
- for idx,iectype in idxs:
- self._RegisterDebugVariable(idx)
+ # suspend but dont disable + self._suspendDebug(False) + # keep a copy of requested idx + self._ResetDebugVariables() + for idx,iectype in idxs: + self._RegisterDebugVariable(idx) + self._suspendDebug(True) class IEC_STRING(ctypes.Structure):
--- a/targets/Linux/plc_Linux_main.c Sun Dec 06 19:39:24 2009 +0100
+++ b/targets/Linux/plc_Linux_main.c Sun Dec 06 21:03:10 2009 +0100
@@ -85,7 +85,9 @@
sigev.sigev_notify_function = PLC_timer_notify;
pthread_mutex_init(&debug_wait_mutex, NULL);
+ pthread_mutex_init(&debug_mutex, NULL); pthread_mutex_init(&python_wait_mutex, NULL);
+ pthread_mutex_init(&python_mutex, NULL); pthread_mutex_lock(&debug_wait_mutex);
pthread_mutex_lock(&python_wait_mutex);
@@ -95,10 +97,7 @@
PLC_SetTimer(Ttick,Ttick);
/* install signal handler for manual break */
-// signal(SIGTERM, catch_signal);
signal(SIGINT, catch_signal);
- pthread_mutex_trylock(&debug_mutex);
@@ -107,7 +106,14 @@
int TryEnterDebugSection(void)
- return pthread_mutex_trylock(&debug_mutex) == 0;
+ if (pthread_mutex_trylock(&debug_mutex) == 0){ + /* Only enter if debug active */ + pthread_mutex_unlock(&debug_mutex); void LeaveDebugSection(void)
@@ -149,11 +155,12 @@
pthread_mutex_unlock(&debug_wait_mutex);
+void suspendDebug(int disable)
/* Prevent PLC to enter debug code */
pthread_mutex_lock(&debug_mutex);
+ /*__DEBUG is protected by this mutex */