Solution
This error occurs when a TDMS function (i.e TDMS Write or TDMS Read) receives an invalid reference on its
tdms file input. The following example simulates a common situation where this issue shows up.
The code is continuously logging random data to a TDMS file (
test.tdms). Under regular conditions, the
Write TDMS function receives the file reference that was created with the
TMDS Open function. To simulate a situation where the file reference is lost, a case structure controlled by the
Close Ref button was added. Once this button is pressed, the initial reference is closed. In the next iteration, the
Write TDMS function will receive an invalid reference causing the -2501 error.