Replacement for hal utilities in a serial port list script

Forum rules
Before you post please read how to get help
Level 9
Level 9
Posts: 2929
Joined: Fri Aug 19, 2011 3:46 am

Replacement for hal utilities in a serial port list script

Postby Monsta » Fri Jun 27, 2014 3:02 am

At work, I sometimes deal with various USB-RS232 devices which are recognized by the system as serial ports with device names like /dev/ttyUSBn, where n >= 0.
A few years ago I wrote a script that prints all currently connected serial ports - their device names and product descriptions (to distinguish between FTDI and Prolific devices, for example):

Code: Select all


list_all_ports() {
    for ((i = 0; i < dev_count; i++ ))
        dev_description=`hal-get-property --udi ${dev_list[$i]} --key info.product`
        dev_name=`hal-get-property --udi ${dev_list[$i]} --key serial.device`
        echo -e $dev_name'\t'$dev_description

declare -a dev_list
dev_list=(`hal-find-by-property --key info.subsystem --string tty`)

echo List of comports in the system:
list_all_ports | sort

This script calls two hal utilities: hal-get-property and hal-find-by-property. Now that hal is obsolete and not present neither in Ubuntu-based Mint nor in LMDE, this script ceased to function.

What could I possibly use to replace these calls?

User avatar
Level 18
Level 18
Posts: 8030
Joined: Thu Apr 07, 2011 8:15 pm

Re: Replacement for hal utilities in a serial port list scri

Postby WharfRat » Fri Jun 27, 2014 10:08 pm

Hal was replaced by udev so you might want to look into udevadm

Code: Select all

udevadm info --export-db
Image Image Image

Return to “Scripts & Bash”

Who is online

Users browsing this forum: No registered users and 1 guest