| Instrument Control Toolbox | ![]() |
Write binary data to the instrument
Syntax
Arguments
Description
fwrite(obj,A)
writes the binary data A to the instrument connected to obj.
fwrite(obj,A,' writes binary data with precision specified by precision')
precision.
precision controls the number of bits written for each value and the interpretation of those bits as integer, floating-point, or character values. If precision is not specified, uchar (an 8-bit unsigned character) is used. The supported values for precision are listed below in Remarks.
writes binary data with command line access specified by fwrite(obj,A,'mode')
mode. If mode is sync, A is written synchronously and the command line is blocked. If mode is async, A is written asynchronously and the command line is not blocked. If mode is not specified, the write operation is synchronous.
writes binary data with precision specified by fwrite(obj,A,'precision','mode')
precision and command line access specified by mode.
Remarks
Before you can write data to the instrument, it must be connected to obj with the fopen function. A connected instrument object has a Status property value of open. An error is returned if you attempt to perform a write operation while obj is not connected to the instrument.
The ValuesSent property value is increased by the number of values written each time fwrite is issued.
An error occurs if the output buffer cannot hold all the data to be written. You can specify the size of the output buffer with the OutputBufferSize property.
Synchronous Versus Asynchronous Write Operations
By default, data is written to the instrument synchronously and the command line is blocked until the operation completes. You can perform an asynchronous write by configuring the mode input argument to be async. For asynchronous writes,
BytesToOutput property value is continuously updated to reflect the number of bytes in the output buffer.
OutputEmptyFcn property is executed when the output buffer is empty.
You can determine whether an asynchronous write operation is in progress with the TransferStatus property.
Synchronous and asynchronous write operations are discussed in more detail in Synchronous Versus Asynchronous Write Operations.
Rules for Completing a Write Operation with fwrite
A binary write operation using fwrite completes when
Timeout property passes.
Note
The Terminator and EOSCharCode properties are not used with binary write operations.
|
Supported Precisions
The supported values for precision are listed below.
Functions
Properties
OutputBufferSize, OutputEmptyFcn, Status, Timeout, TransferStatus, ValuesSent
| fscanf | get | ![]() |