Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Reading and Writing TDM/TDMS Files

Is there an example for modifying headers of TDMS files with the TDM C DLL? I can read the data just fine.  And, there are examples provided for creating new files/channels.  But what about modifying existing groupchannel parameters? 


In particular, I am interesting in using MATLAB to set a channel name.  From the header file, I understand I should use the DDC_SetChannelPropertyV and that the property should be "name."



int __stdcall DDC_SetChannelPropertyV (DDCChannelHandle channel,
                                       const char *property,
                                       va_list args);



I am getting hung up on va_list.  I understand this is dependent on the parameter being set, and there are methods to create additional parameters.  For exmaple, must I submit a length or data type along with my string?  Could someone just explicitly list the args and types for the known parameters:



// Channel property constants
#define DDC_CHANNEL_NAME                "name"                // Name
#define DDC_CHANNEL_DESCRIPTION            "description"        // Description
#define DDC_CHANNEL_UNIT_STRING            "unit_string"        // Unit String
#define DDC_CHANNEL_MINIMUM                "minimum"            // Minimum
#define DDC_CHANNEL_MAXIMUM                "maximum"            // Maximum



Writing out a "c" function call to the function above would be a bonus.  I figure if I know what they are, I can modify the *.h file to get MATLAB to understand the data type expected by the DLL.  As it is, all I can get MATLAB to do is crash.


0 Kudos
Message 1 of 10

Hello allbusiness,


Are you using hardware that you got from National Insrtuments?  If so, what is the model number of your hardware?


Best wishes,

Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 2 of 10

USB-6255 BNC



0 Kudos
Message 3 of 10

Hello allbusiness,


If you are programming in C, you would have to make separate function calls for each DDC channel property that you would want to set.  For example, a function call to set the DDC channel name to My DDC Channel might look like this...


int    DDC_SetChannelProperty (DDCChannelHandle channel, DDC_Channel_Name, My DDC Channel);



Wallace F.

National Instruments
Applications Engineer
0 Kudos
Message 4 of 10

Dear all

I am facing a similar problem.

I am creating TDMS files with matlab (similar to the example using the 64-bit version of the TDM-C-DLL that can be found here:


I would like to add a property to my TDMS file. I have tried using

DDC_CreateFilePropertyV and DDC_SetFilePropertyV



calllib('nilibddc','DDC_CreateFilePropertyV',pfile.Value, libpointer('stringPtr','mypropertyname'),'DDC_Double', num2str(16));


without success (depending on the data type either matlab crashes or the proporty is set to a wrong value). I'm not sure if I am correctly passing the required "va_list" (last argument) via matlab.

Using "DDC_CreateFileProperty" (without "V") might solve my problem. However, this function is not implemented in the 64-bit version of the TDM-C_DLL.


Does anybody know how to solve this problem?






0 Kudos
Message 5 of 10

Howdy Bertram!


I need to begin this by saying that the TDM DLL is provided as is and without official support so the amount of help I can give is very limited.  I only have access to the same documentation you have from downloading the TDM-C-DLL files you linked.


That being said, I did glance over the included help documentation and the header file.  I did not see any reference to DDC_CreateFilePropertyV in the help doc, though it did appear in the header file.


Why did you chose to use the "V" version of that function?


Where do you see/how do you know that the "non-V" version of the function is not implemented in the 64-bit version of the DLL?


Have you tried using the DDC_CreateFilePropertyDouble() function instead since you are trying to create a double?


I apologize that I don't have a deeper insight into this library.



Applications Engineering
National Instruments
0 Kudos
Message 6 of 10

Hello Barron


Thanks for your fast reply!

All functions are actually implemented for the 64-bit Version. However, the matlab function 'calllib' does not work with the header file (nilibddc.h) provided with the 2010 version (64-bit and 32-bit). Instead I had used the reduced header file (nilibddc_m.h) that came along with the matlab TDMS example. This works, but not all methods are available.

I now solved the problem by adding the type-safe DDC_CreateFilePropertyDouble() etc. that you suggested to the header file - (adding DDC_CreateFileProperty(..) to the header file will cause matlab to crash). I attached the new header file for other users.

Thanks again - your reply was of great help 🙂




0 Kudos
Message 7 of 10

Awesome! I'm glad to know that worked! Smiley Happy


Thanks for posting your modified header file for others to use in future.



Applications Engineering
National Instruments
0 Kudos
Message 8 of 10

I am trying to write TDM/TDMS files using nilibddc.dll on an old Visual C6 project (that I cant afford to update at this time) under Windows XP.

I am using an older version of the nilibddc.dll ( and it works if I ignore the error message (-6202) I get from nilibddc.dll/DDC_CreateChannelGroupPropertyTimestampComponents().


I am making all the other calls as shown in the example libary code.

And I am providing the argument types as called for in the header so I am completely puzzled by this behaviour.


Not sure I should ignore the error message but I dont know what to do to fix this.

Anyone else run into this out there?




PS. I tried using the latest library but had a link error I couldnt figure out on VC6.0.

nilibddc.lib(implib.obj) : error LNK2001: unresolved external symbol ___security_cookie

nilibddc.lib(implib.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4

Debug/Test TDM.exe : fatal error LNK1120: 2 unresolved externals


0 Kudos
Message 9 of 10

I figured this out myself ... in case anyone else runs into this.


I didnt realize that there are specific property tags - i found noticed the string "DDC_Timestamp" referred to in the only references I could find and tried it instead of my own property name ...


        sprintf(szCHANNEL_NAME,"DDC_Timestamp"); // y160618 Note: when this was "Time Recorded", the

                                                                                                // DDC_CreateChannelGroupPropertyTimestampComponents() func returned -6202
        ddcError = DDC_CreateChannelGroupPropertyTimestampComponents (hgroup,
                                                                  (unsigned int)year,
                                                                  (unsigned int)month,
                                                                  (unsigned int)days,
                                                                  (unsigned int)hours,
                                                                  (unsigned int)minutes,
                                                                  (unsigned int)wholeseconds,

Thanks to anyone who notices this posting and I hope my answer helps someone.



0 Kudos
Message 10 of 10