mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Fix device description-Linux
This commit only effects Linux.
The description field of the `device_list`, populated by
`tty_search_for_serial_devices()`, was either incorrect or less than ideal
for CDC ACM virtual com ports. For instance:
(i) Some devices incorrectly have the description field populated by
the 'product' property of USB hub they are connected via.
(ii) Other devices have description fields populated with the interface,
e.g. CDC, when there is a 'product' property available that would give a
clearer description.
To solve these issues, we first prioritise searching for the 'product' property
of the device over the 'interface' property. We also look for the
'product' property in an additional directory.
This commit is contained in:
parent
3e0b2d861d
commit
9d00cd3492
1 changed files with 10 additions and 6 deletions
16
src/tty.c
16
src/tty.c
|
|
@ -1785,18 +1785,22 @@ GList *tty_search_for_serial_devices(void)
|
|||
creation_time = fs_get_creation_time(path);
|
||||
double uptime = current_time - creation_time;
|
||||
|
||||
// Read sysfs files to get best possible description of the driver
|
||||
// Read sysfs files to get best possible description
|
||||
char description[50] = {};
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/interface", entry->d_name);
|
||||
if (length == -1)
|
||||
{
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/../interface", entry->d_name);
|
||||
}
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/../product", entry->d_name);
|
||||
if (length == -1)
|
||||
{
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/../../product", entry->d_name);
|
||||
}
|
||||
if (length == -1)
|
||||
{
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/interface", entry->d_name);
|
||||
}
|
||||
if (length == -1)
|
||||
{
|
||||
length = fs_read_file_stripped(description, sizeof(description), "/sys/class/tty/%s/device/../interface", entry->d_name);
|
||||
}
|
||||
if (length == -1)
|
||||
{
|
||||
snprintf(description, sizeof(description), "%s", get_serial_port_type(path));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue