--- a/targets/Xenomai/plc_Xenomai_main.c Sat Aug 21 11:02:09 2021 +0200
+++ b/targets/Xenomai/plc_Xenomai_main.c Tue Aug 24 11:12:41 2021 +0200
@@ -18,12 +18,12 @@
unsigned int PLC_state = 0;
#define PLC_STATE_TASK_CREATED 1
-#define PLC_STATE_DEBUG_PIPE_CREATED 2
-#define PLC_STATE_PYTHON_PIPE_CREATED 8
+#define PLC_STATE_DEBUG_PIPE_CREATED 2 +#define PLC_STATE_PYTHON_PIPE_CREATED 8 #define PLC_STATE_WAITDEBUG_PIPE_CREATED 16
#define PLC_STATE_WAITPYTHON_PIPE_CREATED 32
@@ -62,7 +62,7 @@
typedef struct RT_to_nRT_signal_s RT_to_nRT_signal_t;
@@ -101,7 +101,7 @@
rt_task_wait_period(NULL);
- /* since xenomai 3 it is not enough to close()
+ /* since xenomai 3 it is not enough to close() file descriptor to unblock read()... */
/* explicitely finish python thread */
@@ -258,26 +258,25 @@
/* no memory swapping for that process */
mlockall(MCL_CURRENT | MCL_FUTURE);
/* memory initialization */
bzero(RT_to_nRT_signal_pool, sizeof(RT_to_nRT_signal_pool));
- if(Debug_handle = create_RT_to_nRT_signal("Debug_pipe")) goto error;
+ if(!(Debug_handle = create_RT_to_nRT_signal("Debug_pipe"))) goto error; PLC_state |= PLC_STATE_DEBUG_PIPE_CREATED;
- if(Python_handle = create_RT_to_nRT_signal("Python_pipe")) goto error;
+ if(!(Python_handle = create_RT_to_nRT_signal("Python_pipe"))) goto error; PLC_state |= PLC_STATE_PYTHON_PIPE_CREATED;
/* create WaitDebug_pipe */
- if(WaitDebug_handle = create_RT_to_nRT_signal("WaitDebug_pipe")) goto error;
+ if(!(WaitDebug_handle = create_RT_to_nRT_signal("WaitDebug_pipe"))) goto error; PLC_state |= PLC_STATE_WAITDEBUG_PIPE_CREATED;
/* create WaitPython_pipe */
- if(WaitPython_handle = create_RT_to_nRT_signal("WaitPython_pipe")) goto error;
+ if(!(WaitPython_handle = create_RT_to_nRT_signal("WaitPython_pipe"))) goto error; PLC_state |= PLC_STATE_WAITPYTHON_PIPE_CREATED;
/*** create PLC task ***/
@@ -319,7 +318,7 @@
void LeaveDebugSection(void)
- if(AtomicCompareExchange( &debug_state,
+ if(AtomicCompareExchange( &debug_state, DEBUG_BUSY, DEBUG_FREE) == DEBUG_BUSY){
/* signal to NRT for wakeup */
@@ -335,7 +334,7 @@
if (PLC_shutdown) return -1;
/* Wait signal from PLC thread */
- recv_RT_to_nRT_signal(WaitDebug_handle, &cmd);
+ res = recv_RT_to_nRT_signal(WaitDebug_handle, &cmd); if (res == 1 && cmd == DEBUG_PENDING_DATA){
@@ -383,7 +382,7 @@
static long python_state = PYTHON_FREE;
int WaitPythonCommands(void)
if (PLC_shutdown) return -1;
/* Wait signal from PLC thread */