binblockwrite
(To be removed) Write binblock data to instrument
This serial, Bluetooth, tcpip,
udp, visa, and gpib object
function will be removed in a future release. Use serialport, bluetooth,
tcpclient,
tcpserver,
udpport,
and visadev
object functions instead. For more information on updating your code, see Version History.
Syntax
binblockwrite(obj,A)
binblockwrite(obj,A,'precision')
binblockwrite(obj,A,'header')
binblockwrite(obj,A,'precision','header')
binblockwrite(obj,A,'precision','header','headerformat')
Arguments
| An interface object. |
| The data to be written using the binblock format. |
| The number of bits written for each value, and the interpretation of the bits as character, integer, or floating-point values. |
| The ASCII header text to be prefixed to the data. |
| C language conversion specification format for the header text. |
Description
binblockwrite(obj,A) writes the data
specified by A to the instrument connected to
obj as a binary-block (binblock). The binblock format is
defined as #<N><D><A>, where
Nspecifies the number of digits inDthat follow.Dspecifies the number of data bytes inAthat follow.Ais the data written to the instrument.
For example, if A is given by [0 5 5 0 5 5
0], the binblock would be defined as [double('#') 1 7 0 5 5 0
5 5 0].
binblockwrite(obj,A,'
writes binblock data translating the MATLAB® values to the precision specified by
precision')precision. By default the uchar
precision is used. Refer to the fwrite function for a list of
supported precisions.
binblockwrite(obj,A,'header') writes a
binblock using the data, A, and the ASCII header, header, to the
instrument connected to interface object, obj. The data written
is constructed using the formula
<header>#<N><D><A>
binblockwrite(obj,A,'
writes binary data, precision','header')A, translating the MATLAB values to the specified precision,
precision. The ASCII header,
header, is prefixed to the binblock.
binblockwrite(obj,A,'
writes binary data, precision','header','headerformat')A, translating the MATLAB values to the specified precision,
precision. The ASCII header,
header, is prefixed to the binblock using the format
specified by headerformat.
headerformat is a string containing C language
conversion specifications. Conversion specifications are composed of the character
% and the conversion characters d,
i, o, u,
x, X, f,
e, E, g,
G, c, and s. Type
instrhelp fprintf for more information on valid values for
headerformat. By default,
headerformat is %s.
Examples
s = visa('ni', 'ASRL2::INSTR');
fopen(s);
% Write the command: [double('#14') 0 5 0 5] to the instrument.
binblockwrite(s, [0 5 0 5]);
% Write the command: [double('Curve #14') 0 5 0 5] to the
% instrument.
binblockwrite(s, [0 5 0 5], 'Curve ')
fclose(s);Tips
Before you can write data to the instrument, it must be connected to
obj with the fopen function. A connected
interface 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 binblockwrite 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.
Note
To get a list of options you can use on a function, press the Tab key after entering a function on the MATLAB command line. The list expands, and you can scroll to choose a property or value. For information about using this advanced tab completion feature, see Using Tab Completion for Functions.