From 5e8581907b09ab875106677d78039a14e369ffb8 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Fri, 12 Jul 2013 10:50:33 +0200 Subject: [PATCH] Move ext mode communiction out of the real-time thread --- ert_linux/ert_linux_multitasking_main.tlc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ert_linux/ert_linux_multitasking_main.tlc b/ert_linux/ert_linux_multitasking_main.tlc index aa40ed1..96e7fd0 100644 --- a/ert_linux/ert_linux_multitasking_main.tlc +++ b/ert_linux/ert_linux_multitasking_main.tlc @@ -34,6 +34,7 @@ #include /* Semaphores library header file */ #include #include + #include #include "%.h" /* Model's header file */ #include "rtwtypes.h" /* MathWorks types */ %if extMode == 1 @@ -178,9 +179,6 @@ %if extMode == 1 rtExtModeCheckEndTrigger(); - rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL), - NUMST, - (boolean_T *)&rtmGetStopRequested(RT_MDL)); %endif next.tv_sec += period.tv_sec; @@ -255,9 +253,17 @@ sched_param.sched_priority = MAX_PRIO; CHECK0(pthread_attr_setschedparam(&attr, &sched_param)); CHECK0(pthread_create(&base_rate_thread, &attr, base_rate, NULL)); + CHECK0(pthread_attr_destroy(&attr)); + + %if extMode == 1 + /* External mode */ + while(rtmGetErrorStatus(%_M) == NULL && !rtmGetStopRequested(%_M)) { + rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL), NUMST, (boolean_T *)&rtmGetStopRequested(RT_MDL)); + usleep(%); + } + %endif /* Wait for threads to finish */ - CHECK0(pthread_attr_destroy(&attr)); pthread_join(base_rate_thread, NULL); %foreach i = numSampleTimes %if i == 0 || i == 1 && tid01Eq -- 2.39.2