0

I know that it is possible to create S-function from C code that I provide. But is it possible to create one S-function from C Code, which is generated from a Simulink Model for dSPACE ECUs, with low effort. The reason is, I am trying to test the dspace code with matlab/simulink. Furthermore I'm aksing because the generated code from this simulink model consists multiple .c and .h files and I don't know how to integrate these files in one s-function block.

Daniel
  • 36,610
  • 3
  • 36
  • 69
d4rty
  • 3,970
  • 5
  • 34
  • 73
  • Why? Running your tests this way you can only test a very minor part of the code because many specific features (Task handling, IO blocks, interrupts and a lot of other stuff) can not be compiled on your system. Further, if you end up with some malfunction, is it a malfunction because the code is wrong or because it was simply not designed for a X86-64 platform? My strong recommendation, test it really and run it on the ECU or trust the generator and test only your model. – Daniel Jan 20 '16 at 00:21

1 Answers1

1

There are several methods of doing this. I suggest using the Legacy Code Tool as its structure helps to guide you through the process. You could also explore calling the function(s) from Stateflow or a Matlab Function block depending on the application.

With respect to multiple c/h files. I assume they will all need to be visible to Matlab through pointing to the source paths, but you should be able to identify the 'entry' function that you're interested in and utilize that in your model.

Jeremy Mangas
  • 361
  • 1
  • 8