Array of struct as S-Function output

1 visualizzazione (ultimi 30 giorni)
Manuel Stumpf
Manuel Stumpf il 8 Mag 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?

Risposte (0)

Categorie

Scopri di più su Prepare Model Inputs and Outputs in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by