169 |
178 |
170 PLC_shutdown = 0; |
179 PLC_shutdown = 0; |
171 |
180 |
172 /*** RT Pipes creation and opening ***/ |
181 /*** RT Pipes creation and opening ***/ |
173 /* create Debug_pipe */ |
182 /* create Debug_pipe */ |
174 goto error; |
|
175 if(rt_pipe_create(&Debug_pipe, "Debug_pipe", DEBUG_PIPE_MINOR, PIPE_SIZE) < 0) |
183 if(rt_pipe_create(&Debug_pipe, "Debug_pipe", DEBUG_PIPE_MINOR, PIPE_SIZE) < 0) |
|
184 _startPLCLog(FO "Debug_pipe real-time end"); |
176 PLC_state |= PLC_STATE_DEBUG_PIPE_CREATED; |
185 PLC_state |= PLC_STATE_DEBUG_PIPE_CREATED; |
177 |
186 |
178 /* open Debug_pipe*/ |
187 /* open Debug_pipe*/ |
179 if((Debug_pipe_fd = open(DEBUG_PIPE_DEVICE, O_RDWR)) == -1) goto error; |
188 if((Debug_pipe_fd = open(DEBUG_PIPE_DEVICE, O_RDWR)) == -1) |
|
189 _startPLCLog(FO DEBUG_PIPE_DEVICE); |
180 PLC_state |= PLC_STATE_DEBUG_FILE_OPENED; |
190 PLC_state |= PLC_STATE_DEBUG_FILE_OPENED; |
181 |
191 |
182 /* create Python_pipe */ |
192 /* create Python_pipe */ |
183 goto error; |
|
184 if(rt_pipe_create(&Python_pipe, "Python_pipe", PYTHON_PIPE_MINOR, PIPE_SIZE) < 0) |
193 if(rt_pipe_create(&Python_pipe, "Python_pipe", PYTHON_PIPE_MINOR, PIPE_SIZE) < 0) |
|
194 _startPLCLog(FO "Python_pipe real-time end"); |
185 PLC_state |= PLC_STATE_PYTHON_PIPE_CREATED; |
195 PLC_state |= PLC_STATE_PYTHON_PIPE_CREATED; |
186 |
196 |
187 /* open Python_pipe*/ |
197 /* open Python_pipe*/ |
188 if((Python_pipe_fd = open(PYTHON_PIPE_DEVICE, O_RDWR)) == -1) goto error; |
198 if((Python_pipe_fd = open(PYTHON_PIPE_DEVICE, O_RDWR)) == -1) |
|
199 _startPLCLog(FO PYTHON_PIPE_DEVICE); |
189 PLC_state |= PLC_STATE_PYTHON_FILE_OPENED; |
200 PLC_state |= PLC_STATE_PYTHON_FILE_OPENED; |
190 |
201 |
191 /* create WaitDebug_pipe */ |
202 /* create WaitDebug_pipe */ |
192 goto error; |
|
193 if(rt_pipe_create(&WaitDebug_pipe, "WaitDebug_pipe", WAITDEBUG_PIPE_MINOR, PIPE_SIZE) < 0) |
203 if(rt_pipe_create(&WaitDebug_pipe, "WaitDebug_pipe", WAITDEBUG_PIPE_MINOR, PIPE_SIZE) < 0) |
|
204 _startPLCLog(FO "WaitDebug_pipe real-time end"); |
194 PLC_state |= PLC_STATE_WAITDEBUG_PIPE_CREATED; |
205 PLC_state |= PLC_STATE_WAITDEBUG_PIPE_CREATED; |
195 |
206 |
196 /* open WaitDebug_pipe*/ |
207 /* open WaitDebug_pipe*/ |
197 if((WaitDebug_pipe_fd = open(WAITDEBUG_PIPE_DEVICE, O_RDWR)) == -1) goto error; |
208 if((WaitDebug_pipe_fd = open(WAITDEBUG_PIPE_DEVICE, O_RDWR)) == -1) |
|
209 _startPLCLog(FO WAITDEBUG_PIPE_DEVICE); |
198 PLC_state |= PLC_STATE_WAITDEBUG_FILE_OPENED; |
210 PLC_state |= PLC_STATE_WAITDEBUG_FILE_OPENED; |
199 |
211 |
200 /* create WaitPython_pipe */ |
212 /* create WaitPython_pipe */ |
201 goto error; |
|
202 if(rt_pipe_create(&WaitPython_pipe, "WaitPython_pipe", WAITPYTHON_PIPE_MINOR, PIPE_SIZE) < 0) |
213 if(rt_pipe_create(&WaitPython_pipe, "WaitPython_pipe", WAITPYTHON_PIPE_MINOR, PIPE_SIZE) < 0) |
|
214 _startPLCLog(FO "WaitPython_pipe real-time end"); |
203 PLC_state |= PLC_STATE_WAITPYTHON_PIPE_CREATED; |
215 PLC_state |= PLC_STATE_WAITPYTHON_PIPE_CREATED; |
204 |
216 |
205 /* open WaitPython_pipe*/ |
217 /* open WaitPython_pipe*/ |
206 if((WaitPython_pipe_fd = open(WAITPYTHON_PIPE_DEVICE, O_RDWR)) == -1) goto error; |
218 if((WaitPython_pipe_fd = open(WAITPYTHON_PIPE_DEVICE, O_RDWR)) == -1) |
|
219 _startPLCLog(FO WAITPYTHON_PIPE_DEVICE); |
207 PLC_state |= PLC_STATE_WAITPYTHON_FILE_OPENED; |
220 PLC_state |= PLC_STATE_WAITPYTHON_FILE_OPENED; |
208 |
221 |
209 /*** create PLC task ***/ |
222 /*** create PLC task ***/ |
210 if(rt_task_create(&PLC_task, "PLC_task", 0, 50, T_JOINABLE)) goto error; |
223 if(rt_task_create(&PLC_task, "PLC_task", 0, 50, T_JOINABLE)) |
|
224 _startPLCLog("Failed creating PLC task"); |
211 PLC_state |= PLC_STATE_TASK_CREATED; |
225 PLC_state |= PLC_STATE_TASK_CREATED; |
212 |
226 |
213 if(__init(argc,argv)) goto error; |
227 if(__init(argc,argv)) goto error; |
214 |
228 |
215 /* start PLC task */ |
229 /* start PLC task */ |
216 if(rt_task_start(&PLC_task, &PLC_task_proc, NULL)) goto error; |
230 if(rt_task_start(&PLC_task, &PLC_task_proc, NULL)) |
|
231 _startPLCLog("Failed starting PLC task"); |
217 |
232 |
218 return 0; |
233 return 0; |
219 |
234 |
220 error: |
235 error: |
221 |
236 |