ssGetBusElementOffset
Get the offset from the start of the bus data type to a bus element
Syntax
int_T ssGetBusElementOffset(SimStruct* S, int_T busTypeID, int_T elemIdx)
Arguments
S
SimStruct that represents an S-Function block
busTypeID
The bus data type identifier that represents the bus signal
elemIdx
The zero-based bus element index
Returns
int_T
Description
Use to get the offset, in bytes, from the start of the bus data type to the bus
element that you specify and to obtain a pointer to the memory location of the bus
element. The ssGetBusElementOffset
S-function accounts for the
data type, complexity, dimensions, and any padding between the start of the bus
signal and the bus element that you specify.
Languages
C, C++
Examples
static void mdlOutputs(SimStruct *S, int_T tid) { DTypeId dType = ssGetOutputPortDataType(S, 0); const void *u = ssGetInputPortSignal(S, 0); int numElems = ssGetNumBusElements(S, dType); int i; for(i=0; i<numElems; i++) { int_T offset = ssGetBusElementOffset(S, dType, i); /* Assume that the bus element is of type double */ const double *in = (const double*) ((const char*)u + offset); } }
See Also
Version History
Introduced in R2010a