Skip to content

list_ports.comports() lists dummy devices on Ubuntu 24.04 #763

@Slarag

Description

@Slarag

When I list the available serial ports using serial.tools.list_ports.comports() on Ubuntu 24.04, it also lists all the dummy /dev/ttyS* (0-31) devices which are non-existent on my hardware.

On the same machines with Ubuntu 22.04, only existing serial ports are listed.

>>> from serial.tools.list_ports import comports
>>> [p.name for p in comports()]

Output on Ubuntu 24.04:

['ttyS0', 'ttyS1', ..., 'ttyS30', 'ttyS31', 'ttyUSB0', ..., 'ttyUSB7']

Output on Ubuntu 22.04:

['ttyUSB0', ..., 'ttyUSB7']
Ubuntu Version Kernel Version
22.04 6.2.0-26-generic
24.04 6.8.0-36-generic

By default, pyserial filters out devices with subsystem platform.

However, Ubunt 24.04 (or more precisely newer kernel versions) report a different subsystem serial-base for all the (existing and non-existing) legacy serial ports:

Port Type Subsystem on Ubuntu 22.04 Subsystem on Ubuntu 24.04
Non-existent ports (/dev/ttyS*) platform serial-base
Existing legacy ports (/dev/ttyS*) pnp serial-base

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions