User`s manual
8 Serial Port I/O
8-36
Writing Binary Data
You use the fwrite function to write binary data to the device. Writing binary
data means writing numerical values. A typical application for writing binary
data involves writing calibration data to an instrument such as an arbitrary
waveform generator.
Note Some serial port devices accept only text-based commands. These
commands may use the SCPI language or some other vendor-specific
language. Therefore, you may need to use the
fprintf function for all write
operations.
By default,
fwrite translates values using the uchar precision. However, you
can specify many other precisions as described in the reference pages for this
function.
By default,
fwrite operates synchronously. To write binary data
asynchronously to the device, you must specify
async as the last input
argument to
fwrite. For more information about synchronous and
asynchronous write operations, refer to the “Writing Text Data” on page 8-34.
For a description of the rules used by
fwrite to complete a write operation,
refer to its reference pages.
Reading Data
This section describes reading data from your serial port device in three parts:
•“The Input Buffer and Data Flow” describes the flow of data from the device
to MATLAB.
•“Reading Text Data” describes how to read from the device, and format the
data as text.
•“Reading Binary Data” describes how to read binary (numerical) data from
the device.