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:

Additionally, you can stop an asynchronous write operation at any time with the stopasync function.

An instrument determines if a write operation is complete based on the EOSMode, EOIMode, and EOSCharCode property values. If EOSMode is configured to either write or read&write, each occurrence of \n in a text command is replaced with the End-Of-String (EOS) character specified by the EOSCharCode value. Therefore, when you use the default fprintf format of %s\n, all text commands written to the instrument will end with that value. The default EOSCharCode value is LF, which corresponds to the line feed character. The EOS character required by your instrument will be described in its documentation.

If EOIMode is on, then the End Or Identify (EOI) line is asserted when the last byte is written to the instrument. The last byte can be part of a binary data stream or a text data stream. If EOSMode is configured to either write or read&write, then the last byte written is the EOSCharCode value and the EOI line is asserted when the instrument receives this byte.

Completing Read Operations

A read operation with fgetl, fgets, fread, fscanf, or readasync 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 Text Data