From 90d89bbe5f8f36bc9616e8599805be44adfde69f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 30 Dec 2015 10:34:23 +0100 Subject: [PATCH] Add full LG4 (VS986) support Add productId to the Wireshark dissector and udev rule, adjust the serial path detection logic to find the right key (`\Device\LGVZANDNETDIAG1`). Now you do not need to pass `--serial COM4` anymore. Reportedly fails in VirtualBox with USB passthrough, but works fine on Linux. Thanks @invisiblek for testing! --- lglaf.lua | 1 + lglaf.py | 13 +++++++++---- rules.d/42-usb-lglaf.rules | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lglaf.lua b/lglaf.lua index bcb5b57..a5fe8d2 100644 --- a/lglaf.lua +++ b/lglaf.lua @@ -97,4 +97,5 @@ function lglaf.init() local usb_product = DissectorTable.get("usb.product"); usb_product:add(0x1004633e, lglaf) -- LG G3 D855 usb_product:add(0x1004627f, lglaf) -- LG G3 VS985 + usb_product:add(0x10046298, lglaf) -- LG G4 VS986 end diff --git a/lglaf.py b/lglaf.py index 234c9ce..4a73291 100755 --- a/lglaf.py +++ b/lglaf.py @@ -275,16 +275,21 @@ def detect_serial_path(): try: path = r'HARDWARE\DEVICEMAP\SERIALCOMM' with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path) as key: - return winreg.QueryValueEx(key, r'\Device\LGANDNETDIAG1')[0] - except OSError: - return None + for i in range(winreg.QueryInfoKey(key)[1]): + name, value, value_type = winreg.EnumValue(key, i) + # match both \Device\LGANDNETDIAG1 and \Device\LGVZANDNETDIAG1 + name = name.upper() + if name.startswith(r'\DEVICE\LG') and name.endswith('ANDNETDIAG1'): + return value + except OSError: pass + return None def autodetect_device(): if winreg is not None and 'usb.core' not in sys.modules: serial_path = detect_serial_path() _logger.debug("Using serial port: %s", serial_path) if not serial_path: - raise RuntimeError("Please install LG drivers or PyUSB") + raise RuntimeError("Device not found, try installing LG drivers") return FileCommunication(serial_path) else: if 'usb.core' not in sys.modules: diff --git a/rules.d/42-usb-lglaf.rules b/rules.d/42-usb-lglaf.rules index 86fdee4..55d9a0f 100644 --- a/rules.d/42-usb-lglaf.rules +++ b/rules.d/42-usb-lglaf.rules @@ -3,3 +3,5 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", ATTRS{idProduct}=="633e", TAG+="uaccess" # LG G3 (VS985) in download mode SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", ATTRS{idProduct}=="627f", TAG+="uaccess" +# LG G4 (VS986) in download mode +SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", ATTRS{idProduct}=="6298", TAG+="uaccess"