LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

tdms dll interfacing

I mostly save my measurement data in TDMS nowadays. Now, a customer wants to read these files using the TDMS dll that is provided by NI on request.
Now, my customer complains he cannot get the dll to work. Supposedly returning an error almost instantaneously.
Anybody know the caveats of this dll?

XP, VC++ 8.0: error -6204: "An unexpected error occurred in the library."


Message Edited by aartjan on 11-28-2007 01:28 PM
0 Kudos
Message 1 of 9
(5,587 Views)
Hello,

I am, actually, Aard-Jan's customer. Let me take this opportunity to provide some more background information.

Below is my test program to read TDMS data:

// start of code snippet

#include <cstdio>
#include <cassert>

#include "nilibddc.h"

int main()
{
    int ddc_err;
    DDCFileHandle tdmsfile;

    ddc_err = DDC_OpenFileEx("testtdms.tdms", NULL, 1, &tdmsfile);
    printf("DDC_OpenFileEx result: %d\n", ddc_err);
    assert(ddc_err == DDC_NoError);

    // We never get here because the assert above fails

    ddc_err = DDC_CloseFile(tdmsfile);
    assert(ddc_err == DDC_NoError);

    return 0;
}

// end of code snippet


As Aard-Jan said, the DDC_OpenFileEx failes with error code -6204: "An unexpected error occurred in the library." This is on Windows XP, using Visual C++ Express 2005 (a.k.a. Visual C++ 8.0).

The error code suggests that at least the DLL function is being called, and that the test file is being found; I can make the function return -6209 ("File Not Found") by trying to open a non-existing file.

On Windows Vista, using Visual C++ Express 2008 (a.k.a. Visual C++ 9.0) I get different behavior. The very same program, with the very same call to DDC_OpenFileEx now gives me an error -6211: "The storage could not be opened".


I would very much appreciate it if anyone has useful hints on this. Even reports from people just saying that it works for them would be useful at this point.

0 Kudos
Message 2 of 9
(5,565 Views)
Aart-Jan: sorry for misspelling your name -- twice. Won't happen again, I promise ... 🙂

0 Kudos
Message 3 of 9
(5,563 Views)
Just a shot in the dark, but I feel your pain because I've found it surprisingly difficult to get at my TDMS data in Matlab with any sort of flexibility / elegance.   (Update: gave up for now.  Got to a point where my m-script ran to completion about 1 out of 5 tries with mostly but not entirely expected results.  The other 4 out of 5 tries it would stop prematurely at unpredictable locations.  Caveat -- I'm a total rookie with pointers in Matlab, but do have familiarity with them from olden-days C programming.)
 
Dunno know what the arguments NULL and 1 are for exactly, but I *think* I recall that from Matlab it was necessary to open in read-only mode.  Maybe the "1" specifies the mode and there are other values you can try?
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 9
(5,536 Views)
Hi Kevin,

The NULL is supposed to tell DDC_OpenFileEx that it should infer the file type from the extension; the 1 is to have the file opened in read-only mode. This I gathered from [url=http://zone.ni.com/reference/en-XX/help/370051H-01/cvi/cviddc_openfileex/]here[/url].

I agree that support for TDMS outside of Labview and friends seems, well, - lacking, at this point. In general, using proprietary file formats for storing something as rudimentary as measurement data seems like a distinctly bad idea, as it locks you in to a single vendor's toolset.

NI should really publish a spec of the TDMS format in order to ensure data accessibility for everyone, from any analysis tool, also in the future. Of course they won't - vendor lock-in doesn't seem so bad if you're the vendor, I guess... Smiley Sad

0 Kudos
Message 5 of 9
(5,528 Views)
FWIW, here's a more detailed description of the storage format.  The information density is quite high and frankly, I haven't put in a solid effort to grasp & apply it.  Maybe it'll help you though...
 
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 9
(5,523 Views)
Kevin, that's exceedingly useful for me -- many thanks. Seems I jumped the gun when I complained about the proprietaryness of the format -- silly me.

As I have a computer science background and have extensive experience in interpreting data format specs (I spent a year of my life doing precisely that for remote sensing applications), it seems quite feasible for me to just bite the bullet and implement a data reader based on the specification you pointed to.


I will keep you posted on my progress -- perhaps something will come out that is useful for you, too.

0 Kudos
Message 7 of 9
(5,519 Views)

reddish and aartjan,

I tried the code reddish posted on a clean Windows XP system with Visual Studio VC++ 2005 (aka VC++ 8.0) and nilibddc version 8.1 (nilibddc.dll actually shows a full version number of 8.1.1).  Your code ran fine with no errors opening a .tdms file I generated from a TDMS sample program that ships with LabWindows/CVI 8.5.

Are you using nilibddc version 8.1?  Only version 8.1 supports reading TDMS files.  The original version of nilibddc (version 8.0) does not.

If that isn't the problem, perhaps there is something specific about the .tdms file you are opening that might be causing the problem?  Maybe you can describe what software you used to create that file and either describe the contents of the file or post the file and we can go from there.

Hope that helps.

-Jeff

Message 8 of 9
(5,499 Views)
I love a happy ending 😉
Jeff, I don't think there's any peculiar properties to the subjected TDMS file. Reddish informed me he gladly writes his own parser. Fine by me, but not a good score for the dll in question.

Aart-Jan
0 Kudos
Message 9 of 9
(5,420 Views)