viReadToFile
Syntax
viReadToFile (ViSession vi, ViConstString fileName, ViUInt32 count, ViPUInt32 retCount);
Description
Read data synchronously and store the transferred data in a file. This read operation synchronously transfers data. The file specified in fileName is opened in binary write-only mode.
If the value of VI_ATTR_FILE_APPEND_EN is VI_FALSE, any existing contents are destroyed. Otherwise, the file contents are preserved. The data read is written to the file. This operation returns only when the transfer terminates. This operation is useful for storing raw data to be processed later. VISA uses ANSI C file operations. The mode used by viReadToFile is "wb" or "ab" depending on the value of VI_ATTR_FILE_APPEND_EN.
Parameters
Name |
Dir |
Type |
Description |
---|---|---|---|
vi |
IN |
ViSession |
Unique logical identifier to a session. |
fileName |
IN |
ViConstString |
Name of file to which data will be written. |
count |
IN |
ViUInt32 |
Number of bytes to be read. |
retCount |
OUT |
ViPUInt32 |
Number of bytes actually transferred. |
Special Value for retCount Parameter |
|||
Value |
Description |
||
VI_NULL |
|
|
Do not return the number of bytes transferred. |
Return Values
Type ViStatus |
This is the function return status. It returns either a completion code or an error code as follows. |
Completion Code |
Description |
---|---|
VI_SUCCESS |
The function completed successfully and the END indicator was received (for interfaces that have END indicators). |
VI_SUCCESS_MAX_CNT |
The number of bytes read is equal to count. |
VI_SUCCESS_TERM_CHAR |
The specified termination character was read. |
Error Code |
Description |
VI_ERROR_ASRL_FRAMING |
A framing error occurred during transfer. |
VI_ERROR_ASRL_OVERRUN |
An overrun error occurred during transfer. A character was not read from the hardware before the next character arrived. |
VI_ERROR_ASRL_PARITY |
A parity error occurred during transfer. |
VI_ERROR_BERR |
Bus error occurred during transfer. |
VI_ERROR_CONN_LOST |
The I/O connection for the given session has been lost. |
VI_ERROR_FILE_ACCESS |
An error occurred while trying to open the specified file. Possible reasons include an invalid path or lack of access rights. |
VI_ERROR_FILE_IO |
An error occurred while accessing the specified file. |
VI_ERROR_INV_SESSION |
The given session or object reference is invalid (both are the same value). |
VI_ERROR_INV_SETUP |
Unable to start read function because setup is invalid (due to attributes being set to an inconsistent state). |
VI_ERROR_IO |
An unknown I/O error occurred during transfer. |
VI_ERROR_NCIC |
The interface associated with the given vi is not currently the controller in charge. |
VI_ERROR_NLISTENERS |
No Listeners condition is detected (both NRFD and NDAC are deasserted). |
VI_ERROR_NSUP_OPER |
The given vi does not support this function. |
VI_ERROR_OUTP_PROT_VIOL |
Device reported an output protocol error occurred during transfer. |
VI_ERROR_RAW_RD_PROT_VIOL |
Violation of raw read protocol occurred during transfer. |
VI_ERROR_RAW_WR_PROT_VIOL |
Violation of raw write protocol occurred during transfer. |
VI_ERROR_RSRC_LOCKED |
Specified operation could not be performed because the resource identified by vi has been locked for this kind of access. |
VI_ERROR_TMO |
Timeout expired before function completed. |