<div class="meta" robots="noindex">

</div>

Method

# System.SerialPort

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `SerialDevice</api/hardware/serialdevice>` as a replacement.

</div>

## Description

Gets the serial port by its path.

## Notes

On macOS and Linux, the path is the path to the device file corresponding to the serial device (e.g., /dev/ttyS0). On Windows, this can be the COM port you want to open, e.g.,

``` xojo
Serial1.SerialPort = System.SerialPort("/dev/ttyS0") ' macOS and Linux
Serial1.SerialPort = System.SerialPort("COM1") ' Windows
```

## Sample code

You get the values of `SerialDevice</api/hardware/serialdevice>` properties by accessing the properties of the `System</api/os/system>` module:

``` xojo
TextField1.Text = System.SerialPort(0).InputDriverName
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The following displays the names of the serial ports on the computer:

``` xojo
For i As Integer = 0 To System.SerialPortCount - 1
  MsgBox(System.SerialPort(i).Name)
Next
```

## Compatibility

All project types on all supported operating systems.
