Array of struct as S-Function output

1 次查看(过去 30 天)
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?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Block and Blockset Authoring 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by