I am writing a service which currently polls the USB bus to look for a
specific device's PID/VID and then creates a handle to that device.

Problem is, once the device is connected and discovered, the polling
method I am using utilizes 99% of the processor:

int
isUSBConnected(void)
{
struct usb_bus *bus;
  struct usb_device *dev;

  usb_find_busses(); /* find all busses */
  usb_find_devices(); /* find all connected devices */

  for (bus = usb_get_busses(); bus; bus = bus->next)
    {
      for (dev = bus->devices; dev; dev = dev->next)
        {
          if (dev->descriptor.idVendor == MY_VID && dev-
>descriptor.idProduct
              == MY_PID)
            {
              return 0;
            }
        }
    }

  MyLibusbDeviceHandle = NULL;
  return -1;
}

I use essentially the same function to continually look for the
device, which doesn't take up any resources.  The only difference is
that a handle to the device is returned or null.

I tried using Android's built-in "on device-added-/dev/2-1" and "on
device-removed-/dev/2-1" which my device pops up as when plugged in.
The file is also removed when the device is unplugged, however, the
triggers are not firing my application when the device appears /dev/
2-1.

init.rc:
on device-added-/sys/bus/usb/devices/
2-1
       start conv_srv

on device-removed-/sys/bus/usb/devices/
2-1
       stop conv_srv

service conv_srv /system/bin/logwrapper /system/bin/
conv_srv
       disabled
       user root
       group
root

I have also tried commenting out "disabled" under the service, but
then my app launches on boot without meeting the specified criteria,
nor does the application detect changes on the bus.

Am I doing something wrong in my init.rc?  Is there another way to
leverage Android to do the "polling" or "watching" of the USB bus for
me?

Any help on this would be greatly appreciated!


sws-vinpa

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to