Array of struct as S-Function output
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Prepare Model Inputs and Outputs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!