Simulink build errors while building with custom code for target device - Cannot find standard library header files in custom code.

조회 수: 22 (최근 30일)
Background
I am trying to use Simulink in hardware mode to connect to a power board. For this I am building a model to a (Raspberry Pi using the Simulink Support Package for Raspberry Pi Hardware - 20.2.2) with custom c code driver files supplied with the power board which should allow communication over USB from the Pi to the board. A C-Caller block is being used currently in the simulink model which should just send a reset command to the board as a test of the model compiling and running on the Pi. I have been able to run simple tests to ensure that a model using the support package, and simple C programs can be run on the Pi.
Problem
When using the C_Caller block I must include the main header file, to access the needed functions, and all source files for the driver in Configuration Parameters -> Simulation Target.
The toolchain used to compile is the default for the Pi Support package, GNU GCC Raspberry Pi:
When testing by running Moniter & Tune, the build error occurs:
Error(s) encountered while building custom code simulation target for model 'test_model'. Fix the errors in your custom code or disable 'Import custom code' if your custom code has incompatibilities.
Caused by:
  • c:\filepath\ComPort\ComPort.c:4:21: fatal error: termios.h: No such file or directory #include <termios.h> ^ compilation terminated.
I think that this means that the compiler does not have access to a certain standard library that contains this file. The file termios.h is included in the GNU C Library (glibc), and therefore I believe this problem could be resolved by ensuring this library is included in the compiler, but I am completely unsure how to do this, and getting further out of my depth!
Advice very welcome.
  댓글 수: 1
Nathan Wenban
Nathan Wenban 2021년 2월 23일
Hi again Prasanth,
I have had some success at overcoming my own problem and would like to know whether it seems a sensible thing to do:
To enable the C Caller block to find my desired function, I have created a duplicate dummy source file that contains blank functions with the same inputs outputs etc. This source file is called in Configuration Parameters -> Simulation Target. This enables the code to run in simulation by using the dummy file, and in hardware using the real files.
Thanks once again,
Nathan

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

채택된 답변

Prasanth Sunkara
Prasanth Sunkara 2021년 2월 18일
이동: Stefanie Schwarz 2023년 2월 7일
Hi Nathan,
Since we are building this model on raspberry pi, instead on the host PC, we need to add the custom code information in Configration Parameters -> Code Generation -> Custom Code. At this location, please enter the same information you have entered in "Simulation Target" section. Finally, you can delete all the inforamtion you have entered in "Simulation Target".
Let me know if it works!
Cheers,
Prasanth
  댓글 수: 2
Nathan Wenban
Nathan Wenban 2021년 2월 23일
이동: Stefanie Schwarz 2023년 2월 7일
Hi Prasanth,
Thanks for getting back and for the advice. The code now builds on the Raspberry Pi, however I cannot seem to access my functions for use with the 'c caller' block. When refreshing custom code to search for function names in the c caller block I get the following error:
C Caller block 'model_tests/C Caller' requires model to have associated importable custom code. There is no custom code specified, or 'Import custom code' is disabled.
Suggested actions to import custom code take me to the Configuration Parameters -> Simulation Target tab where I have removed all the info.
Any advice on this would be great.
Thanks,
Nathan
Clemens K
Clemens K 2021년 10월 19일
이동: Stefanie Schwarz 2023년 2월 7일
Hello Nathan,
thank you for your quick-fix on that topic. Helped a lot!
Have you already found out another work-around to this issue?
Kind regards
Clemens

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by