Errors with ext_work.c file generated with Simulink Coder

3 vues (au cours des 30 derniers jours)
Matthew AY
Matthew AY le 25 Sep 2021
Hello,
I am working within a team that is attempting to generate C code using Simulink Coder.
When we attempt to generate code using the sldrt.tlc System Target File, it does not generate an executable file. In order to mitigate this issue, we are attempting to compile the C source code that was generated with Simulink Coder. We are using gcc/clang.
However, we are running into an issue with compiling. When attempting to compile the file ext_work.c, numerous errors are generated.
The most common error is:
ext_work.c:126:1: error: expected identifier or '('
{
^
This error is associated with the following code snippet:
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 */
I have checked the file for missing curly brakets, but did not find any. The file appears "correct".
I have attached a .txt document with the entire terminal output.
I have also atttached ext_work.c and ext_work.h as .txt files. In order to post the .c and .h files, they had to be coverted to .txt files and their names changed to avoid being named the same thing. Aside from that, the files have been unedited from their original generated state.
The user in this post/thread described the same issue. However, the post/thread does not offer a solution for this issue.
Could someone help with this issue?
Thank you!
Matt

Réponses (1)

Harsh
Harsh le 9 Jan 2025
Hi Matthew,
There is not any issue with the curly brackets in the generated code while it may appear so because of the error message. Upon inspecting the error log and code files, it seems that you are not able to compile the C code because of mismatch between the definition of a macro in the header file and its usage in the C code.
For example, in the header file the following macro is defined
#define rtExtModeCheckEndTrigger() /* do nothing */
But in the C code the above function is used as follows:
void rtExtModeCheckEndTrigger(void)
{
#ifndef EXTMODE_DISABLESIGNALMONITORING
rt_UploadCheckEndTrigger();
#endif
}
This leads to an error because the definition of “rtExtModeCheckEndTriggermacro does not expect an input but in the C code an input is passed.
To resolve these errors, you can modify the definition in header file. You can also change the implementation of the function wherever valid.
Also to create an executable target application please refer to the following documentation - https://www.mathworks.com/help/releases/R2021a/sldrt/ug/prepare-external-mode-application.html

Catégories

En savoir plus sur Simulink Coder dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by