0

Im trying to use DART's chrome.usb API in a angular-4 dart web-application. But it keeps throwing an exception as _usb is null.

if (_usb == null) _throwNotAvailable();

As a workaround, I wrote a DART wrapper around a javascript library (inspired by arduino webusb demo). This works. Also when chrome-app device-info as en example, Im able to communicate to a USB device endpoint; however, the example is not written in DART.

However, I'm confused why using DART's chrome.usb, it isn't working. I'll prefer to use the already existing chrome.usb API as reinventing the wheel.

Reading certain websites, they indicate that chrome.usb is limited to web-applications or extensions and need a manifest.json file for the proper permissions (I tried the manifest file without success). Not sure if I misunderstood those websites (As I think writing a SPA front-end with Angular-dart is considered a web-application), plus when using a DART wrapper around a javascript library, it works fine.

Any suggestions are welcome.

4

1 回答 1

1

chrome.usb 和 WebUSB 是两个不同的 API。chrome.usb 仅在已弃用的 Chrome 应用中可用。WebUSB 可在任何网页上使用(只要它通过 HTTPS 提供)。如果您使用的 Dart 包装器仅支持调用 chrome.usb API,那么您需要编写一个调用 WebUSB API 的新包装器。

于 2018-02-21T22:43:27.557 回答