From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

TDMS C DLL returns incorrect channel data type in MATLAB

Hello,

 

Within MATLAB 2018b, I'm attempting to use the TDMS C DLL to read images from a TDMS file that are stored as an array uint16's (data type 0x6). My first attempt at this was as follows:

 

inds  = startInd:(startInd + numImages - 1);
pImages = libpointer('uint16Ptr', zeros(1, numel(inds)*imageHeight*imageWidth));
status = calllib(libName, 'DDC_GetDataValues', channel.ID(groupInd, channelInd), (startInd-1)*imageHeight*imageWidth, numel(inds)*imageHeight*imageWidth-1, pImages);

 

However, this causes MATLAB to crash. I tried to dig into the problem by requesting the datatype for this channel using:

 

[status, dataType] = calllib(libName, 'DDC_GetDataType', channel.ID(groupInd, channelInd), 0);

 

and dataType returns 'DDC_Double', which corresponds to datatype 0xA. I've confirmed with my TDMS File Viewer that 'NI_DataType' for this channel is indeed set to 0x6 (uint16):

 

Screen Shot 2019-04-25 at 9.36.42 AM.png

 

 

 

 

 

 

 

 

But for some reason, the C DLL thinks that it is a double. If I modify the above snippet of code to initialize libpointer as a 'doublePtr', then my images are read correctly:

 

inds  = startInd:(startInd + numImages - 1);
pImages = libpointer('doublePtr', zeros(1, numel(inds)*imageHeight*imageWidth));
status = calllib(libName, 'DDC_GetDataValues', channel.ID(groupInd, channelInd), (startInd-1)*imageHeight*imageWidth, numel(inds)*imageHeight*imageWidth-1, pImages);

 

Can anyone help me understand what is going on here? I've noticed that within the C header file that comes with the DLL (nilibddc_m.h), it does not appear to support uint16 datatypes:

 

typedef enum {
    DDC_UInt8       = 5,    // unsigned char
    DDC_Int16       = 2,    // short
    DDC_Int32       = 3,    // int
    DDC_Float       = 9,    // float
    DDC_Double      = 10,   // double
    DDC_String      = 23,   // string
    DDC_Timestamp   = 30,   // timestamp (Year/Month/Day/Hour/Minute/Second/Millisecond components)
} DDCDataType;

 

If there is no support for uint16 data types, then I would expect it to crash or return an error, rather than declare it to be a double. Any help or insight would be much appreciated.

 

Thank you,

Erin

0 Kudos
Message 1 of 1
(1,796 Views)