Sep 4, 2011 Replies: 34 Gives access to the new Usb host features available in Android 3.1 and above. A working example is available here: http://www.b4x.com/forum/basic4andr.../11289-android-usb-host-tutorial-adbtest.html Documentation: http://www.b4x.com/android/help/usb.html Installation instructions: - Unzip the attached file. - Copy both files to the internal libraries folder: C:\Program Files\Anywhere Software\Basic4android\Libraries Attachments USB.zip USB.zip 14.4 KB · Views: 2,501 Click to expand...
Gives access to the new Usb host features available in Android 3.1 and above. A working example is available here: http://www.b4x.com/forum/basic4andr.../11289-android-usb-host-tutorial-adbtest.html Documentation: http://www.b4x.com/android/help/usb.html Installation instructions: - Unzip the attached file. - Copy both files to the internal libraries folder: C:\Program Files\Anywhere Software\Basic4android\Libraries
D dilettante Active Member Licensed User Longtime User May 8, 2013 #21 Erel said: Are you familiar with the PS3 controller protocol? The example code is specific to ADB protocol. Click to expand... Don't most generic (non-Android) game controllers look like one of the HID Class gamepad or joystick, etc. devices? I went 'round and 'round with the Bluetooth "Green Throttle" controller which like so many Android game controllers relys on goofy totally custom device types and proprietary APIs every game has to use or remapping game controller actions to buttons/keys and such. Bleh. Somewhere here I read that USB HID devices get "eaten" by Android and can't be accessed using this library. Is this true even for custom HID Class devices (not a keyboard, mouse, gamepad, etc.)? I really want to use some USB sensors that are HID but don't present as common subtypes. I guess I need to just try this out, and if it fails look at some even lower level API.
Erel said: Are you familiar with the PS3 controller protocol? The example code is specific to ADB protocol. Click to expand... Don't most generic (non-Android) game controllers look like one of the HID Class gamepad or joystick, etc. devices? I went 'round and 'round with the Bluetooth "Green Throttle" controller which like so many Android game controllers relys on goofy totally custom device types and proprietary APIs every game has to use or remapping game controller actions to buttons/keys and such. Bleh. Somewhere here I read that USB HID devices get "eaten" by Android and can't be accessed using this library. Is this true even for custom HID Class devices (not a keyboard, mouse, gamepad, etc.)? I really want to use some USB sensors that are HID but don't present as common subtypes. I guess I need to just try this out, and if it fails look at some even lower level API.
Erel B4X founder Staff member Licensed User Longtime User May 9, 2013 #22 Note that you will need the full version in order to test USB. Most HID devices are handled internally. In that case it is not possible to access these devices with Android USB Api (there isn't a lower level access available).
Note that you will need the full version in order to test USB. Most HID devices are handled internally. In that case it is not possible to access these devices with Android USB Api (there isn't a lower level access available).
D dilettante Active Member Licensed User Longtime User May 11, 2013 #23 Erel said: Note that you will need the full version in order to test USB. Most HID devices are handled internally. In that case it is not possible to access these devices with Android USB Api (there isn't a lower level access available). Click to expand... Thanks. Under Windows I look for these devices by enumerating all HID devices and then weed them out. First by UsagePage and UsageID values, and further by VID and PID. It isn't clear whether this library can provide all of those values, and that presumes non-standard HID device info can be returned at all (Android may "eat" these devices anyway). I know on conventional Linux-based OSs people are using these devices. But that doesn't predict anything about how Android may handle them or how this particular library might deal with them.
Erel said: Note that you will need the full version in order to test USB. Most HID devices are handled internally. In that case it is not possible to access these devices with Android USB Api (there isn't a lower level access available). Click to expand... Thanks. Under Windows I look for these devices by enumerating all HID devices and then weed them out. First by UsagePage and UsageID values, and further by VID and PID. It isn't clear whether this library can provide all of those values, and that presumes non-standard HID device info can be returned at all (Android may "eat" these devices anyway). I know on conventional Linux-based OSs people are using these devices. But that doesn't predict anything about how Android may handle them or how this particular library might deal with them.
Erel B4X founder Staff member Licensed User Longtime User May 11, 2013 #24 This library is just a wrapper above the native API. You can try any USB app from Google Play. If your device is recognized then it will also be recognized with this library.
This library is just a wrapper above the native API. You can try any USB app from Google Play. If your device is recognized then it will also be recognized with this library.
P pixelpop Active Member Licensed User Longtime User Feb 15, 2014 #25 I have a very generic mini tablet with Android 4.0.4 and rooted. I have two USB devices--a barcode scanner and a postal scale that I connect to the tablet with a micro USB host OTG cable. The barcode scanner works as expected as a keyboard device (open notepad, scan a barcode and the UPC appears in the notepad). The scale is probably using a data packet of some sort, so it doesn't act as a keyboard. When I use USBDetails with these devices, the results are puzzling. The scanner shows as the RealTek WAN adapter (as has been discussed here and elsewhere) but it works as a keyboard anyway. However, the scale is correctly identified by USBDetails as a DYM M10 (Dymo Model M10), but I cannot interpret the remain info to determine if I can program an interface to read this devices output data. Attached are screen shots of both screen. Any help would be greatly appreciated.
I have a very generic mini tablet with Android 4.0.4 and rooted. I have two USB devices--a barcode scanner and a postal scale that I connect to the tablet with a micro USB host OTG cable. The barcode scanner works as expected as a keyboard device (open notepad, scan a barcode and the UPC appears in the notepad). The scale is probably using a data packet of some sort, so it doesn't act as a keyboard. When I use USBDetails with these devices, the results are puzzling. The scanner shows as the RealTek WAN adapter (as has been discussed here and elsewhere) but it works as a keyboard anyway. However, the scale is correctly identified by USBDetails as a DYM M10 (Dymo Model M10), but I cannot interpret the remain info to determine if I can program an interface to read this devices output data. Attached are screen shots of both screen. Any help would be greatly appreciated.
Erel B4X founder Staff member Licensed User Longtime User Feb 16, 2014 #26 You should be able to communicate with the scale. However you will need to know the exact protocol that the scale expects.
You should be able to communicate with the scale. However you will need to know the exact protocol that the scale expects.
P pixelpop Active Member Licensed User Longtime User Feb 16, 2014 #27 Thanks, Erel. When I run the USBSerialDemo app, I get this (screen cap). The Vendor and Product IDs are incorrect. Should I ignore this and just read the data on the USB port? I got a USB demo project in VB6 off the Internet that reads the USB data correctly, but only if I define the Vendor and Product IDs first. Public Const MyVendorID = &H922 Public Const MyProductID = &H8003 Edit: Using SetCustomDevice I was able to get the Dymo M10 correctly recognized. I'm off and running! Thanks!! Attachments Screenshot_2014-02-16-05-08-30.png 33 KB · Views: 754 Last edited: Feb 16, 2014
Thanks, Erel. When I run the USBSerialDemo app, I get this (screen cap). The Vendor and Product IDs are incorrect. Should I ignore this and just read the data on the USB port? I got a USB demo project in VB6 off the Internet that reads the USB data correctly, but only if I define the Vendor and Product IDs first. Public Const MyVendorID = &H922 Public Const MyProductID = &H8003 Edit: Using SetCustomDevice I was able to get the Dymo M10 correctly recognized. I'm off and running! Thanks!!
P pabloprat2013 New Member Licensed User Longtime User May 7, 2014 #28 This library has an event for you to send data usb host port? I need print use port usb host thanks for you help
This library has an event for you to send data usb host port? I need print use port usb host thanks for you help
Erel B4X founder Staff member Licensed User Longtime User May 8, 2014 #29 Yes. You can send data to the usb device.
J javiman6969 Member Licensed User Longtime User Nov 18, 2014 #30 Hi, Erel. I've been using this library for a long time with different devices with usb host. Has been used for printing on different Receipt Printers usb smoothly. But they have been tested with a new device an Android POS and does not detect any usb device. However with APP downloaded from Google PLay, "USB Host Controller" if it detects USB Hub and USB devices. Could you tell me where you can be wrong? It would be possible to have the source code for the library to test it? Or some code to test where the error may come? Thank you for your help
Hi, Erel. I've been using this library for a long time with different devices with usb host. Has been used for printing on different Receipt Printers usb smoothly. But they have been tested with a new device an Android POS and does not detect any usb device. However with APP downloaded from Google PLay, "USB Host Controller" if it detects USB Hub and USB devices. Could you tell me where you can be wrong? It would be possible to have the source code for the library to test it? Or some code to test where the error may come? Thank you for your help
Erel B4X founder Staff member Licensed User Longtime User Nov 18, 2014 #31 This is the relevant Java code: public void Initialize() { manager = (UsbManager) BA.applicationContext.getSystemService(Context.USB_SERVICE); } public UsbDeviceWrapper[] GetDevices() { HashMap<String, UsbDevice> h = manager.getDeviceList(); UsbDeviceWrapper[] uw = new UsbDeviceWrapper[h.size()]; int i = 0; for (UsbDevice u : h.values()) { uw = new UsbDeviceWrapper(); uw.setObject(u); i++; } return uw; } If you can root the device then it is worth trying this solution: http://www.b4x.com/android/forum/threads/pl2303-usb-to-rs232-adaptor-driver.11449/page-3#post-121125
This is the relevant Java code: public void Initialize() { manager = (UsbManager) BA.applicationContext.getSystemService(Context.USB_SERVICE); } public UsbDeviceWrapper[] GetDevices() { HashMap<String, UsbDevice> h = manager.getDeviceList(); UsbDeviceWrapper[] uw = new UsbDeviceWrapper[h.size()]; int i = 0; for (UsbDevice u : h.values()) { uw = new UsbDeviceWrapper(); uw.setObject(u); i++; } return uw; } If you can root the device then it is worth trying this solution: http://www.b4x.com/android/forum/threads/pl2303-usb-to-rs232-adaptor-driver.11449/page-3#post-121125
J javiman6969 Member Licensed User Longtime User Nov 19, 2014 #32 Hi Erel. I tried what you told me and the problem is not resolved. Moreover, the device is root and the correct file android.hardware.usb.host.xml. When I run this code, I return 0 number of devices. Code: Dim usbdevices() As UsbAccessory Dim interface As UsbInterface Dim manager As UsbManager manager.Initialize usbdevices = manager.GetAccessories Msgbox("USB: " & usbdevices.Length, "") However, the APP "USB Host Controller" perfectly detects devices and USB HUB. Any idea, plus? Last edited: Nov 19, 2014
Hi Erel. I tried what you told me and the problem is not resolved. Moreover, the device is root and the correct file android.hardware.usb.host.xml. When I run this code, I return 0 number of devices. Code: Dim usbdevices() As UsbAccessory Dim interface As UsbInterface Dim manager As UsbManager manager.Initialize usbdevices = manager.GetAccessories Msgbox("USB: " & usbdevices.Length, "") However, the APP "USB Host Controller" perfectly detects devices and USB HUB. Any idea, plus?
Erel B4X founder Staff member Licensed User Longtime User Nov 20, 2014 #33 You need to call manager.GetDevices.
J Josef Graessle New Member Licensed User Longtime User May 24, 2016 #34 Who developed the USB host library? I would like to get more details how I have to use it, when I connet a non ADB device to an Android tablet. I have no ADB like communication, as the hardware was developed 5 years ago and is sold now for 5 years. The hardware has only 1 Bulk Endpoint IN and 1 Bulk Endpoint OUT. It works at PC's from Win-XP to Win-10 and I would like to use it with Android tablets too. By the USB host tutorial is the hardware correctly recognized, but I cannot transfer data IN and OUT.
Who developed the USB host library? I would like to get more details how I have to use it, when I connet a non ADB device to an Android tablet. I have no ADB like communication, as the hardware was developed 5 years ago and is sold now for 5 years. The hardware has only 1 Bulk Endpoint IN and 1 Bulk Endpoint OUT. It works at PC's from Win-XP to Win-10 and I would like to use it with Android tablets too. By the USB host tutorial is the hardware correctly recognized, but I cannot transfer data IN and OUT.
Erel B4X founder Staff member Licensed User Longtime User May 25, 2016 #35 The ADB example is just an example of using this library: https://www.b4x.com/android/forum/threads/android-usb-host-tutorial-adbtest.11289/ Please start a new thread and post the relevant communication code that is not working for you.
The ADB example is just an example of using this library: https://www.b4x.com/android/forum/threads/android-usb-host-tutorial-adbtest.11289/ Please start a new thread and post the relevant communication code that is not working for you.