#include <semaphore.h> /* Semaphores library header file */\r
#include <time.h>\r
#include <stdlib.h>\r
+ #include <unistd.h>\r
#include "%<modelName>.h" /* Model's header file */\r
#include "rtwtypes.h" /* MathWorks types */\r
%if extMode == 1\r
\r
%if extMode == 1\r
rtExtModeCheckEndTrigger();\r
- rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL),\r
- NUMST,\r
- (boolean_T *)&rtmGetStopRequested(RT_MDL));\r
%endif\r
\r
next.tv_sec += period.tv_sec;\r
sched_param.sched_priority = MAX_PRIO;\r
CHECK0(pthread_attr_setschedparam(&attr, &sched_param));\r
CHECK0(pthread_create(&base_rate_thread, &attr, base_rate, NULL));\r
+ CHECK0(pthread_attr_destroy(&attr));\r
+\r
+ %if extMode == 1\r
+ /* External mode */\r
+ while(rtmGetErrorStatus(%<modelName>_M) == NULL && !rtmGetStopRequested(%<modelName>_M)) {\r
+ rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL), NUMST, (boolean_T *)&rtmGetStopRequested(RT_MDL));\r
+ usleep(%<FEVAL("uint32", fundamentalStepSize * 1000000)>);\r
+ }\r
+ %endif\r
\r
/* Wait for threads to finish */\r
- CHECK0(pthread_attr_destroy(&attr));\r
pthread_join(base_rate_thread, NULL);\r
%foreach i = numSampleTimes\r
%if i == 0 || i == 1 && tid01Eq\r