Info

This question is closed. Reopen it to edit or answer.

Using a C++ class support library in a Simulink model

1 view (last 30 days)
Andrew
Andrew on 22 Jan 2016
Closed: MATLAB Answer Bot on 20 Aug 2021
I have a project where I am coding an Arduino in Simulink. Among other things, the Arduino is communicating with other devices via a CAN bus shield. The shield came with a C++ support library. This library is setup as a class with member functions for initialization of the shield, checking for errors, sending/recieving messages, etc.
I know that the S-block builder can be used to include C++ code in Simulink however if I declare the class every time the s-block is called, then the constructor for the class would be called and the shield will reinitialize. This is a problem because this would clear the buffer on the shield, erasing all the messages.
I need to find a way to declare the class somewhere in the Simulink model and then be able to call that class's member functions elsewhere in my Simulink model.
Any suggestions would be greatly appreciated, thanks.

Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!