How to use ssRegisterDataTypeInteger with Simulink Coder ?
Mostra commenti meno recenti
Hi everyone,
I'm struggling for a while now (about a month) to use the ssRegisterDataTypeInteger function in my app. I had to test it out of my application to find the issue. When i'm running my s-function using ssRegisterDataTypeInteger (libfixedpoint) through Simulink it works perfectly. Then I'm building with simulink (C Code -> Build), it's working almost like a charm (had some issues with linking libfixedpoint.lib but seems to be solved), and when i'm trying to run the resulting .exe it's failing when calling ssRegisterDataTypeInteger, any clue about what's going on here ?
I've also tried the proposition of Mikhail on the following thread and it has given me the same behaviour :
https://fr.mathworks.com/matlabcentral/answers/345944-how-to-create-64-bit-integer-data-type-in-simulink
Risposta accettata
Più risposte (2)
Mikhail
il 11 Gen 2021
0 voti
Hi Brieuc,
As I mentioned in the thread you've linked to (https://www.mathworks.com/matlabcentral/answers/345944-how-to-create-64-bit-integer-data-type-in-simulink#comment_850989)
4) And the worst. The S-Function using 64 bits data types must be inlined (this is from my experience, please tell me I'm wrong) for target-based builds. I'm not against throwing in some TLC, but I would really prefer not to inline S-Function in some cases. This also makes this API less capable than true built-in data types, where I don't have to worry about it.
So this might be problem.
But I can't tell fo sure unless you provide some reproduction steps and specific error messages.
1 Commento
Brieuc DANIEL
il 11 Gen 2021
Andy Bartlett
il 11 Gen 2021
Modificato: Andy Bartlett
il 11 Gen 2021
0 voti
Hi
A low effort way to inline an s-function is to use "wrapping".
The general concept of "wrapping" an s-function is described here.
I've created an example that is more specific to use of integer types including int64.
Please note, this example only covers cases where the inner function being wrapped has a statically typed interface. Such as the github example.
uint64_t func_core_hybrid_add(uint64_t const a, uint32_t const b);
In other words, no polymorphism via void pointers or such.
If you need an interface that handles port types that are different for different instances of the s-function, that can be wrapped too. But that needs a different wrapping technique.
-Andy
8 Commenti
Brieuc DANIEL
il 11 Gen 2021
Andy Bartlett
il 11 Gen 2021
Hi,
S-Functions are inlined for several purposes.
Depending on the purpose, different licenses are required.
For simulation of a model in accelerator mode, Coder licenses are NOT required.
To build stand-alone C (C Code -> Build),
for Generic Real-Time target (GRT)
MATLAB Coder and Simulink Coder are required
for Embedded Real-Time target (ERT)
Embedded Coder, MATLAB Coder and Simulink Coder are required.
The example model was configured to use ERT target hence the need for all 3 C Coder licenses.
I've uploaded a change to GitHub to use GRT.
For building standalone C code, that will not require Embedded Coder,
but will require Simulink Coder and MATLAB coder for the (C Code -> Build)
-Andy
Brieuc DANIEL
il 11 Gen 2021
Mikhail
il 12 Gen 2021
Thanks Andy!
I just wish ssRegisterDataTypeInteger was documented.
Brieuc DANIEL
il 12 Gen 2021
Andy Bartlett
il 12 Gen 2021
Hi B.Daniel,
Clarifying question:
>> I need to handle port types
Does this mean different instances of your s-function handle different port data types?
For example, suppose your s-function is in two places
myModel/mySfunBlockInstance1
myModel/mySfunBlockInstance2
and in both cases the block has two inputs and one output.
The 1st instance might have port data types uint8, int16, int32.
The 2nd instance might have a different set of port data types such as uint64, uint64, uint64.
Is that a correct understanding?
-Andy
Andy Bartlett
il 12 Gen 2021
Hi Mikhail
>> I just wish ssRegisterDataTypeInteger was documented.
I've entered an documentation enhancement request. :-)
-Andy
Brieuc DANIEL
il 12 Gen 2021
Categorie
Scopri di più su Simulink Coder in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!