Register datatype of inport in s-function
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Vidip
on 20 Dec 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 Comments
See Also
Categories
Find more on Configure Block Features for MATLAB S-Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!