External Mode for a custom STF

I'm trying to incorporate external mode for a custom target that I built. One of the files I include (ext_work.c) keeps giving me an error when I compile. This is just a snippet of the code that includes a full function:
void rtExtModePauseIfNeeded(RTWExtModeInfo *ei,
int_T numSampTimes,
boolean_T *stopReqPtr)
{
while((modelStatus == TARGET_STATUS_PAUSED) && !startModel && !(*stopReqPtr)) {
rt_ExtModeSleep(0L, 375000L);
rt_PktServerWork(ei,numSampTimes,stopReqPtr);
#ifndef EXTMODE_DISABLESIGNALMONITORING
rt_UploadServerWork(numSampTimes);
#endif
}
startModel = false; /* reset to false - if we were stepped we want to
* stop again next time we get
* back here.
*/
} /* end rtExtModePauseIfNeeded */
When I try to compile, I get the following error:
ext_work.c:127:8: error: expected identifier or '(' before '{' token
(line 127 refers to the 4th line of the sample code).
Can anyone help with what might be wrong?
Many thanks!

댓글 수: 1

Walter Roberson
Walter Roberson 2016년 12월 25일
My suspicion is that the actual problem is just before that line, if it thinks that it is still inside a function definition.

댓글을 달려면 로그인하십시오.

답변 (1개)

John BG
John BG 2016년 12월 24일

0 개 추천

have you tried either
removing the ')' at the end of the previous line pointed by the error, the line ending with boolean_T *stopReqPtr
pairing the ')' of line boolean_T *stopReqPtr) with '('
if you find these lines useful would you please mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help, click on the thumbs-up vote link,
thanks in advance for time and attention
John BG

댓글 수: 5

Well no the parenthesis is paired since this:
void rtExtModePauseIfNeeded(RTWExtModeInfo *ei,
int_T numSampTimes,
boolean_T *stopReqPtr)
is the same as this:
void rtExtModePauseIfNeeded(RTWExtModeInfo *ei, int_T numSampTimes, boolean_T *stopReqPtr)
I also can't remove it since its the function decleration
John BG
John BG 2016년 12월 27일
편집: John BG 2016년 12월 27일
ok,
in the function declaration try
adding 3 dots after each comma remove the 'void' remove the pointer '*' declare inside the function
rtExtModePauseIfNeeded( ei,...
numSampTimes,...
stopReqPtr)
in MATLAB you don't need that, and the comment character is '%' .
for just
  • call rt_ExtModeSleep
  • call rt_PktServerWork
  • if EXTMODE_DISABLESIGNALMONITORING
  • call rt_UploadServerWork
Why are you writing C code anyway, because you want this function to be called by a MATLAB function?
can you show the MATLAB function that calls this c function and how do you declare in MATLAB the variables that you are using here?
Walter Roberson
Walter Roberson 2016년 12월 27일
All those removals proposed are not appropriate under the circumstances. This is C code being invoked from Simulink as part of a custom real time deployment and it should not be rewritten in MATLAB.
John BG
John BG 2017년 1월 4일
ok, thanks for explaining
Michael
Michael 2021년 9월 27일
@Giorgi Did you ever resolve this issue. We are facing a similar problem.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 View and Analyze Simulation Results에 대해 자세히 알아보기

질문:

2016년 12월 24일

댓글:

2021년 9월 27일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by