问题标签 [webusb]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1475 浏览

javascript - WebUSB:请求的接口实现了一个受保护的类

我正在尝试使用读卡器(https://www.ewen-online.com/tcpdf/pdf/ew/p/EW1052/)来读取健康卡。

这是代码(从官方文档复制粘贴:https ://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web ):

错误在这里:

由于某种原因,我无法在课堂上访问。我无法弄清楚如何让它工作,我已经阅读了 alla stackoverflow 相关的线程,但没有找到解决方案。

提前致谢!

0 投票
2 回答
3179 浏览

javascript - WebUSB:如果 navigator.usb.getDevices() 失败,如何调用 navigator.usb.requestDevice()

我正在为 Scratch3 编写一个基于 WebUSB 的扩展。在扩展构造函数中,我需要建立 WebUSB 连接。理想情况下,我想使用 navigator.usb.getDevices() 检查可用/配对的设备,如果失败,我想要求用户使用 navigator.usb.requestDevice() 选择设备。

问题是 navigator.usb.requestDevice() 需要从用户手势中调用。在大多数情况下,scratch3 扩展构造函数是从用户操作中调用的,因此我可以很好地使用 navigator.usb.requestDevice()。

但是 navigator.usb.getDevices() 返回一个 Promise 并从那里调用 navigator.usb.requestDevice() 失败,并显示“必须处理用户手势以显示权限请求”。

所以以下工作(但每次都会打开一个请求对话框):

但是由于缺少“用户手势”而导致以下失败:

我想避免弄乱 Scratch 3 核心,因此不想添加另一个 UI 元素。

在第一个片段中仅使用 navigator.usb.requestDevice() 有两个主要缺点:

  1. 它一直打开请求对话框,尽管它只需要一次
  2. 有时稍后可能会从非交互式情况调用构造函数,并且 navigator.usb.requestDevice() 会完全失败,而 navigator.usb.getDevices() 会成功

有没有办法使第二个代码片段的方法起作用?

0 投票
1 回答
900 浏览

google-chrome - 接口申领失败:该平台不支持或未实现操作

我正在尝试v73.0.3683.86通过 WebUSB 在 Chrome 中的 Windows 10 上使用 USB 条形码扫描仪。

扫描仪是Honeywell Voyager 1250g.

我可以通过设备对话框查看设备 - 我也可以打开它并选择配置。

但是,当我尝试声明interface(1) (有 3 个接口,但 1 个是批量传输)时,我Failed to claim interface: Operation not supported or unimplemented on this platformchrome://device-log/.

有没有办法解决这个问题,或者这个扫描仪不能通过 WebUSB 使用?谢谢!

0 投票
1 回答
795 浏览

arduino - DOMException 声明 WebUSB 接口

我读过其他人在使用 FTDI(CDC 类)和 WebUSB 时遇到的类似问题,但是没有一个建议的答案对我有用。

我正在尝试通过以下方式与 Arudino Mega 通信:

但我得到一个 DOMException.. 并且 chrome://device-log 以蓝色显示设备(“USB 用户”)。

我知道 Chrome 必须使用未绑定或未连接到 Windows 的接口,但是,USB 配置显示 2 个接口,均未声明,但我也不能声明。

尽管尝试卸载和使用 WinUsb.sys,Windows 总是加载 ftdiport.sys 驱动程序而不是 WinUsb.sys。不知道可能是什么问题。

0 投票
0 回答
602 浏览

javascript - WebUSB 串行连接 - DOMException:设备不可用

我正在尝试运行此 WebUSB 演示: https ://developers.google.com/web/updates/2016/03/access-usb-devices-on-the-web

我使用的是 SparkFun Pro Micro,所以我将 vendorId 更改为 0x1b4f,当我调用它时它成功显示在弹出窗口中

选择设备并按连接后,我收到此错误:DOMException: 设备不可用

将 Pro Micro 插入 USB 端口(位于 /dev/ttyACM0 ),并在其上加载了演示 Arduino 代码,该代码在连接时发送串行握手(参见上面的演示链接)

我还编辑了文件 ArduinoRawHID.rules 以包含 0x1b4f 并将其放在 /etc/udev/rules.d/

有什么明显我在这里失踪的吗?

---编辑我正在尝试一个不同的演示,它说 Pro Micro 已配对但我收到“连接错误:SecurityError:访问被拒绝。”

我还对 USBCore.h 进行了 #define USB_VERSION 0x210 修改

我还缺少什么会导致SecurityError的东西?

0 投票
0 回答
81 浏览

webusb - 如何在 SAMD51 或任何其他 MCU 上实现 WebUSB?

SAMD51 是兼容 Arduino 的 MCU,我有这个板(Adafruit itsybitsy m4)。https://www.adafruit.com/product/3800

我想在这块板上实现 WebUSB。

0 投票
2 回答
2381 浏览

javascript - Serial API 中的 navigator.serial 和 SerialPort 上的函数是否未实现?

我正在尝试从网页连接到串行端口。我找到了可以支持它的串行 API 。

但是navigator.serial.requestPort()电话失败了;我发现 navigator.serial 未定义。我很确定串行端口已连接到我的计算机。Serial API 中的 navigator.serial 和 SerialPort 上的函数是否未实现?我的 chrome 版本是 74.0.3729.131。我的系统是 Ubuntu 16.04

0 投票
1 回答
227 浏览

usb - 如何在没有用户手势的情况下重新连接到 USB 设备?

我正在编写一个网页,将在自定义 USB 设备上执行软件升级。首先,用户执行用户手势以连接到设备并启动程序。然后页面仍然打开,但设备会自行重置。有没有办法在没有用户手势的情况下再次连接到这个设备(已经配对)?

0 投票
0 回答
399 浏览

javascript - WebUSB reading data from a serial port not responding

I am using WEBUSB to read data from a weighing machine. The device is returning with status: stall when data is sent on the control transfer .

The Serial port from the weighing machine has been connected to RS232 USB to Serial port converter (BAFO BF-810 which has IC PL2303) and the usb is connected to the computer. Reading data from the same IC PL2303 was working before do not know suddenly why this issue has popped up.

Got stuck here for the past 1 week. Any help will be greatly appreciated . Thanks in Advance.

0 投票
1 回答
618 浏览

javascript - WebUSB will not connect because another device is using the same interface

So I'm trying to connect to openEEG upon running the claimInterface() function I get

NetworkError: Unable to claim interface

lsusb shows this problem is likely because some MSI driver is running on the same driver

Output of lsusb -v -s4

I originally tried adding 255 as the classCode on navigator.usb.requestDevice because the documentation said I can do that, but they don't have the same IDs so that was pointless. Also upon reconnecting I can only get lsusb to output of the MSI driver even though Chrome picks it up and I got an access denied error.

which is strange because I changed the udev rules and used sudo chmod -R 777 * In dev/bus/usb

I then found in folder "001" a file that I previously had to manually change the permissions of thinking it was the MSI driver but this time the original file was deleted in place of one named "007" instead of "005" (probably because I tried plugging the device in twice)

So this must be a combination of MSI security features? and OpenEEG creating a new file every time it's loaded?

The only solution I can think of is to delete a file that I don't understand and change the permissions every time it's plugged in. both of which are very prohibitive for uses especially since I want my website to work across a broad range of devices and operating systems

PS: Using Linux Mint if that's relevant and here is my code(I don't think it's the problem) that is being run with on local node.js server

EDIT/UPDATE: lsusb returns nothing when not connected the two drivers are coming from the same input???????