MATLAB Answers

0

libstruct does not create the complete struct

Asked by Jannis Carstens on 20 Sep 2018
Latest activity Commented on by Philip Borghesani on 24 Sep 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

  0 Comments

Sign in to comment.

Products


Release

R2017b

1 Answer

Answer by Philip Borghesani on 21 Sep 2018
 Accepted Answer

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 Comments

fieldnames showed all fields, regardless of any value assigned to any field. The inspector is definitely buggy!
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.

Sign in to comment.