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

2 次查看(过去 30 天)
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 个评论
Benjamin Thompson
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 2022-2-28
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).

请先登录,再进行评论。

回答(1 个)

Benjamin Thompson
Benjamin Thompson 2022-2-28
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.

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by