Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android USB host and hidden devices

Tags:

I am developing an Android application in which I have to communicate to an USB device. I tried to use standart google API in my app, but list of devices is allways empty.

Same things if i use USB device info with google api. List of devices searched by google api is empty,

lsusb gives following results:

Bus 001 Device 001: ID 1d6b:0001 Bus 002 Device 001: ID 1d6b:0002 Bus 003 Device 001: ID 1d6b:0001 Bus 002 Device 002: ID 2226:0014 

my device is 2226:0014

log of eclipse:

I/USB3G(92): event { 'add', '/devices/platform/sw-ehci.1/usb2/2-1', 'usb', '', 189, 133 } I/USB3G(92): path : '/sys/devices/platform/sw-ehci.1/usb2/2-1' I/USB3G(92): VID :size 5,vid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idVendor',VID  '2226 I/USB3G(92): '. I/USB3G(92): PID :size 5,Pid_path '/sys/devices/platform/sw-ehci.1/usb2/2-1/idProduct',PID  '0014 I/USB3G(92): '. I/USB3G(92): cmd=/system/etc/usb_modeswitch.sh /system/etc/usb_modeswitch.d/2226_0014 &, I/USB3G(92): excute ret : 0,err:No such file or directory 

If i plug in devices like rs232 adapters, bluetooth dongle, nothing happens,and there is no any result from API and lsusb.

Prtocol of a device is based on ezusb library. Android v.: 4.0.3 kernel v.: 3.0.8 firmware build: crane_evb-eng 4.0.3 IMLK74k 20120330

Is there are any way to access hidden USB devices via API, or should i implement support of this device by writing driver and patching it into the firmware?

UPDATE: even if i create info file in *system/etc/usb_modeswitch.d/* with name 2226_0014 containing

DefaultVendor= 0x2226 DefaultProduct=0x0014 TargetVendor=  0x2226 TargetProductList="0014" MessageEndpoint="0x00" NeedResponse=1 CheckSuccess=20 

i get the same error: "No such file or directory"

like image 613
Alexey.Shilenkov Avatar asked Jun 25 '12 05:06

Alexey.Shilenkov


People also ask

What is Android USB host?

When your Android-powered device is in USB host mode, it acts as the USB host, powers the bus, and enumerates connected USB devices. USB host mode is supported in Android 3.1 and higher.

What is the difference between host and device in USB?

Standard USB uses a Master/Slave architecture; a host acts as the Host device for the entire bus, and a USB device acts as a Peripheral. If implementing standard USB, devices must assume one role or the other, with computers generally set up as hosts, while (for example) printers normally function as a Peripheral.


2 Answers

To enable USB host API support you should add a file named
android.hardware.usb.host.xml and containing the following lines:

<permissions>  <feature name="android.hardware.usb.host"/> </permissions> 

into folder

/system/etc/permissions 

in that folder find file named

handheld_core_hardware.xml or tablet_core_hardware.xml  

and add

<feature name="android.hardware.usb.host" /> 

into <permissions> section.

Reboot your device. Usb host api should work.

Tested on CUBE U30GT with android 4.

like image 73
Greg-q Avatar answered Sep 20 '22 18:09

Greg-q


Excellent! This worked on my Envizen V700NA running Android 4.0.4.

Minor Typo: <feature name="android.hardware.usb.host">

Should be: <feature name="android.hardware.usb.host"/>

Procedure:

  1. adb pull /system/etc/permissions/tablet_core_hardware.xml
  2. Update that file and create android.hardware.usb.host.xml as specified by Greg-q.
  3. adb push android.hardware.usb.host.xml /system/etc/permissions
  4. adb push tablet_core_hardware.xml /system/etc/permissions
  5. Reboot.
like image 26
markjuggles Avatar answered Sep 18 '22 18:09

markjuggles