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 serial port 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.
Timeout
property passes.
fscanf
and readasync
only).
A read operation with fread
completes when one of these conditions is satisfied:
Timeout
property passes.
In addition to these rules, you can stop an asynchronous read operation at any time with the stopasync
function.
![]() | Asynchronous Write and Read Operations | Example: Writing and Reading Text Data | ![]() |