equal
deleted
inserted
replaced
64 rt_cond_signal(&timer_set); |
64 rt_cond_signal(&timer_set); |
65 } |
65 } |
66 |
66 |
67 void cleanup_all(void) |
67 void cleanup_all(void) |
68 { |
68 { |
|
69 if (rt_task_join(&timerloop_task) != 0){ |
|
70 printf("Failed to join with Timerloop task\n"); |
|
71 } |
69 rt_task_delete(&timerloop_task); |
72 rt_task_delete(&timerloop_task); |
70 } |
73 } |
71 |
74 |
72 /** |
75 /** |
73 * Clean all Semaphores, mutex, condition variable and main task |
76 * Clean all Semaphores, mutex, condition variable and main task |
76 { |
79 { |
77 rt_sem_delete(&CanFestival_mutex); |
80 rt_sem_delete(&CanFestival_mutex); |
78 rt_mutex_delete(&condition_mutex); |
81 rt_mutex_delete(&condition_mutex); |
79 rt_cond_delete(&timer_set); |
82 rt_cond_delete(&timer_set); |
80 rt_sem_delete(&control_task); |
83 rt_sem_delete(&control_task); |
|
84 if (rt_task_join(&timerloop_task) != 0){ |
|
85 printf("Failed to join with Timerloop task\n"); |
|
86 } |
81 rt_task_delete(&timerloop_task); |
87 rt_task_delete(&timerloop_task); |
82 } |
88 } |
83 |
89 |
84 /** |
90 /** |
85 * Take a semaphore |
91 * Take a semaphore |
163 |
169 |
164 char taskname[32]; |
170 char taskname[32]; |
165 snprintf(taskname, sizeof(taskname), "timerloop-%d", getpid()); |
171 snprintf(taskname, sizeof(taskname), "timerloop-%d", getpid()); |
166 |
172 |
167 /* create timerloop_task */ |
173 /* create timerloop_task */ |
168 ret = rt_task_create(&timerloop_task, taskname, 0, 50, 0); |
174 ret = rt_task_create(&timerloop_task, taskname, 0, 50, T_JOINABLE); |
169 if (ret) { |
175 if (ret) { |
170 printf("Failed to create timerloop_task, code %d\n",errno); |
176 printf("Failed to create timerloop_task, code %d\n",errno); |
171 return; |
177 return; |
172 } |
178 } |
173 |
179 |
197 char taskname[32]; |
203 char taskname[32]; |
198 snprintf(taskname, sizeof(taskname), "canloop%d-%d", id, getpid()); |
204 snprintf(taskname, sizeof(taskname), "canloop%d-%d", id, getpid()); |
199 id++; |
205 id++; |
200 |
206 |
201 /* create ReceiveLoop_task */ |
207 /* create ReceiveLoop_task */ |
202 ret = rt_task_create(ReceiveLoop_task,taskname,0,50,0); |
208 ret = rt_task_create(ReceiveLoop_task,taskname,0,50,T_JOINABLE); |
203 if (ret) { |
209 if (ret) { |
204 printf("Failed to create ReceiveLoop_task number %d, code %d\n", id, errno); |
210 printf("Failed to create ReceiveLoop_task number %d, code %d\n", id, errno); |
205 return; |
211 return; |
206 } |
212 } |
207 /* start ReceiveLoop_task */ |
213 /* start ReceiveLoop_task */ |
217 * Wait for the CAN Receiver Task end |
223 * Wait for the CAN Receiver Task end |
218 * @param *ReceiveLoop_task CAN receiver thread |
224 * @param *ReceiveLoop_task CAN receiver thread |
219 */ |
225 */ |
220 void WaitReceiveTaskEnd(TASK_HANDLE *ReceiveLoop_task) |
226 void WaitReceiveTaskEnd(TASK_HANDLE *ReceiveLoop_task) |
221 { |
227 { |
|
228 if (rt_task_join(ReceiveLoop_task) != 0){ |
|
229 printf("Failed to join with Receive task\n"); |
|
230 } |
222 rt_task_delete(ReceiveLoop_task); |
231 rt_task_delete(ReceiveLoop_task); |
223 } |
232 } |
224 |
233 |
225 /** |
234 /** |
226 * Set timer for the next wakeup |
235 * Set timer for the next wakeup |