B4A Library Usb Host library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Sep 4, 2011.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

    • USB.zip
      File size:
      14.4 KB
      Views:
      1,133
    Volga and raphaelcno like this.
  2. agraham

    agraham Expert Licensed User

    Here's an example that displays all the details of the first USB device it finds connected.

    There is presently a bug in UsbDeviceConnection.getRawDescriptors so the Reflection library is used in USBdetails.DeviceDetails(device) instead.

    It's quite interesting connecting various USB devices to see what they support.
     

    Attached Files:

    Last edited: Apr 18, 2013
    Volga and raphaelcno like this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    V0.92 uploaded to the first post. This version adds a method named BulkTransfer which supports synchronous requests.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    V0.93 uploaded to the first post. This version adds support for Android Accessory USB devices.
    A big thank you for agraham for this implementation :icon_clap:
     
  5. msemih2011

    msemih2011 Member Licensed User

    Why get the following error when compiling program USBDetails

    Compiling code. Error
    Error parsing program.
    Error description: The index was outside the bounds of the array.
     
  6. agraham

    agraham Expert Licensed User

    I've just downloaded it to check and it compiles and runs fine for me.
     
  7. msemih2011

    msemih2011 Member Licensed User

    No change in the project using the Android version is 3.1 which gives the same result, but did not do it if you tell me that you are using them, I use libs
     
  8. agraham

    agraham Expert Licensed User

    Sorry, but I don't understand your post.
     
  9. msemih2011

    msemih2011 Member Licensed User

    gives the same error when I try to compile the project. I used an android version 3.1. What does such an error?
     
  10. agraham

    agraham Expert Licensed User

    I'm afraid that I have no idea. I am compiling using the android.jar for android-13 (Android 3.2).
     
  11. Erel

    Erel Administrator Staff Member Licensed User

  12. lgbdt

    lgbdt New Member Licensed User

    I'm just getting started with B4A and I've attempted both the USBDetails example and the USB example on my Coby MID8042 and have not had any luck with either application returning a USB device from manager.GetDevices. No matter what USB device I attach, devices[] is empty.

    My Coby 8042 has Android 4.0.3 and it appears that USB devices are supported because I can plug in a USB mouse or USB keyboard via the USB Host dongle (provided by Coby) and they seem to work fine in various applications on the tablet. They just don't show up in the example apps...

    I found a couple of topics via Google that suggested some tablets support USB devices and USB Host but don't support the USB Host API. Those topics went on to mention that a possible cause is the absence of an 'android.hardware.usb.host.xml file in the /system/etc/permissions folder. And, the absence of '<feature name="android.hardware.usb.host">' in either the handheld_core_hardware.xml or tablet_core_hardware.xml file. In looking in my 8042's /etc/permissions folder, these items do appear to be absent, as suggested.

    Have you or any other users encountered this type of problem with the USB Host API on some devices?

    Do you think those missing items mentioned could be the problem? If not, do you have other suggestions?

    Thanks!
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    If your device is rooted then it is worth trying to add these missing items.
     
  14. lgbdt

    lgbdt New Member Licensed User

    No. It's not rooted. I'm just getting started with android devices and I have not rooted anything yet. So, I'll do some more research on doing that and give it a try.

    Thanks!
     
  15. Filippo

    Filippo Expert Licensed User

    Hi Erel,

    I have 3 different USB-converter but not recognized by my device, I get the message "No device attached".

    I try just using the example "USBdetail" and "USBpl203".
    All USB converter have the chipset "Prolific PL-2303".

    My device is an HTC-one-s ICS 4.0.3.

    Ciao,
    Filippo
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    The USB library is a simple wrapper over the native USB api. If it doesn't find the USB device then it means that your phone doesn't recognize it.
     
  17. Filippo

    Filippo Expert Licensed User

    That is but even if it would work with my phone not sure it would work with other mobile also.

    It would be a better Seriel-Bluetooth adapter or what do you think?
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    If you do not target a specific device that you know for sure that it works with then a Bluetooth solution will be better.
     
  19. NeoTechni

    NeoTechni Well-Known Member Licensed User

    How would you get other data types?

    Like INTs from a PS3 controller? Or even a mouse?

    I've combined the USB and USB details examples into a single project and altered it to connect to a PS3 controller, but I can't get any data (other than all zeroes) from it

    The relevant code is PrintRaf
     

    Attached Files:

    • demo.zip
      File size:
      11.3 KB
      Views:
      222
    Last edited: Mar 19, 2013
  20. Erel

    Erel Administrator Staff Member Licensed User

    Are you familiar with the PS3 controller protocol? The example code is specific to ADB protocol.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice