User`s manual
8 Serial Port I/O
8-34
As shown below, after the string is written to the output buffer, it is then
written to the device via the serial port.
Writing Text Data
You use the fprintf function to write text data to the device. For many devices,
writing text data means writing string commands that change device settings,
prepare the device to return data or status information, and so on.
For example, the
Display:Contrast command changes the display contrast of
the oscilloscope.
s = serial('COM1');
fopen(s)
fprintf(s,'Display:Contrast 45')
By default, fprintf writes data using the %s\n format since many serial port
devices accept only text-based commands. However, you can specify many
other formats as described in the
fprintf reference pages.
You can verify the number of values sent to the device with the
ValuesSent
property.
s.ValuesSent
ans =
20
COM1
...
Output Buffer
Bytes used during write
Bytes unused during write
6 values
6 bytes
Serial Port I/O Hardware Instrument
*IDN?