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

Marcus Priesch marcus at priesch.co.at
Mon Jul 22 05:39:28 PDT 2013


Dear List,

first of all, i just subscribed here, so a big Hello to all of you ;)

here comes my question:

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):

udi = '/org/freedesktop/Hal/devices/usb_device_403_6001_WT1693937_if0_serial_usb_0'
   info.capabilities = {'serial'} (string list)
   info.category = 'serial'  (string)
   info.parent = '/org/freedesktop/Hal/devices/usb_device_403_6001_WT1693937_if0'  (string)
   info.product = 'FT232 USB-Serial (UART) IC'  (string)
   info.subsystem = 'tty'  (string)
   info.udi = '/org/freedesktop/Hal/devices/usb_device_403_6001_WT1693937_if0_serial_usb_0' 
(string)
   linux.device_file = '/dev/ttyUSB0'  (string)
   linux.hotplug_type = 2  (0x2)  (int)
   linux.subsystem = 'tty'  (string)
   linux.sysfs_path = 
'/sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/ttyUSB0/tty/ttyUSB0'  (string)
   serial.device = '/dev/ttyUSB0'  (string)
   serial.originating_device = '/org/freedesktop/Hal/devices/usb_device_403_6001_WT1693937_if0' 
  (string)
   serial.port = 0  (0x0)  (int)
   serial.type = 'usb'  (string)

for usb devices and:

udi = '/org/freedesktop/Hal/devices/pnp_PNP0501_serial_platform_0'
   info.capabilities = {'serial'} (string list)
   info.category = 'serial'  (string)
   info.parent = '/org/freedesktop/Hal/devices/pnp_PNP0501'  (string)
   info.product = '16550A-compatible COM port'  (string)
   info.subsystem = 'tty'  (string)
   info.udi = '/org/freedesktop/Hal/devices/pnp_PNP0501_serial_platform_0'  (string)
   linux.device_file = '/dev/ttyS0'  (string)
   linux.hotplug_type = 2  (0x2)  (int)
   linux.subsystem = 'tty'  (string)
   linux.sysfs_path = '/sys/devices/pnp0/00:09/tty/ttyS0'  (string)
   serial.device = '/dev/ttyS0'  (string)
   serial.originating_device = '/org/freedesktop/Hal/devices/pnp_PNP0501'  (string)
   serial.port = 0  (0x0)  (int)
   serial.type = 'platform'  (string)

for onboard devices ...

i built a wrapper around this and the programmer could specify which software can communicate 
with which device based on matching criteria.

furthermore i was able to get the serial number of the usb adapter (1693937 in this case) which 
is also printed on the device - a useful information to the customer which needs this 
information to map the connected hardware to the software ...

now, as hal is gone - at least in gentoo where i run my software - how can i do this with DBus 
/ DevKit / is this at least the right place to ask ?!?!

i did some experiments with python-dbus but all i was able to get was a huge list of serial 
devices (existing and non existing) - now, i could filter out those that are not existing by 
trying to open each one of them - but that sounds odd to me ... however i also did some 
searches on this mailinglist but havent found much about this topic ... despite other people 
having the same problems ;)

furthermore, how can i retrieve the serial number of the usb adapter - which was part of the 
"udi" ?!?!

any help would be very much appreciated as i would like to upgrade the system to more recent 
versions ... it is about two years old now ...

i would also like to hack some code on this - to get it done !!!

regards,
marcus.

-- 
Marcus Priesch
open source consultant - solution provider
www.priesch.co.at / office at priesch.co.at
A-2122 Riedenthal, In Prandnern 31 / +43 650 62 72 870


More information about the devkit-devel mailing list