author | Edouard Tisserant |
Tue, 14 Feb 2023 12:10:35 +0100 | |
changeset 3725 | 0043e2b9dbec |
parent 3334 | d7e0ddb5974b |
child 3726 | 516779f11803 |
permissions | -rw-r--r-- |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
1 |
/** |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
2 |
* Linux specific code |
329 | 3 |
**/ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
4 |
|
205 | 5 |
#include <stdio.h> |
6 |
#include <string.h> |
|
7 |
#include <time.h> |
|
8 |
#include <signal.h> |
|
9 |
#include <stdlib.h> |
|
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
10 |
#include <errno.h> |
329 | 11 |
#include <pthread.h> |
568 | 12 |
#include <locale.h> |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
13 |
#include <semaphore.h> |
205 | 14 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
15 |
static sem_t Run_PLC; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
16 |
|
236 | 17 |
long AtomicCompareExchange(long* atomicvar,long compared, long exchange) |
205 | 18 |
{ |
19 |
return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
|
20 |
} |
|
954 | 21 |
long long AtomicCompareExchange64(long long* atomicvar, long long compared, long long exchange) |
22 |
{ |
|
23 |
return __sync_val_compare_and_swap(atomicvar, compared, exchange); |
|
24 |
} |
|
205 | 25 |
|
26 |
void PLC_GetTime(IEC_TIME *CURRENT_TIME) |
|
27 |
{ |
|
592 | 28 |
struct timespec tmp; |
29 |
clock_gettime(CLOCK_REALTIME, &tmp); |
|
30 |
CURRENT_TIME->tv_sec = tmp.tv_sec; |
|
31 |
CURRENT_TIME->tv_nsec = tmp.tv_nsec; |
|
205 | 32 |
} |
33 |
||
34 |
void PLC_timer_notify(sigval_t val) |
|
35 |
{ |
|
36 |
PLC_GetTime(&__CURRENT_TIME); |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
37 |
sem_post(&Run_PLC); |
205 | 38 |
} |
39 |
||
40 |
timer_t PLC_timer; |
|
41 |
||
518
8e61b0066859
Fixed confusion about __common_ticktime type, redesigned LPC PLC timer support
edouard
parents:
485
diff
changeset
|
42 |
void PLC_SetTimer(unsigned long long next, unsigned long long period) |
205 | 43 |
{ |
44 |
struct itimerspec timerValues; |
|
45 |
/* |
|
46 |
printf("SetTimer(%lld,%lld)\n",next, period); |
|
47 |
*/ |
|
48 |
memset (&timerValues, 0, sizeof (struct itimerspec)); |
|
49 |
{ |
|
50 |
#ifdef __lldiv_t_defined |
|
51 |
lldiv_t nxt_div = lldiv(next, 1000000000); |
|
52 |
lldiv_t period_div = lldiv(period, 1000000000); |
|
53 |
timerValues.it_value.tv_sec = nxt_div.quot; |
|
54 |
timerValues.it_value.tv_nsec = nxt_div.rem; |
|
55 |
timerValues.it_interval.tv_sec = period_div.quot; |
|
56 |
timerValues.it_interval.tv_nsec = period_div.rem; |
|
57 |
#else |
|
58 |
timerValues.it_value.tv_sec = next / 1000000000; |
|
59 |
timerValues.it_value.tv_nsec = next % 1000000000; |
|
60 |
timerValues.it_interval.tv_sec = period / 1000000000; |
|
61 |
timerValues.it_interval.tv_nsec = period % 1000000000; |
|
62 |
#endif |
|
329 | 63 |
} |
205 | 64 |
timer_settime (PLC_timer, 0, &timerValues, NULL); |
65 |
} |
|
66 |
// |
|
67 |
void catch_signal(int sig) |
|
68 |
{ |
|
69 |
// signal(SIGTERM, catch_signal); |
|
70 |
signal(SIGINT, catch_signal); |
|
71 |
printf("Got Signal %d\n",sig); |
|
72 |
exit(0); |
|
73 |
} |
|
74 |
||
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
75 |
|
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
76 |
static unsigned long __debug_tick; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
77 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
78 |
pthread_t PLC_thread; |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
79 |
static pthread_mutex_t python_wait_mutex = PTHREAD_MUTEX_INITIALIZER; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
80 |
static pthread_mutex_t python_mutex = PTHREAD_MUTEX_INITIALIZER; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
81 |
static pthread_mutex_t debug_wait_mutex = PTHREAD_MUTEX_INITIALIZER; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
82 |
static pthread_mutex_t debug_mutex = PTHREAD_MUTEX_INITIALIZER; |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
83 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
84 |
int PLC_shutdown = 0; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
85 |
|
2173
976841968d74
Add retain basic implementation on GNU/Linux
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2171
diff
changeset
|
86 |
int ForceSaveRetainReq(void) { |
976841968d74
Add retain basic implementation on GNU/Linux
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2171
diff
changeset
|
87 |
return PLC_shutdown; |
976841968d74
Add retain basic implementation on GNU/Linux
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2171
diff
changeset
|
88 |
} |
976841968d74
Add retain basic implementation on GNU/Linux
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2171
diff
changeset
|
89 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
90 |
void PLC_thread_proc(void *arg) |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
91 |
{ |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
92 |
while (!PLC_shutdown) { |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
93 |
sem_wait(&Run_PLC); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
94 |
__run(); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
95 |
} |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
96 |
pthread_exit(0); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
97 |
} |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
98 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
99 |
#define maxval(a,b) ((a>b)?a:b) |
205 | 100 |
int startPLC(int argc,char **argv) |
101 |
{ |
|
102 |
struct sigevent sigev; |
|
568 | 103 |
setlocale(LC_NUMERIC, "C"); |
329 | 104 |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
105 |
PLC_shutdown = 0; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
106 |
|
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
107 |
sem_init(&Run_PLC, 0, 0); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
108 |
|
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
109 |
pthread_create(&PLC_thread, NULL, (void*) &PLC_thread_proc, NULL); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
110 |
|
205 | 111 |
memset (&sigev, 0, sizeof (struct sigevent)); |
112 |
sigev.sigev_value.sival_int = 0; |
|
113 |
sigev.sigev_notify = SIGEV_THREAD; |
|
114 |
sigev.sigev_notify_attributes = NULL; |
|
115 |
sigev.sigev_notify_function = PLC_timer_notify; |
|
116 |
||
333 | 117 |
pthread_mutex_init(&debug_wait_mutex, NULL); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
118 |
pthread_mutex_init(&debug_mutex, NULL); |
333 | 119 |
pthread_mutex_init(&python_wait_mutex, NULL); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
120 |
pthread_mutex_init(&python_mutex, NULL); |
329 | 121 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
122 |
pthread_mutex_lock(&debug_wait_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
123 |
pthread_mutex_lock(&python_wait_mutex); |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
124 |
|
2171
d1536c271866
use CLOCK_MONOTONIC instead of CLOCK_REALTIME for timer setup
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1903
diff
changeset
|
125 |
timer_create (CLOCK_MONOTONIC, &sigev, &PLC_timer); |
205 | 126 |
if( __init(argc,argv) == 0 ){ |
1428
e14003eb4d42
Simplified use of runtime's global variable __common_ticktime accross extensions.
Edouard Tisserant
parents:
985
diff
changeset
|
127 |
PLC_SetTimer(common_ticktime__,common_ticktime__); |
329 | 128 |
|
205 | 129 |
/* install signal handler for manual break */ |
130 |
signal(SIGINT, catch_signal); |
|
131 |
}else{ |
|
132 |
return 1; |
|
133 |
} |
|
134 |
return 0; |
|
135 |
} |
|
136 |
||
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
137 |
int TryEnterDebugSection(void) |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
138 |
{ |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
139 |
if (pthread_mutex_trylock(&debug_mutex) == 0){ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
140 |
/* Only enter if debug active */ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
141 |
if(__DEBUG){ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
142 |
return 1; |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
143 |
} |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
144 |
pthread_mutex_unlock(&debug_mutex); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
145 |
} |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
146 |
return 0; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
147 |
} |
235 | 148 |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
149 |
void LeaveDebugSection(void) |
235 | 150 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
151 |
pthread_mutex_unlock(&debug_mutex); |
235 | 152 |
} |
153 |
||
205 | 154 |
int stopPLC() |
155 |
{ |
|
156 |
/* Stop the PLC */ |
|
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
157 |
PLC_shutdown = 1; |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
158 |
sem_post(&Run_PLC); |
205 | 159 |
PLC_SetTimer(0,0); |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
160 |
pthread_join(PLC_thread, NULL); |
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
161 |
sem_destroy(&Run_PLC); |
205 | 162 |
timer_delete (PLC_timer); |
163 |
__cleanup(); |
|
329 | 164 |
pthread_mutex_destroy(&debug_wait_mutex); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
165 |
pthread_mutex_destroy(&debug_mutex); |
329 | 166 |
pthread_mutex_destroy(&python_wait_mutex); |
483
bc26c42d2eec
fixed greg's crap in win32, enhanced debug stability, implemented preliminary retain
edouard
parents:
462
diff
changeset
|
167 |
pthread_mutex_destroy(&python_mutex); |
386 | 168 |
return 0; |
205 | 169 |
} |
170 |
||
397
6a7ff66a811d
Adding support for forcing tick count to return to zero as the same time than all tasks firing are synchronized
laurent
parents:
386
diff
changeset
|
171 |
extern unsigned long __tick; |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
172 |
|
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
173 |
int WaitDebugData(unsigned long *tick) |
205 | 174 |
{ |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
175 |
int res; |
876
179d5c455f29
Fix bug python thread blocked sometimes on Linux
Laurent Bessard
parents:
617
diff
changeset
|
176 |
if (PLC_shutdown) return 1; |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
177 |
/* Wait signal from PLC thread */ |
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
178 |
res = pthread_mutex_lock(&debug_wait_mutex); |
446
1edde533db19
Some cleanup in PLC status - removed that \"Starting\" state ...
ed
parents:
397
diff
changeset
|
179 |
*tick = __debug_tick; |
617
7c23fac40a2a
fixed debug with xenomai, fixed unprotected access to ___debug_tick
Edouard Tisserant
parents:
614
diff
changeset
|
180 |
return res; |
205 | 181 |
} |
329 | 182 |
|
205 | 183 |
/* Called by PLC thread when debug_publish finished |
184 |
* This is supposed to unlock debugger thread in WaitDebugData*/ |
|
185 |
void InitiateDebugTransfer() |
|
186 |
{ |
|
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
187 |
/* remember tick */ |
227
48c13b84505c
- Some improovements in debug data feedback data
etisserant
parents:
205
diff
changeset
|
188 |
__debug_tick = __tick; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
189 |
/* signal debugger thread it can read data */ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
190 |
pthread_mutex_unlock(&debug_wait_mutex); |
205 | 191 |
} |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
192 |
|
614 | 193 |
int suspendDebug(int disable) |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
194 |
{ |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
195 |
/* Prevent PLC to enter debug code */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
196 |
pthread_mutex_lock(&debug_mutex); |
462
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
197 |
/*__DEBUG is protected by this mutex */ |
274e83a5534e
Now debug is not a button anymore
Edouard TISSERANT <edouard.tisserant@gmail.com>
parents:
446
diff
changeset
|
198 |
__DEBUG = !disable; |
485 | 199 |
if (disable) |
200 |
pthread_mutex_unlock(&debug_mutex); |
|
614 | 201 |
return 0; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
202 |
} |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
203 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
204 |
void resumeDebug(void) |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
205 |
{ |
290
3bd617ae7a05
Local Runtime (LOCAL://) now launched "on demand"
etisserant
parents:
280
diff
changeset
|
206 |
__DEBUG = 1; |
239
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
207 |
/* Let PLC enter debug code */ |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
208 |
pthread_mutex_unlock(&debug_mutex); |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
209 |
} |
112b4bc523b3
Fixed bad IPC choice for debugger/PLC/control thread collaboration
etisserant
parents:
236
diff
changeset
|
210 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
211 |
/* from plc_python.c */ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
212 |
int WaitPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
213 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
214 |
/* Wait signal from PLC thread */ |
329 | 215 |
return pthread_mutex_lock(&python_wait_mutex); |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
216 |
} |
329 | 217 |
|
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
218 |
/* Called by PLC thread on each new python command*/ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
219 |
void UnBlockPythonCommands(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
220 |
{ |
3334 | 221 |
/* signal python thread it can read data */ |
280
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
222 |
pthread_mutex_unlock(&python_wait_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
223 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
224 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
225 |
int TryLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
226 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
227 |
return pthread_mutex_trylock(&python_mutex) == 0; |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
228 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
229 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
230 |
void UnLockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
231 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
232 |
pthread_mutex_unlock(&python_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
233 |
} |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
234 |
|
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
235 |
void LockPython(void) |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
236 |
{ |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
237 |
pthread_mutex_lock(&python_mutex); |
f2ef79f3dba0
Added native (not a plugin) asynchronous python eval function block - Beta. Code cleanup in C code templates.
etisserant
parents:
245
diff
changeset
|
238 |
} |
2820
d9b5303d43dc
SVGHMI : had to move the problem of wkaing up python thread from plc thread to platform specific code.
Edouard Tisserant
parents:
2173
diff
changeset
|
239 |
|
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
240 |
struct RT_to_nRT_signal_s { |
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
241 |
int used; |
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
242 |
pthread_cond_t WakeCond; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
243 |
pthread_mutex_t WakeCondLock; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
244 |
}; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
245 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
246 |
typedef struct RT_to_nRT_signal_s RT_to_nRT_signal_t; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
247 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
248 |
#define _LogAndReturnNull(text) \ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
249 |
{\ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
250 |
char mstr[256] = text " for ";\ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
251 |
strncat(mstr, name, 255);\ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
252 |
LogMessage(LOG_CRITICAL, mstr, strlen(mstr));\ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
253 |
return NULL;\ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
254 |
} |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
255 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
256 |
void *create_RT_to_nRT_signal(char* name){ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
257 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)malloc(sizeof(RT_to_nRT_signal_t)); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
258 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
259 |
if(!sig) |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
260 |
_LogAndReturnNull("Failed allocating memory for RT_to_nRT signal"); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
261 |
|
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
262 |
sig->used = 1; |
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
263 |
pthread_cond_init(&sig->WakeCond, NULL); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
264 |
pthread_mutex_init(&sig->WakeCondLock, NULL); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
265 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
266 |
return (void*)sig; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
267 |
} |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
268 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
269 |
void delete_RT_to_nRT_signal(void* handle){ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
270 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
271 |
|
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
272 |
pthread_mutex_lock(&sig->WakeCondLock); |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
273 |
sig->used = 0; |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
274 |
pthread_cond_signal(&sig->WakeCond); |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
275 |
pthread_mutex_unlock(&sig->WakeCondLock); |
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
276 |
} |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
277 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
278 |
int wait_RT_to_nRT_signal(void* handle){ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
279 |
int ret; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
280 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
281 |
pthread_mutex_lock(&sig->WakeCondLock); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
282 |
ret = pthread_cond_wait(&sig->WakeCond, &sig->WakeCondLock); |
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
283 |
if(!sig->used) ret = -EINVAL; |
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
284 |
pthread_mutex_unlock(&sig->WakeCondLock); |
3725
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
285 |
|
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
286 |
if(!sig->used){ |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
287 |
pthread_cond_destroy(&sig->WakeCond); |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
288 |
pthread_mutex_destroy(&sig->WakeCondLock); |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
289 |
free(sig); |
0043e2b9dbec
Linux runtime: fix thread waiting on wait_RT_to_nRT_signal not being waken-up when delete_RT_to_nRT_signal is invoked.
Edouard Tisserant
parents:
3334
diff
changeset
|
290 |
} |
3294
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
291 |
return ret; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
292 |
} |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
293 |
|
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
294 |
int unblock_RT_to_nRT_signal(void* handle){ |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
295 |
RT_to_nRT_signal_t *sig = (RT_to_nRT_signal_t*)handle; |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
296 |
return pthread_cond_signal(&sig->WakeCond); |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
297 |
} |
e3db472b0dfb
Runtime+SVGHMI: Added a generic way to wakeup non-real-time threads from real-time PLC thread. Replace SVGHMI specific calls in Linux and Xenomai implementations of plc_main.c. Fixed xenomai build, xeno-config making problems with --no-auto-init argument.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
2820
diff
changeset
|
298 |
|
3295
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3294
diff
changeset
|
299 |
void nRT_reschedule(void){ |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3294
diff
changeset
|
300 |
sched_yield(); |
0375d801fff7
Runtime+SVGHMI: Add generic wakeup of threads from PLC thread to windows implementation of plc_main.c. Also added nRT_reschedule to abstract sched_yield.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3294
diff
changeset
|
301 |
} |