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

Marcus Priesch marcus at priesch.co.at
Wed Dec 11 03:07:41 PST 2013


Hello Martin, Hello list,

now there is the need to implement it ;)

however, i get lots of devices ttyS[2-31] with the following

DEVNAME /dev/ttyS10
DEVPATH /devices/platform/serial8250/tty/ttyS10
ID_MM_CANDIDATE 1
MAJOR 4
MINOR 74
SUBSYSTEM tty
USEC_INITIALIZED 91478

which are actually not real devices (running on ubuntu 13.10) - i assume 
they get added
automatically ...

and two devices which are actually existing on my hardware

DEVNAME /dev/ttyS1
DEVPATH /devices/pnp0/00:08/tty/ttyS1
ID_MM_CANDIDATE 1
MAJOR 4
MINOR 65
SUBSYSTEM tty
USEC_INITIALIZED 82505

DEVNAME /dev/ttyS0
DEVPATH /devices/pnp0/00:09/tty/ttyS0
ID_MM_CANDIDATE 1
MAJOR 4
MINOR 64
SUBSYSTEM tty
USEC_INITIALIZED 5299

so the question arises how to filter out the non-existing ones ?

is it safe to ignore all those "DEVPATH /devices/platform/serial8250/tty*" ?

thanks for any hints,
marcus.

On 2013-09-08 11:20, Martin Pitt wrote:
> 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
> (http://pyudev.readthedocs.org/en/latest/) or using GUdev through
> introspection (http://www.freedesktop.org/software/systemd/gudev/),
> like this:
>
>>>> from gi.repository import GUdev
>>>> client = GUdev.Client.new(subsystems=['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
>


More information about the devkit-devel mailing list