File Exchange

image thumbnail

Get Port List

version (2.79 KB) by M. A. Hopcroft
Returns a list of serial port names suitable for use with serial objects.


Updated 20 Feb 2018

View Version History

View License

The matlab serial object can be used to connect to external devices that use serial communication, such as microcontrollers, GPS receivers, heartrate monitors, etc. In order to use a serial object, you need to know the serial port name.
GET_PORT_LIST returns a list of serial port names which are suitable for connections with serial port objects. The function is cross-platform (OS X, Linux, Windows) and does not require any Matlab toolboxes.
Example: (on OS X)

devices = get_port_list;
'A700elGZ' '/dev/tty.usbserial-A700elGZ'
'PXFARNQU' '/dev/tty.usbserial-PXFARNQU'
Example: (on Windows)

devices = get_port_list;
'6' 'COM6'
'1' 'COM1'
device_connection = serial(devices{1,2});
% send/receive data, etc

Cite As

M. A. Hopcroft (2021). Get Port List (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!