Problem with C-Caller

14 views (last 30 days)
paolo dini
paolo dini on 1 Aug 2023
Commented: paolo dini on 11 Aug 2023
Hello everyone,
i am just traing to use the C-caller, in very simple way actually but i have encauntered issue already for this simple exercse.
I have the following situation. In the same folder a created:
1) "my_functions.c" with the following content:
#include "my_functions.h"
void my_function_1 (int A, float B, double* C){
*C = A*B;}
int my_function_2 (int A, int B){
return A + B;}
2) "my_functions.h" with the following content:
void my_function_1 (int, float, double*);
int my_function_2 (int, int);
(Actually i have tried also with "external" before the functions prototypes, but it does not works).
3) "esempio_c_caller.slx" where i use the C-caller block.
Actually the code i have the follwing message in the diagnostic viewer when compile my code "Parsing Custom Code in model:'esempio_C_caller' successful." and in fact the c-caller adapt it form on the function i select from the mask interface.
The problem is the folowing, calling for example, my_function_2() connecting sin wave blocks (connected with data type conversion block...) and try to plot the sum, the resulting signal is always equal to zero.
Have you some suggestion?
If i forgot something to secting in the configuration, in order to use C code during simulation?
or other things...
Thanks for attention to All in advance!
PS: i use 2018b version in this case, but i have installe also more recent version (2020b + 2022b) so if workaround is change the version, could be not an issue for me.

Answers (1)

David Balbuena
David Balbuena on 10 Aug 2023
Your model runs and produces results on my end. It's possible that the scope is not scaled properly for you to see the output. Try clicking the auto-scale button to see if that changes anything:
  1 Comment
paolo dini
paolo dini on 11 Aug 2023
Dear David,
first of all, thanks to spent some of your time to check for my issue.
Actually the problem was the extension of the "file.C", as you can notice, what i have uploaded is a "file.C.txt", wich is not recognised as C file from my file system.
I solved forced the extension from terminal (cmd).
I know was a stupid issue after all.
Thanks again!!
Best,
Pierpaolo.

Sign in to comment.

Categories

Find more on Configure and View Diagnostics in Help Center and File Exchange

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!