listPorts {serial}R Documentation

Lists the serial interfaces.

Description

This function lists all installed serial interfaces in a computer. Thereby Windows, Linux and MacOs behave different. Please ensure that you have the appropriate permissions to do a search in the registry or in the corresponding linux folders.

Usage

listPorts()

Value

A character vector with the list of comports is returned.

Windows

In a Windows environment, this function tries to read out the registry keys located in:

"HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM"

This should be consistent with all installed hardware ports plus all virtual ports.

Linux and MacOS

Here the situation is different, compared to Windows. All possible serial devices are located in "/dev/tty[...]" as a file connection. Still, all virtual and closed dev's can be found here. This is confusing, because one will find more devices in this folder than physically (virtual) present. In addition to that, Ubuntu linux systems do list the plug and play devices of interest in "/sys/devices/pnp0/..." again. That is the reason why, the function returns a subset of "/dev/tty[...]", which is also present in the "../pnp0/.." folder.

On MacOs the installed interfaces are marked by "tty.<name>" or "cu.<name>", with a unique name after the dot, which makes it easier to search for installed devices. Here a tty device is a modem which waits for a DCD (Data Carrier Detect) signal to receive data. The device is blocked as long such a signal is not detected. The corresponding cu device manages the out going communication for historical reasons. However a cu port is not blocked and should be used in favour on MacOS.

Subsequently, the user must know which interface is present and which isn't. AND the user must have at least reading permissions in the corresponding folders. So in the end, this function is a best guess of what is installed.


[Package serial version 3.0 Index]