libstruct does not create the complete struct
2 views (last 30 days)
Show older comments
Jannis Carstens
on 20 Sep 2018
Commented: 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
Accepted Answer
Philip Borghesani
on 21 Sep 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 Comments
Philip Borghesani
on 24 Sep 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.
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!