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:

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:

A read operation with fread completes when one of these conditions is satisfied:

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