Register datatype of inport in s-function
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I would like to link any signal to the inport of my s-function block and then use the ssGetDataTypeSize function onto the datatype of the inport to retrieve the size in bytes.
Currenlty I have a parameter on the s-function giving the name of the inport as a character array. For example 't_busTest'. Then I register that datatype in mdlInitializeSizes.
#define DATATYPE_CHAR (mxArrayToString(ssGetSFcnParam(S, 0)))
// Get data type of input and register
DTypeId idDataType; // = ssGetInputPortDataType(S, 0); (does not work)
ssRegisterTypeFromNamedObject(S, DATATYPE_CHAR, &idDataType);
Perferably, I would not need to have this parameter and I can retrieve the datatype from the inport, register it in the s-function and call the ssGetDataTypeSize. Is there a way to achieve this?
Thank you in advance!
Kind regards,
brecht
0 commentaires
Réponses (1)
Vidip
le 20 Déc 2023
I understand that you want to link any signal to the inport of your s-function block and then retrieve the size based on the datatype.
You can use ‘ssGetInputPortWidth’, this function directly returns the number of elements in the data type of the specified input port. You can multiply this element count by the size of each element (known based on the data type) to get the total size in bytes and ‘ssGetInputPortDataType’ can be used to get the data type of the inport.
For further information, refer to the documentation links below:
0 commentaires
Voir également
Catégories
En savoir plus sur Configure Block Features for MATLAB S-Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!