Method

System.SerialPort


Warning

This item was deprecated in version 2019r2. Please use SerialDevice as a replacement.

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.,

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

Sample code

You get the values of SerialDevice properties by accessing the properties of the System module:

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

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

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

Compatibility

All project types on all supported operating systems.