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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Prepare Model Inputs and Outputs 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!