12-16-2011 01:24 PM - edited 12-16-2011 01:26 PM
Hello everyone!!
I hope someone can help me out with this one.
I'm trying to set up a program capable of reading the last value of one of the channels of different large TDMS files but I just can´t find a way to do that.
I would really appreciate any help with my little problem.
Thank you very much in advance for your support.
Kasim.
Solved! Go to Solution.
12-16-2011 02:07 PM
There is a property 'NI_ChannelLength' (or something like that) that shows you the number of elements in a channel.
You can use that to get the offset you need to read.
Ton
12-16-2011 03:11 PM
Hi Ton!
Thank you very much for your help!
My TDMS file doesn't have the property NI_ChannelLength. Is that a property I have to initialize when creating the TDMS file?
12-17-2011 02:14 AM
It's a channel property (every channel and group can have different lengths). I think it's added by the TDMS API of LabVIEW.
Ton
12-19-2011 03:33 PM
Hi,
You can use the TDMS Set Next Read Position function included in the TDMS API. This function receives a parameter called "from (0:start)", which can be set to 1 to access the end of the file. This way, you can read the last value written to the TDMS file.
Hope this helps!
Anuar Rojas
12-20-2011 02:02 PM
GREAT!!!
Thank you very much Anuar!!! It works!!!
Kasim.
12-20-2011 02:24 PM
I'm glad I could help!!
You're welcome!!
Anuar Rojas
11-20-2012 06:44 PM
Reviving this thread since I also am attempting to read the last value in a TDMS file, but have a detail question ... I made this work by setting the 'from (0:start)' input of the Set Next Read Position Advanced TDMS VI to "end", and then setting the 'offset' input on the same VI to minus 1.
This appears to work, however, using the 'offset' to read the last five values (setting offset to -5) provides garbled data for all but the last value. Am I using this VI correctly?
The file was not created using the Advanced TDMS VIs, just TDMS VIs from the basic palette. Does this matter? (the file is closed between writes and reads).
When I set a Group and single Channel designation on the Set Next Read Position VI, the Advanced Read VI seems to return multiple Channel values if the designated Channel was not the last Channel defined when creating the file. Can I depend on this behavior? The Advanced Read does not provide the 'Return Values in File Order' control allowed by the basic Read VI.
To make this work I had to set both 'Disable Buffering' and 'Enable Async' to True, on the Advanced TDMS Open VI. False values on either generated errors.
I am using LV 2011. Thanks.
11-20-2012 09:18 PM
It's more safe to use TDMS Standard APIs if you are not familiar with Advanced APIs.
For example, to get the last N samples of a channel you can make a VI like that:
11-22-2012 11:08 AM
Thank You. The online help did not indicate what parameters can be read. The clue was NI_ChannelLength.