Instrument Control Toolbox | ![]() ![]() |
Creating a Serial Port Object
You create a serial port object with the serial
function. serial
requires the name of the serial port connected to your device as an input argument. As described in Configuring Property Values, you can also configure property values during object creation.
Each serial port object is associated with one serial port. For example, to create a serial port object associated with the COM1 port
s = serial('COM1');
The serial port object s
now exists in the MATLAB workspace. You can display the class of s
with the whos
command.
whos s Name Size Bytes Class s 1x1 512 serial object Grand total is 11 elements using 512 bytes
Once the serial port object is created, the properties listed below are automatically assigned values. These general purpose properties provide descriptive information about the serial port object based on the object type and the serial port.
Property Name |
Description |
Name |
Specify a descriptive name for the serial port object. |
Port |
Indicate the platform-specific serial port name. |
Type |
Indicate the object type. |
You can display the values of these properties for s
with the get
function.
get(s,{'Name','Port','Type'}) ans = 'Serial-COM1' 'COM1' 'serial'
![]() | Finding Serial Port Information for Your Platform | The Serial Port Object Display | ![]() |