Android: USB Communication Android <-> External Device

后端 未结 3 1546
醉梦人生
醉梦人生 2021-02-10 02:55

I found several threads speacking about this subject, but after read them I don\'t have a clear idea about my problem.

We have a external device (something like a tomtom

相关标签:
3条回答
  • 2021-02-10 03:35

    Currently the adb interface is one way. Flow is controlled by the host PC using adb. Looking at your requirement, looks like you might need to open up the source code, re-tune the USB driver to allow communication both ways. After that, you will need to design your very own API that allows an application to send messages via USB. This will require a lot of work as the current Android model does not support it.

    0 讨论(0)
  • 2021-02-10 03:48

    If the android device that you are attaching your device to, supports host mode then the usb api can help. it is however a low level api that talks in usb request buffers (URBs) I am writing a serial abstraction at the moment using this api but it is not ready for airing at present.

    If your non android device is able to act as host then as Royston suggests the adb route might be best for you and there are examples of how to do this in the api bundles post api version 12.

    0 讨论(0)
  • 2021-02-10 03:51

    I'm basically doing the same you are describing. I'm still at the early stages but I've managed such communication under some constraints:

    1. You need a device supporting the USB Host API. The API itself has been around since Android 3.2 or so, but not every device seems to support it. It looks like most of the devices running >4.0 should work, but still is a per device check you should do. I'm currently using an Acer Iconia Tab A510, which so far seems to work but has some glitches: for instance, you cannot charge the device while using the USB port as it is shared with the charger but not compatible with USB.
    2. As Neil says the USB API is low level, so I think you will need a driver for your USB chipset (the one at your side, i.e. in your device). I've been quite lucky here as there's an open source project working on FTDI chipsets that happen to be the ones I've chosen. If that's your case too, you should check the projects:
      • FTDriver: https://github.com/ksksue/FTDriver
      • Android USB Serial Monitor Lite: https://github.com/ksksue/Android-USB-Serial-Monitor-Lite This one has even an app in Google Play, so you can install it and start "playing" ;-)

    I hope this helps. As I've said, I'm starting to work in this ecosystem and I still have to find my way around many "places".

    Cheers, Asier.

    0 讨论(0)
提交回复
热议问题