User`s manual

Connecting to the Device
8-27
Connecting to the Device
Before you can use the serial port object to write or read data, you must connect
it to your device via the serial port specified in the
serial function. You connect
a serial port object to the device with the
fopen function.
fopen(s)
Some properties are read-only while the serial port object is connected and
must be configured before using
fopen. Examples include the
InputBufferSize and the OutputBufferSize properties. Refer to “Property
Reference” on page 8-70 to determine when you can configure a property.
Note You can create any number of serial port objects. However, you can
connect only one serial port object to a given serial port at a time.
You can examine the
Status property to verify that the serial port object is
connected to the device.
s.Status
ans =
open
As illustrated below, the connection between the serial port object and the
device is complete, and you can write and read data.
Serial Port I/O Hardware
s=serial('COM1');
fopen(s)
01.00
COM1
InstrumentMATLAB