Effacer les filtres
Effacer les filtres

Use FunctionCaller and C-Caller together

2 vues (au cours des 30 derniers jours)
Roman
Roman le 6 Mar 2024
Commenté : Yao Ren le 12 Mar 2024
I generate dem Function Caller is a .h file that I would like to call again via the C caller to simulate the function. But the simulation only works if the FunctionCaller is commented out. Does anyone know how I can solve this without having to comment out the FunctionCaller every time?
  1 commentaire
Yao Ren
Yao Ren le 12 Mar 2024
Hi Roman,
Could you clarify the following quoted statement in your question with more details?
"I generate dem Function Caller is a .h file ..."
  • What is "dem" referring to
  • Funciton Caller block is able to generate a function call to "asd()". C Caller needs the C function source code to make a call. Is the C function "asd()" hand written in a ".c" file? Or is it generated by another model?
  • What's the higher level goal for what you're trying to do
Thanks,
Yao

Connectez-vous pour commenter.

Réponses (1)

Hassaan
Hassaan le 6 Mar 2024
  1. Correct Prototype Matching: Ensure that the function prototype defined in the .h file matches the input and output specifications of the Function Caller block in Simulink.
  2. Multiple Definition Conflict: If the function is defined in multiple places (e.g., in both the .h file and somewhere within the Simulink model), this could cause a conflict. Make sure the function is only defined once.
  3. Model Configuration Parameters: Check the Simulink model configuration parameters for code generation. Ensure that the model is set up to include the .h file and that the function prototype is being imported correctly.
  4. Function Call Subsystem: If the function you're trying to call from the .h file is part of a Simulink Function block or a MATLAB Function block, ensure that the function call is set up correctly and that there are no naming conflicts.
  5. C Caller Block: If you are using the C Caller block, you need to make sure that the .h file is specified correctly in the block parameters and that the C Caller block is configured to match the function signature.
  6. Simulation Target vs. Code Generation Target: Sometimes, Simulink models are set up differently for simulation versus code generation. Check if there are any pre-processor directives (like #ifdef or #ifndef) in the .h file or the generated code that may be causing the code to be excluded during simulation.
  7. External Code Integration: Verify the settings under "Simulation Target > Custom Code" in the Simulink model configuration parameters to ensure that your .h file is correctly integrated and that the path is correct.
  8. Compiler and Linker Settings: Check the compiler and linker settings in the model configuration to ensure they are set up correctly to find and use the .h file during the build process.
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

Catégories

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

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by