Clear Filters
Clear Filters

Mask s-function with datatype selector and register datatype in s-function

2 views (last 30 days)
Hello,
I would like to mask an s-function with a datatype selector:
The datatype can to be selected be a standard matlab build in datatype, a bus or an enumeration.
How would I be able to retrieve the datatypeID of the selected datatype in the mask in the s-function and register it, so I can retrieve its size with ssGetDataTypeSize()?
Thank you in advance!
Kind regards,
Brecht
  2 Comments
Benjamin Thompson
Benjamin Thompson on 8 Feb 2022
Why does the mask care about the data type? The S-Function can get the data type by calling ssGetInputPortDataType, and get the size, and if you like that data type, you proceed. If you do not, call ssPrintf or ssSetErrorStatus.
Karel Viaene
Karel Viaene on 28 Feb 2022
It is an option to use the ssGetInputPortDataType or ssGetOutputPortDatatype. However that requires to always directly connect an output port which is fully defined. It is not possible in that case to directly connect a bus selector.
So the suggestion you did is certainly good, but it would be nice to select the datatype directly on the s-function using this mask. (Like you can do on eg. constant blocks).

Sign in to comment.

Answers (1)

Benjamin Thompson
Benjamin Thompson on 28 Feb 2022
Busses are treated a lot differently as Simulink marshals data to pass to or from an S-Function. So what you are describing cannot extend to busses. See the Busses section in the article "Configure C/C++ S-Function Features". For the other basic data types you can have the S-Function call ssGetInputPortDataType or ssGetOutputPortDatatype and use the result to determine how to handle the pointers you get when calling ssGetInputPortSignal or ssGetOutputPortSignal.

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!