Printing outputs when running C code in simulink via the coder.ceval function

1 回表示 (過去 30 日間)
John Doe
John Doe 2020 年 9 月 23 日
回答済み: Peter O 2020 年 9 月 24 日
Hi
I am running some C code in simulink via the coder.ceval. The code is somewhat complex, and originally printed outputs to a seperate file via writef, and error messages via fprintf. How would i go about printing the fprintf messages to some sort of consol when running it in simulink? It doesnt have to be a consol per say, but having some sort of message to the user for troubleshooting is neccisary.

回答 (1 件)

Peter O
Peter O 2020 年 9 月 24 日
Not completely sure about this one, but if there is there a way to access the Simulink diagnostics panel from within the C code, that might be a nice place to put it:
If there's a way to pass in the function pointer reference to sldiagviewer.reportInfo(Message), you might be able to do that, but I don't know if Simulink is designed to handle external calls to that function. (I wouldn't bet on it working.) If you're able to wait for the C function to return to display the message, then you could probably make a field in the cfunc's return variable (or in one of its pass-by-ref arguments) that holds the diagnostics info/codes/messages, and use a little MATLAB glue code after it returns to call reportInfo().

カテゴリ

Help Center および File ExchangeMATLAB Coder についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by