How to use ssRegisterDataTypeInteger with Simulink Coder ?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Brieuc DANIEL
il 6 Gen 2021
Commentato: Brieuc DANIEL
il 14 Gen 2021
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
0 Commenti
Risposta accettata
Andy Bartlett
il 12 Gen 2021
Modificato: Andy Bartlett
il 12 Gen 2021
Hi
I've created an example for cases where the types can vary per instance of the s-function.
The core of the s-function is contained in a C code file and header.
This C file is shared between simulation and code generation.
This code recieves attributes of the input and output ports using a structure.
Based on the contents of these attribute structures the core code dispatches to the correct behavior for each instance.
The wrapper C code and TLC code for the s-function need to fill in the structures,
then call the core function.
How the attribute structures are filled in is distinct to C and TLC.
But the core all comes from the same C file and header.
The example shows one possible way to organize the port information and do the dispatching.
Using the same concept, use whatever specific way works best for your application.
-Andy
Più risposte (2)
Mikhail
il 11 Gen 2021
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.
Andy Bartlett
il 11 Gen 2021
Modificato: Andy Bartlett
il 11 Gen 2021
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
Andy Bartlett
il 12 Gen 2021
Hi Mikhail
>> I just wish ssRegisterDataTypeInteger was documented.
I've entered an documentation enhancement request. :-)
-Andy
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!