Date
1 - 3 of 3
[PATCH v2] config-tools: improve the message of 95-usb.py
Yang, Yu-chu
From: yuchuyang <yu-chu.yang@...>
Improve the logging message of extracting USB device information. v1->v2 Using the error message for logging. Signed-off-by: yuchuyang <yu-chu.yang@...> --- .../board_inspector/extractors/95-usb.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/misc/config_tools/board_inspector/extractors/95-usb.py b/misc/config_tools/board_inspector/extractors/95-usb.py index 99daa256f..7bb15c351 100644 --- a/misc/config_tools/board_inspector/extractors/95-usb.py +++ b/misc/config_tools/board_inspector/extractors/95-usb.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: BSD-3-Clause # -import os, re +import os, re, logging from extractors.helpers import add_child, get_node @@ -17,17 +17,19 @@ def extract(args, board_etree): if m: d = m.group(0) devpath = os.path.join(USB_DEVICES_PATH, d) - with open(os.path.join(devpath, 'devnum'), 'r') as f: - devnum = f.read().strip() - with open(os.path.join(devpath, 'busnum'), 'r') as f: - busnum = f.read().strip() - cmd_out = os.popen('lsusb -s {b}:{d}'.format(b=busnum, d=devnum)).read() - desc = cmd_out.split(':', maxsplit=1)[1].strip('\n') - - with open(devpath + '/port/firmware_node/path') as f: - acpi_path = f.read().strip() - usb_port_node = get_node(board_etree, f"//device[acpi_object='{acpi_path}']") - if usb_port_node is not None: - add_child(usb_port_node, "usb_device", location=d, - description=d + desc) + try: + with open(os.path.join(devpath, 'devnum'), 'r') as f: + devnum = f.read().strip() + with open(os.path.join(devpath, 'busnum'), 'r') as f: + busnum = f.read().strip() + cmd_out = os.popen('lsusb -s {b}:{d}'.format(b=busnum, d=devnum)).read() + desc = cmd_out.split(':', maxsplit=1)[1].strip('\n') + with open(devpath + '/port/firmware_node/path') as f: + acpi_path = f.read().strip() + usb_port_node = get_node(board_etree, f"//device[acpi_object='{acpi_path}']") + if usb_port_node is not None: + add_child(usb_port_node, "usb_device", location=d, + description=d + desc) + except Exception as e: + logging.error(f"{e}: please check if the USB device is connected or has been removed.") -- 2.25.1 |
|
Junjie Mao
toggle quoted message
Show quoted text
-----Original Message-----The error message does not provide any hint which USB device users need to check. Do we have any identifier of that device to provide to them? --- Best Regards Junjie Mao -- |
|
Yang, Yu-chu
toggle quoted message
Show quoted text
-----Original Message-----
From: Mao, Junjie <junjie.mao@...> Sent: Tuesday, November 15, 2022 6:51 PM To: Yang, Yu-chu <yu-chu.yang@...>; acrn-dev@... Subject: RE: [PATCH v2] config-tools: improve the message of 95-usb.py -----Original Message----- The error message does not provide any hint which USB device users need to check. Do we have any identifier of that device to provide to them? Remove a USB device would remove it from "/sys/bus/usb/devices", the path "/sys/bus/usb/devices/<^\d-\d$> " is gone. It won't be found from below commands: $ ls /sys/bus/usb/devices $ lsusb -s <busnum>:<devnum> $ lsusb Do you have any suggestion? Thanks, Yu-chu -- |
|