libstruct does not create the complete struct

4 visualizaciones (últimos 30 días)
Jannis Carstens
Jannis Carstens el 20 de Sept. de 2018
Comentada: Philip Borghesani el 24 de Sept. de 2018
in the c-header file of the DLL, a struct is defined:
typedef struct FrameMetadata
{
unsigned short Size; // size of this structure
unsigned int Counter; // frame counter
unsigned int CounterHW; // frame counter hardware
long long Timestamp; // time stamp in UNITS (10000000 per second)
long long TimestampMedia;
TFlagState FlagState;
float TempChip;
float TempFlag;
float TempBox;
WORD PIFin[2];
// DI = PIFin[0] & 0x8000
// AI1 = PIFin[0] & 0x03FF
// AI2 = PIFin[1] & 0x03FF
}FrameMetadata;
now I want to create an instance of the struture using
myStruct = libstruct( 'FrameMetadata');
myStruct is created, but in the inspector, the struct lib.FrameMetadata has only for entries:
  • FlagState
  • TempChip
  • TempFlag
  • TempBox
Why does MATLAB skip all the other entries? When the DLL is loaded with it's c-header, no warnings or errors are shwon. In the inspector it is also possible to chose from the values of the TFlagState for the FlagState entry.
Regards, Jannis

Respuesta aceptada

Philip Borghesani
Philip Borghesani el 21 de Sept. de 2018
It appears that there is a bug in the inspector. It does not seem to show all fields of a libstruct. Try accessing the fields that don't appear to you in the inspector or use the fieldnames(myStruct) or get(myStruct) to see the different fields.
Remember that until data is assigned to at least one field of a libstruct it remains in an uninitialized (null) state and some fields may not act the way you expect them too.
I will report this bug but suggest you contact support for any updates or additional help.
  2 comentarios
Jannis Carstens
Jannis Carstens el 24 de Sept. de 2018
fieldnames showed all fields, regardless of any value assigned to any field. The inspector is definitely buggy!
Philip Borghesani
Philip Borghesani el 24 de Sept. de 2018
Long and unsigned long data types confuse the inspector. These types exist only for loadlibrary support and change size depending on the platform and 64/32 bit version of MATLAB.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by