DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

nilibddc dll: opening tdms files with corrupt index files

Solved!
Go to solution

Hi there,

 

i have a question regarding error handling, when using the nilibddc.dll.

 

I want to use nilibddc.dll to open .tdms files. At the time i'm experimenting with some error cases and got stuck in one case:

When i try to open a .tdms file with a corrupt .tdms_index file i get the error code -6211 (DDC_StorageCouldNotBeOpened).

The .tdms_index file is corrupt because of errors while copying the file.

 

The problem i noticed is, that i have a file lock on the corrupt .tdms_index file after DDC_OpenFile(...) (i can rename it, but i can't delete the file!?).

 

As you can see in the code snippet - it isn't really special...

int ddcError = 0, length;
DDCFileHandle	file = 0;

ddcError = DDC_OpenFile (FILE_PATH, NULL, &file);

// here i get ddcError == -6211
if( ddcError == 0 )
{
  // do something with the file...
    
  ddcError = DDC_CloseFile(file);

  if( ddcError == 0 )
  {
    cout << "no error - everything done" << endl;
  }
}

system("PAUSE");

 Do i miss something here? Should i use DDC_FreeMemory in somehow to release opened handles?

 I also tried to use the DDC_OpenFileEx(...) with readOnly set to true. But this doesn't change anything!

 

Thanks in advance for help,

Daniel

 

 

 

 

0 Kudos
Message 1 of 9
(5,790 Views)

Hi Daniel,

 

first of all: Which development enviroment do you use? You have posted the question in the DIAdem topic. But the formatting doesn't look like DIAdem script. It seems to be LV CVI.

 

Do you have the file usiPluginTDM.dll in the same location as nilibddc.dll. This is a dependancy that is necessary to correctly read the .tdms file.

 

Best regards

Philipp

 

0 Kudos
Message 2 of 9
(5,757 Views)

Hello Daniel,

 

I assume your code is fine.

I tried to reproduce by just reducing the filesize of the index file but at my place it works fine.

Would it be possible to get the tdms and the index file to check wheater I could reproduce it?

Does the file handle stay at 0 in your code?

 

Andreas

0 Kudos
Message 3 of 9
(5,730 Views)

Hi there,

thanks for the replies (and sorry for my late answer).

The code above is from a simple Visual C++ Project that i use to run some tests with the dll.

If i posted the question in the wrong topic please let me know - i found some other posts dealing with the dll so i thought i'm right here.

 

I attached a tdms and the corresponding "corrupt" tdms_index file.

The file handle stays 0 when i debug my code with that file and i receive the error -6211.

I want to use the dll as part of an application that runs as system service. It reads and writes information from/to existing tdms files. After the information is read the application moves the files. So, if the tdms_index file gets corrupt (by whatever) i have the problem, that the index file is locked as long as the service is running and the file can't be moved. I can't tell how often this happens (hopefully never) but if i can do something against it, i would like to integrate this precaution.

 

Thanks in Advance for any information & have a nice day,

Daniel

0 Kudos
Message 4 of 9
(5,675 Views)

Hi drud,

 

I've found a forum post which treats the same topic:

http://forums.ni.com/ni/board/message?board.id=180&message.id=37932&requireLogin=False

I hope this post will solve your problem.

 

Regards

 

Philipp

0 Kudos
Message 5 of 9
(5,666 Views)
Solution
Accepted by topic author drud

You are right. The sample file taht you attached to your post causes an access violation. So no normal program flow and apllication in undefined state.

I will direct the file to the developers. I tried hard to generate a file that causes the same thing by thrashing some index files but didn't manage to create one on my own. Did it happen at your place more than once?

 

What can be done?

 

In first place it is sufficient to only copy the tdms file. The index file will be recreated when the file is accessed. So what is lost when the index file isn't copied is the time needed to create the index file by once scanning the tdms file.

 

Hope this helps a little

Andreas

0 Kudos
Message 6 of 9
(5,642 Views)

Hi there,

 

thanks for your replies. Unfortunately the forum topic posted by Philipp, does not solve my problem.

All necessary files are available. In my tests i read and write valid tdms files without any problem.

The problem occures, when i read a tdms file, with a corrupt index file.

 

Because the tdms_index file is not necessary to open a tdms file (and is generated when i read the tdms file) i will use the workaround

to delete the tdms_index file, before i process the tdms file (i would prefer a solution without deleting existing files, but the workaround is ok for me).

 

Thanks for all your help & have a nice day,

Daniel

 

 

 

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

So does it really occure in a regular manner?

Is it possible that the index file belongs to a different file and isn't overwritten correctly?

 

Andreas

0 Kudos
Message 8 of 9
(5,632 Views)

Hi Andreas,

 

sorry - i wrote the last post in haste and didn't answer the question from your reply.

 

I generated some more data to test and it was a unique problem (it's also hard for me to reproduce it again). But because the error occured once it was hard for me to ignore itSmiley Wink

The index file does not belong to a different tdms-file.

 

Generally, i don't know what can happen to the data (maybe data get's corrupt by network transfers, maybe someone illegally edits some files,...).

 

So i think the most secure way is to load the tdms file without the tdms_index file. If the tdms file is correct i will geht a new index file.

 

Thanks again & have a nice day,

Daniel

0 Kudos
Message 9 of 9
(5,629 Views)