Giter VIP home page Giter VIP logo

Comments (6)

sameehj avatar sameehj commented on August 17, 2024

What is the flow when doing control transfers, and is it possible to fetch interface/endpoint descriptors (tacking on to my previous issue #48)?

It is indeed possible

When I issue this request, it completes successfully, i.e. result variable indicates a TransferSuccess, as does UsbdStatus in GenResult. However, BytesTransferred in GenResult is 0, indicating that no bytes were transferred in the request.
Is this this proper flow? Should I execute more reads after this? All in all, the questions is as previously mentioned - is it possible to fetch the device descriptor (and analogously configuration/interface/endpoint) descriptors by doing control transfer, instead of using the API functions? Thanks for having patience.

There is absolutely no problem with using control transfers instead of the given API, however this is not a proper flow, you should get a valid response with data and BytesTransferred shouldn't be zero. I think you have a bug/bugs lying somewhere in your code, the first one I noticed is the request value:

(LONG64)transferRequest->Buffer = 0x0012000001000680;
I think you mistyped the request, it should be:
0x0012000000100680 instead.

from usbdk.

nikola-matic avatar nikola-matic commented on August 17, 2024

@sameehj, I don't think I miss typed it, as I get 0xffffffff80000800 error when I use your value, which is USBD_STATUS_INTERNAL_HC_ERROR if I'm not mistaken. When I use my value, I get status OK (0). Now, having looked into UsbDk code, I'm assuming that CUsbDkRedirectorStrategy::DoControlTransfer function is called when doing a control transfer, and in it, ControlTransferAsync seems to be called to do the transfer itself. Could it be that I have to check for the transferred bytes later if the transfer is done asynchronously?

from usbdk.

sameehj avatar sameehj commented on August 17, 2024

@sameehj, I don't think I miss typed it, as I get 0xffffffff80000800 error when I use your value, which is USBD_STATUS_INTERNAL_HC_ERROR if I'm not mistaken. When I use my value, I get status OK (0). Now, having looked into UsbDk code, I'm assuming that CUsbDkRedirectorStrategy::DoControlTransfer function is called when doing a control transfer, and in it, ControlTransferAsync seems to be called to do the transfer itself. Could it be that I have to check for the transferred bytes later if the transfer is done asynchronously?

@nikola-matic Sorry for the long reply I've been a bit busy lately. You are right indeed, you need to poll and check for the completion using the function UsbDk_GetRedirectorSystemHandle() (https://github.com/daynix/UsbDk/blob/master/UsbDkHelper/UsbDkHelper.h#L251)

Please refer to UsbDk's code in Libusb for an example of the usage. You can find that here: https://github.com/libusb/libusb/blob/master/libusb/os/windows_usbdk.c
Checkout the functions usbdk_do_control_transfer, usbdk_do_bulk_transfer and usbdk_do_iso_transfer.

from usbdk.

nikola-matic avatar nikola-matic commented on August 17, 2024

@sameehj, no worries. In fact, I realized that libusb does in fact offer the capabilities that I need (it doesn't "support" libusb_claim_interface & libusb_detach_kernel_driver calls on Windows and Darwin, which was a no no, since that's exactly what I needed - but then, looking through their code, I realized that they call UsbDk_StartRedirect in libusb_open).

In any case, I'll be using libusb with UsbDk backend instead of UsbDk directly. Thanks for the help, and I'll look into writing a simple example for redirecting a device (e.g. mouse) and doing interrupt reads from it. Thanks again!

from usbdk.

sameehj avatar sameehj commented on August 17, 2024

Great! Since this issue is resolved I am closing it, feel free to re open it if you think otherwise or create a new issue if needed :)

from usbdk.

sameehj avatar sameehj commented on August 17, 2024

Great! Since this issue is resolved I am closing it, feel free to re open it if you think otherwise or create a new issue if needed :)

from usbdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.