Commit graph

21 commits

Author SHA1 Message Date
tuxuser
1ef1741bff Printing stderr-redirection warning to user via --help for rawshell argument 2017-11-25 21:14:28 +01:00
tuxuser
61e59e2a27 Add rawshell switch, not prepending anything to sent command 2017-11-22 02:48:40 +01:00
RenaKunisaki
734c650cc4 fix some error codes 2017-07-20 15:53:13 -04:00
RenaKunisaki
0c7bdf2fa9 add error code descriptions 2017-07-20 15:48:51 -04:00
Peter Wu
688e0f3d17 lglaf.py: Fix "Resource busy" error
Detach kernel driver (cdc_acm) to avoid this error:

    usb.core.USBError: [Errno 16] Resource busy

Deliberately do not call attach_kernel_driver for the detached devices,
it is likely that the user runs lglaf multiple times. The user can
unplug and re-insert their device if they want to re-attach the kernel
driver.
2016-03-15 22:24:49 +01:00
Peter Wu
f2792e6374 lglaf.py: dynamically query for endpoint numbers
The endpoint numbers are apparently not fixed. Use heuristics to
discover these (necessary for at least the D805).

Tested with D855.
2016-03-15 22:10:42 +01:00
Peter Wu
396409d3fa Make shell execution a bit more reliable
Previously you would not get feedback when quotes are not terminated or
when the command is too long. Fix this by putting stderr redirection in
the shell command, before eval.
2016-01-04 13:03:30 +01:00
Peter Wu
7ef3448209 lglaf.py: fix default read timeout
Really apply default read timeout (5 seconds) even if Communication.read
passes None.
2016-01-03 22:46:15 +01:00
Peter Wu
90d89bbe5f 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!
2015-12-30 10:51:18 +01:00
Peter Wu
2d79e1565e Attempt to LG G4 compatibility
lsusb from @invisiblek, unfortunately it seems to hang when used in
VirtualBox (USB passthrough from Windows to Linux).

The second CD of exposes the endpoints over bInterfaceNumber 2, so this
patch simply activates the second CD.

LG G4 (1004:6298) has this device descriptor:

    ...
    idVendor           0x1004 LG Electronics, Inc.
    idProduct          0x6298
    bcdDevice            3.10
    iManufacturer           1 LG Electronics Inc.
    iProduct                2 LGE Android Phone
    iSerial                 3 VS986xxxxxxxx
    bNumConfigurations      2
    Configuration Descriptor:
      ...
      bNumInterfaces          1
      bConfigurationValue     1
      ...
      Interface Descriptor:
        ...
        bNumEndpoints           3
        bInterfaceClass         6 Imaging
        bInterfaceSubClass      1 Still Image Capture
        bInterfaceProtocol      1 Picture Transfer Protocol (PIMA 15470)
        iInterface              5 MTP
        ...
        (EP 1 IN  Bulk)
        (EP 1 OUT Bulk)
        (EP 2 IN  Intr)
        ...
    Configuration Descriptor:
      ...
      bNumInterfaces          4
      bConfigurationValue     2
      ...
      Interface Descriptor:
        ...
        bNumEndpoints           3
        bInterfaceClass         6 Imaging
        bInterfaceSubClass      1 Still Image Capture
        bInterfaceProtocol      1 Picture Transfer Protocol (PIMA 15470)
        iInterface              6 MTP
        ...
        (EP 1 IN  Bulk)
        (EP 1 OUT Bulk)
        (EP 2 IN  Intr)
        ...
      Interface Association:
        bLength                 8
        bDescriptorType        11
        bFirstInterface         1
        bInterfaceCount         2
        bFunctionClass          2 Communications
        bFunctionSubClass       2 Abstract (modem)
        bFunctionProtocol       1 AT-commands (v.25ter)
        iFunction               9 CDC Serial
      Interface Descriptor:
        ...
        bNumEndpoints           1
        bInterfaceClass         2 Communications
        bInterfaceSubClass      2 Abstract (modem)
        bInterfaceProtocol      1 AT-commands (v.25ter)
        iInterface              7 CDC Abstract Control Model (ACM)
        ...
        (EP 4 IN  Intr)
      Interface Descriptor:
        ...
        bNumEndpoints           2
        bInterfaceClass        10 CDC Data
        bInterfaceSubClass      0
        bInterfaceProtocol      0
        iInterface              8 CDC ACM Data
        (EP 3 IN  Bulk)
        (EP 2 Out Bulk)
      Interface Descriptor:
        ...
        bInterfaceNumber        2
        bAlternateSetting       0
        bNumEndpoints           2
        bInterfaceClass       255 Vendor Specific Class
        bInterfaceSubClass    255 Vendor Specific Subclass
        bInterfaceProtocol    255 Vendor Specific Protocol
        iInterface              0
        (EP 5 IN  Bulk)
        (EP 3 OUT Bulk)
        ...
2015-12-29 18:43:22 +01:00
Peter Wu
e71375d6cc lglaf.py: do not hang forever on reads
Use 5 second timeout for the initial hello and 60 seconds for other
cases. Maybe a --read-timeout option should be added in case you need
more time...
2015-12-29 18:40:46 +01:00
Peter Wu
d26f0717a9 Add support for VS985 and others
The udev rules and Wireshark dissector still have idProduct hardcoded
for the time being, but lglaf.py detection logic is converted to use
heuristics instead.

Thanks to @invisiblek for testing and providing lsusb output.
2015-12-29 11:40:21 +01:00
Peter Wu
1eaebefe87 lglaf.py: Avoid reading from stdin
stdin points to /dev/graphics/fb0, might not be the greatest source of
input...
2015-12-27 12:54:44 +01:00
Peter Wu
88fa55bbd5 lglaf.py: Python 2 compatibility 2015-12-26 22:03:49 +01:00
Peter Wu
a8145a4a75 lglaf.py: allow skipping HELO
Just in case it causes interference, or to speed up things when you know
that the device is correct and in sync.
2015-12-26 14:51:28 +01:00
Peter Wu
e4544e50e5 lglaf.py: make device detection externally available
Useful for other scripts.
2015-12-26 01:09:07 +01:00
Peter Wu
13d0579db0 Try to make reset more robust
Implements message draining for serial devices and adds a HELO request
to ensure that the device is synchronized and speaks the protocol.
2015-12-25 15:55:15 +01:00
Peter Wu
0b38a8af0e lglaf.py: more helpful assertions 2015-12-25 15:48:30 +01:00
Peter Wu
0871e23c06 Auto-detect serial port on Windows 2015-12-24 23:58:34 +01:00
Peter Wu
ad8977611f Add '-c' option, workaround Windows crash
Fixes "AttributeError: 'NoneType' object has no attribute 'isatty'" for

    echo ls | lglaf.py --serial com4

Adding "python" avoids the crash.
2015-12-24 22:19:47 +01:00
Peter Wu
d5b3ae382f lglaf.py: Initial commit
Tested on Linux only.
2015-12-24 20:03:07 +01:00