C or C++ Code Generation and Integration in Stateflow

Hi,

I made the second succes.
I managed to integrate Arduino function calls into the Stateflow chart and built and downloaded working executable to the hardware.

Previously I succesfully integrated function calls trough the "Code generation /Coustom code" pane of the simulink.

The root cause of my problem the multi level code generation and the different toolchains what the Simulink is using on the levels.

As is learnt there is atleas four session of code making in the Simulink.

session product tool

  1. s-function building. stateflow chart -->> s-function (Probably Simulink coder)
  2. source code generation for simulation s-functions --> Simulink code (Probably VISUAL STUDIO C++)
  3. Source code generation for the target Simulink code --> C source for Arduino (Probably GCC C)
  4. Building executable for target C source for Arduino --> elf (surely GCC)

Please correct me if my list is wrong.

My previous attempts stucked at level 1 and 2

I've had a "dirty" idea and I made three files: wrapper.h; wrapper.cpp; dummy_wrapper.cpp
dummy_wrapper.cpp includes only empty functions in same name as in wrapper.cpp
I included the dummy for 1. and 2. session in "Simulation Target /Custom code" pane.
And included the real wrapper and the library file (actually LiquidCrystal.cpp ) in Code generation/Custom code pane for the 3. and 4.

The quick and dirty way always works :slight_smile:

Now I have working executable. And I can manipulate the calls freely in my model. I'm really proffesional with Simulink. I can create 5000 lines usefull working code from the zero under half a day. (Place of self advert)

ps:
The project is far from the perfection yet because, obviously, the simulation runs with empty functions.
For me its no matter yet because at the beginning I'd like to use Display and Ethernet as monitoring outputs in real runnings.
But I'm going to continue. I'll be back.

Pm for deatils!