I'm building my first s-function block from compiled C code. Everything is going fine, except that the s-function block demands that its interface variables are of type double
, even though the underlying C interface variables are not. The block raises an error if I connect a boolean signal to the input and try to run.
I'm getting the variables in the code by calling ssGetInputPortSignal
and ssGetOutputPortSignal
, and casting the void pointers they return into the correct pointer types.
How do I configure the types of an s-function block's parameters in Simulink?
Take a look at ssSetInputPortDataType. Needs to be called in the S-Function mdlInitializeSizes
function. In your case you'll need something like:
ssSetInputPortDataType(S, 0, SS_BOOLEAN);
Assuming the input port is the first one and you're not concerned about the return value.
The function for the outputs is ssSetOutputPortDataType, with identical use.