Skip to content

Commit

Permalink
src: report the product name when there's no description
Browse files Browse the repository at this point in the history
Some devices like the CH341 do not report any description, but they provide
a product name, which is better than nothing. This patch allows this product
to be retrieved in this case. This gives for example:

   port |  age (sec) | device     | driver           | description
  ------+------------+------------+------------------+----------------------
      0 |     892294 | ttyUSB0    | ch341-uart       | USB2.0-Serial
  • Loading branch information
wtarreau committed Dec 24, 2020
1 parent cd5680a commit 21981c5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,11 +1002,15 @@ int scan_ports()
goto fail;

/* the descrption usually appears in ../interface for ttyUSB or
* ./interface for ttyACM
* ./interface for ttyACM. Some devices like CH341 do not provide
* anything but they come with a "product" node which identifies
* the USB device.
*/
desc = read_line_from("/sys/class/tty/%s/device/../interface", ent->d_name);
if (!desc)
desc = read_line_from("/sys/class/tty/%s/device/interface", ent->d_name);
if (!desc)
desc = read_line_from("/sys/class/tty/%s/device/../../product", ent->d_name);
/* note: the model is not always set, so we accept NULL */

serial_ports[nbports].name = name;
Expand Down

0 comments on commit 21981c5

Please sign in to comment.