Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UsbDk automatic disable usb-device #123

Open
d1ret opened this issue Aug 23, 2023 · 5 comments
Open

UsbDk automatic disable usb-device #123

d1ret opened this issue Aug 23, 2023 · 5 comments

Comments

@d1ret
Copy link

d1ret commented Aug 23, 2023

When I make a request, the device is disconnected from the computer, "URB_FUNCTION_ABORT_PIPE" is called, followed by an error. Is it normal or not?

@ybendito
Copy link
Collaborator

We do not understand the question. Can you please describe your experience in details? What does it mean: "When I make a request"? Where you see that "URB_FUNCTION_ABORT_PIPE is called"? etc

@d1ret
Copy link
Author

d1ret commented Aug 23, 2023

I have code

import usb.core
import usb.util
from usb.backend import libusb1
from ctypes import c_void_p, c_int
import time

backend = usb.backend.libusb1.get_backend(find_library=lambda x: "libusb-1.0.dll")
backend.lib.libusb_set_option.argtypes = [c_void_p, c_int]
backend.lib.libusb_set_option(backend.ctx, 1)
device = usb.core.find(idVendor=0x25A7, idProduct=0xfa7c, backend=backend)
print(device)

def get_battery():
    req =  device.ctrl_transfer(bmRequestType=0x21, bRequest=0x09, wValue=0x0308, data_or_wLength=bytes(
        b"\x08\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x49"), wIndex=1)
    usb.util.dispose_resources(device)
    time.sleep(4)
    result = device.ctrl_transfer(bmRequestType=0xa1, bRequest=0x01, wValue=0x0308, data_or_wLength=40, wIndex=1)

    usb.util.dispose_resources(device)
    usb.util.release_interface(device, 0)
    print(f"Message received from the mouse: {list(result)}")


if __name__ == '__main__':
     get_battery()

When usbdk send request

device.ctrl_transfer(bmRequestType=0x21, bRequest=0x09, wValue=0x0308, data_or_wLength=data, wIndex=1)"

my usb device disconnects from my computer, and connect after request

@ybendito
Copy link
Collaborator

What you expect this request will do?

@d1ret
Copy link
Author

d1ret commented Aug 23, 2023

I send a request to a usb device to get a battery charge, but I need it to continue working during the request

@ybendito
Copy link
Collaborator

It looks like the device is not happy with the request and does the internal reset (disconnects from the bus and reconnects again).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants