Android 上的 WebUsb API [英] WebUsb API on Android

查看:80
本文介绍了Android 上的 WebUsb API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 PWA,它应该通过 Android 9.0 平板电脑通过 USB 与自定义设备进行通信.

I'm developing a PWA that should communicate with a custom device by usb through an Android 9.0 tablet.

当我第一次尝试声明一个接口时,PWA 无法声明它,因为它说接口很忙,如果我尝试通过本机应用程序使用 USB 设备,它工作正常.我尝试通过本机应用程序使用 USB 设备,当我断开与本机应用程序的连接时,我能够通过 PWA 声明该接口.

When I'm first trying to claim an interface the PWA cannot claim it because it's says that the interface is busy, If i try to use the usb device through a native app it works fine. I tried to use the usb Device through the native app, when I disconnected the connection from the native app then I was able to claim the interface through the PWA.

  • 我发现它可能无法工作,因为 android 设备自动声明接口,我可以直接从 PWA 做一些事情来声明使用的接口吗?
  • 如果不是,它是否适用于串行 API?
  • 我对设备有一定的控制权,也许我应该要求它实现另一个我可以声明的接口?

感谢您的帮助!

推荐答案

您可能遇到的是 Android 内核驱动程序或其他已声明该接口的本机应用程序.在 Android 上的 WebUSB 实现中,Chrome 当前在声明接口时不会尝试分离其他驱动程序.下面的问题跟踪考虑是否应该.

What you are probably running into is an Android kernel driver or another native application which has claimed the interface. In the WebUSB implementation on Android Chrome currently does not try to detach other drivers when claiming an interface. The issue below tracks considering whether it should.

https://bugs.chromium.org/p/chromium/issues/detail?id=1099521

如果您可以向设备添加非标准 USB 接口类(例如,CDC 或打印机)的接口,则可以避免系统自动向其附加驱动程序.

If you can add an interface to the device which is not a standard USB interface class (for example, CDC or Printer) then you can avoid having the system automatically attach a driver to it.

这篇关于Android 上的 WebUsb API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆