Instrument Control Toolbox | ![]() ![]() |
Rules for Completing Write and Read Operations
The rules for completing synchronous and asynchronous read and write operations are described below.
Completing Write Operations
A write operation using fprintf
or fwrite
completes when one of these conditions is satisfied:
Timeout
property passes.
In addition to these rules, you can stop an asynchronous write operation at any time with the stopasync
function.
A text command is processed by the instrument only when it receives the required terminator. For TCP/IP and UDP objects, each occurrence of \n
in the ASCII command is replaced with the Terminator
property value. Because the default format for fprintf
is %s\n
, all commands written to the instrument will end with the Terminator
value. The default value of Terminator
is the line feed character. The terminator required by your instrument will be described in its documentation.
Completing Read Operations
A read operation with fgetl
, fgets
, fscanf
, or readasync
completes when one of these conditions is satisfied:
Terminator
property is read. For UDP objects, DatagramTerminateMode
must be off
.
Timeout
property passes.
fscanf
and readasync
only). For UDP objects, DatagramTerminateMode
must be off
.
DatagramTerminateMode
is on
).
A read operation with fread
completes when one of these conditions is satisfied:
Timeout
property passes.
DatagramTerminateMode
must be off
.
DatagramTerminateMode
is on
).
In addition to these rules, you can stop an asynchronous read operation at any time with the stopasync
function.
![]() | Writing and Reading Data | Example: Writing and Reading Data with a TCP/IP Object | ![]() |