get the WaitPythonCommands return (semaphore error code) to quit python_iterator loop when semaphore is destroyed
authorgreg
Mon, 18 May 2009 07:58:41 +0200
changeset 345 a3520d75a722
parent 344 25b7b7f854bc
child 346 abc5abffbc61
get the WaitPythonCommands return (semaphore error code) to quit python_iterator loop when semaphore is destroyed
targets/Xenomai/plc_Xenomai_main.c
--- a/targets/Xenomai/plc_Xenomai_main.c	Mon May 18 07:47:24 2009 +0200
+++ b/targets/Xenomai/plc_Xenomai_main.c	Mon May 18 07:58:41 2009 +0200
@@ -208,10 +208,14 @@
 int WaitDebugData()
 {
     char message;
+    int res;
     /* Wait signal from PLC thread */
-    if (PLC_state & PLC_STATE_DEBUG_FILE_OPENED)
-        read(WaitDebug_pipe_fd, &message, sizeof(char));
-    return __debug_tick;
+    if (PLC_state & PLC_STATE_DEBUG_FILE_OPENED) {
+        res = read(WaitDebug_pipe_fd, &message, sizeof(char));
+        if (res == sizeof(char))
+            return __debug_tick;
+    }
+    return -1;
 }
 
 /* Called by PLC thread when debug_publish finished
@@ -252,8 +256,9 @@
     /* Wait signal from PLC thread */
     if (PLC_state & PLC_STATE_PYTHON_WAIT_SEM_CREATED) {
         rt_task_shadow(&WaitPythonCommand_task, "WaitPythonCommand_task", 0, 0);
-        rt_sem_p(&python_wait_sem, TM_INFINITE);
-    }
+        return rt_sem_p(&python_wait_sem, TM_INFINITE);
+    }
+    return -1;
 }
 
 /* Called by PLC thread on each new python command*/