Question about how to get list of available serial devices ...
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
which are actually not real devices (running on ubuntu 13.10) - i assume
they get added
and two devices which are actually existing on my hardware
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,
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.
More information about the devkit-devel