Learn R Programming

serial (version 1.2)

listPorts: Lists the serial interfaces.

Description

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

Usage

listPorts()

Arguments

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 a bit 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, on Ubuntu linux systems in "/sys/devices/pnp0/..." only the plug and play devices of interest are listed 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>", with a unique name after the dot, which makes it easier to search for installed devices.

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.