|
From: Felix H. <fel...@we...> - 2014-07-26 15:09:20
|
Hello, you know that I had developed an integration of the usb-serial-for-android library (respectively a forked version of the library, see https://code.google.com/r/felixhaedicke-usb-serial-for-android) last year. The code can still be found in my git repository, branch usb-serial-for-android. But it is not based on the current XCSoar code any more and would need some bugfixing. But I do not like the Android USB API. The main reason is that support for asynchronous reading / writing is unusable. See https://code.google.com/p/android/issues/detail?id=39522. For reading data, polling is required all the time, using UsbDeviceConnection.bulkTransfer(). >From my point of view, libusb offers by far the better API for userspace USB drivers. I have already implemented a USB Serial Adapter driver library based on libusbserial. It is a pure C library, and the code can be found here: https://github.com/felixhaedicke/libusbserial. libusb also works on Android, although it is not an official Android API. For enumerating devices, I would still use the Android USB API, for one simple reason: The permission for accessing a USB device needs to be requested using the Android APIs. The native file descriptor can be accessed using the UsbDeviceCOnnection.getFileDescriptor() method. To hand over a UsbDeviceConnection (Android API) to libusb, libusb needs to be patched (to open a libusb_device_handle using the file descriptor). The libusb based code could also be used on other platforms. This is not very helpful on Linux and Windows, because there are kernel drivers on these platforms. But the code could also be used on iOS. At least some iPad devices appear to be USB-OTG compatible and some people are successfully using libusb on it. Unfortunately, I cannot verify this, because I don't have an iPad. What do you think? Should I rather complete / renew the Java code or should I integrate my libusbserial library? Regards Felix |