Question about how to get list of available serial devices ...

Martin Pitt martin.pitt at
Sun Sep 8 02:20:12 PDT 2013

Hello Marcus,

Marcus Priesch [2013-07-22 14:39 +0200]:
> i have a software written in python that needs to know the list of
> available serial devices on the system, including on-board serial
> devices and USB serial adapters.
> in the past i used hal for this and got nice results like this (lshal output):

You get pretty much the same information with libudev these days,
which is the recommended interface not just for enumerating the
current hardware, but also to get notified about any hardware changes.
For C programs you'd just use libudev (or libgudev for GObject-y
stuff), for Python you have the choice between pyudev 
( or using GUdev through
introspection (,
like this: 

>>> from gi.repository import GUdev
>>> client =['tty'])
>>> devs = client.query_by_subsystem('tty')

Then you can iterate over devs and call stuff like .get_device_file()
or .get_property('ID_SERIAL') on those.


Martin Pitt                        |
Ubuntu Developer (  | Debian Developer  (

More information about the devkit-devel mailing list