TDMS_AdvancedAsyncWrite
- Updated2023-02-21
- 5 minute(s) read
TDMS_AdvancedAsyncWrite
int TDMS_AdvancedAsyncWrite (TDMSFileHandle file, void *samples, size_t numberOfSamples, TDMSDataType dataType, TDMSAsyncWriteCallbackPtr callback, void *callbackData);
Purpose
Writes data to the specified .tdms file asynchronously.
This function can issue additional asynchronous writes while executing previously issued asynchronous writes in the background. When the number of asynchronous writes in the background reaches the maximum value, this function waits until a previously issued asynchronous write completes before issuing an additional asynchronous write. If the previously issued asynchronous write does not complete within the timeout value, this function returns error code TDMS_OperationTimedOut. Call TDMS_ConfigureAsyncWrites to configure the maximum number of asynchronous writes and the timeout value.
Call TDMS_GetAsyncWriteStatus to query the number of pending asynchronous writes.
(Linux) This function is not supported.
(Real-Time Module) This function is not supported.
Parameters
Input | ||||
Name | Type | Description | ||
file | TDMSFileHandle | The file handle. You obtain this handle from TDMS_AdvancedOpenFile or TDMS_AdvancedCreateFile. You must specify the enable asynchronous operations option when you open or create the file. | ||
samples | void * | An array containing samples that will be written to the specified file. Because the write operation is asynchronous you cannot modify the array contents or dispose of the array memory immediately after this function call returns. Instead you must wait until the asynchronous operation completes. You can be notified when the asynchronous operation completes using the callback parameter. The type of this array should match the type of the samples you are writing. This function does not support writing samples of type string. If the type of the samples you are writing is TDMS_Timestamp, you must pass an array of type CVIAbsoluteTime. Refer to the Absolute Time functions in the Utility Library for more information about this type.
|
||
numberOfSamples | size_t | The number of samples to write.
|
||
dataType | TDMSDataType | The data type of the samples to write. This function does not support writing samples of type string. | ||
callback | TDMSAsyncWriteCallbackPtr | The function that the library calls when the asynchronous write operation is complete or fails due to an error. The library calls this function asynchronously in a worker thread. The TDM Streaming library will always call your callbacks in the same order in which you issue the corresponding calls to this function. The function you pass for this parameter must have the following prototype: void CVICALLBACK Callback (TDMSFileHandle file, int error, void *samples, size_t numSamplesWritten, void *callbackData); Upon entry to the callback, the file parameter contains the same file handle passed to this function. The error parameter contains an error code value indicating the reason the write operation failed or zero if the write operation succeeded. The samples parameter contains the same array pointer passed to this function. The numSamplesWritten parameter contains the number of samples written to the file. This will be the same number of samples passed to this function or will be zero if an error occurred. The callbackData parameter of the callback contains the value you provide in the callbackData parameter of this function. You can use this parameter to pass any additional information you choose.
|
||
callbackData | void * | Specifies a pointer to user-defined data that the TDM Streaming Library will pass to your callback as the callbackData parameter. Do not pass the address of a local variable or any other variable or memory that might not be valid when the callback is executed. If you do not need callback data you can pass NULL for this parameter. |
Return Value
Name | Type | Description |
status | int | Return value indicating whether the function was successful. Unless otherwise stated, zero represents successful execution and a negative number represents the error code. Error codes are defined in cvi\include\cvitdms.h. |
Additional Information
Library: TDM Streaming Library
Include file: cvitdms.h
LabWindows/CVI compatibility: LabWindows/CVI 2013 and later
© 2016 National Instruments. All rights reserved.
Examples
Refer to the following examples that use the TDMS_AdvancedAsyncWrite function: