Clear Filters
Clear Filters

Array of struct as S-Function output

1 view (last 30 days)
Manuel Stumpf
Manuel Stumpf on 8 May 2019
Hello,
I'm trying to output an structure array from my S-Function. The data comes from a shared memory which gives an easy access via pointer.
This code didn't work:
static void mdlOutputs(SimStruct *S, int_T tid)
{
StructType *struct = (StructType *) ssGetOutputPortSignal(S, 0);
// Info: Outport 0 has a width of 10
{
// Access to shared memory
scoped_lock<named_mutex> lock(CM_ADTF_mtx); // lock access to shared memory for other processes
ListType * ShM_List = managed_shm.find_or_construct<ListType>("CM_ADTF_List")();
memcpy(EnvMdlObj, ShM_objList->EnvMdlObj, 10*sizeof(StructType));
// also not working:
// EnvMdlObj[0] = ShM_List->EnvMdlObj[0];
// EnvMdlObj[1] = ShM_List->EnvMdlObj[1];
}
} /* end mdlOutputs */
I get the first element without a problem, but the follwing elements seem to be random memory.
How do I get access to the elements of a bus type outport vector?

Answers (0)

Categories

Find more on Block and Blockset Authoring 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!