equal
deleted
inserted
replaced
27 #define WAITDEBUG_PIPE_DEVICE "/dev/rtp0" |
27 #define WAITDEBUG_PIPE_DEVICE "/dev/rtp0" |
28 #define WAITDEBUG_PIPE_MINOR 0 |
28 #define WAITDEBUG_PIPE_MINOR 0 |
29 #define WAITDEBUG_PIPE_SIZE 500 |
29 #define WAITDEBUG_PIPE_SIZE 500 |
30 |
30 |
31 /* provided by POUS.C */ |
31 /* provided by POUS.C */ |
32 extern int common_ticktime__; |
32 extern unsigned long common_ticktime__; |
33 |
33 |
34 long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
34 long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
35 { |
35 { |
36 return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
36 return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
37 } |
37 } |
70 if (PLC_shutdown) break; |
70 if (PLC_shutdown) break; |
71 rt_task_wait_period(NULL); |
71 rt_task_wait_period(NULL); |
72 } |
72 } |
73 } |
73 } |
74 |
74 |
75 static int __debug_tick; |
75 static unsigned long __debug_tick; |
76 |
76 |
77 RT_SEM python_wait_sem; |
77 RT_SEM python_wait_sem; |
78 RT_MUTEX python_mutex; |
78 RT_MUTEX python_mutex; |
79 RT_MUTEX debug_mutex; |
79 RT_MUTEX debug_mutex; |
80 |
80 |
140 signal(SIGINT, catch_signal); |
140 signal(SIGINT, catch_signal); |
141 |
141 |
142 /* ne-memory-swapping for this program */ |
142 /* ne-memory-swapping for this program */ |
143 mlockall(MCL_CURRENT | MCL_FUTURE); |
143 mlockall(MCL_CURRENT | MCL_FUTURE); |
144 |
144 |
145 /* Translate PLC's microseconds to Ttick nanoseconds */ |
145 /* Define Ttick to 1ms if common_ticktime not defined */ |
146 Ttick = 1000000 * max_val(common_ticktime__,1); |
146 Ttick = common_ticktime__?common_ticktime__:1000000; |
147 |
147 |
148 /* create python_wait_sem */ |
148 /* create python_wait_sem */ |
149 ret = rt_sem_create(&python_wait_sem, "python_wait_sem", 0, S_FIFO); |
149 ret = rt_sem_create(&python_wait_sem, "python_wait_sem", 0, S_FIFO); |
150 if (ret) goto error; |
150 if (ret) goto error; |
151 PLC_state |= PLC_STATE_PYTHON_WAIT_SEM_CREATED; |
151 PLC_state |= PLC_STATE_PYTHON_WAIT_SEM_CREATED; |
201 void LeaveDebugSection(void) |
201 void LeaveDebugSection(void) |
202 { |
202 { |
203 rt_mutex_release(&debug_mutex); |
203 rt_mutex_release(&debug_mutex); |
204 } |
204 } |
205 |
205 |
206 extern int __tick; |
206 extern unsigned long __tick; |
207 /* from plc_debugger.c */ |
207 /* from plc_debugger.c */ |
208 int WaitDebugData() |
208 unsigned long WaitDebugData() |
209 { |
209 { |
210 char message; |
210 char message; |
211 int res; |
211 int res; |
212 /* Wait signal from PLC thread */ |
212 /* Wait signal from PLC thread */ |
213 if (PLC_state & PLC_STATE_DEBUG_FILE_OPENED) { |
213 if (PLC_state & PLC_STATE_DEBUG_FILE_OPENED) { |