Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate with Serial API and WebHID #186

Open
reillyeon opened this issue May 30, 2020 · 0 comments
Open

Integrate with Serial API and WebHID #186

reillyeon opened this issue May 30, 2020 · 0 comments

Comments

@reillyeon
Copy link
Collaborator

The Serial and WebHID APIs are defining higher-level interfaces to USB devices implementing the CDC-ACM and HID interface classes as well as vendor-specific interfaces which are exposed through the host operating system's serial and HID APIs.

Due to variations on operating system configuration the drivers which translate between USB and these higher-level APIs may not be present. In this case a developer can implement this driver in JavaScript using the WebUSB API. It would therefore be convenient for developers to specify when requesting permission to access a device that they will accept either the high-level interface (such as SerialPort or HIDDevice) or the low-level interface, USBDevice.

Phrased in terms of the Permissions API using the proposed requestAll() method like this,

navigator.permissions.requestAll([
    {name: "usb", filters: [...]},
    {name: "serial", filters: [...]}
]);

Alternatively the requestDevice() method could be extended to optionally return instances of SerialPort or HIDDevice when requested like this,

navigator.usb.requestDevice({
    filters: [...],
    includeSerialPorts: true,
    includeHidDevices: true
});

However, since a USB device may include multiple interfaces implementing these protocols a better integration could be to add serialPorts and hidDevices attributes to the USBDevice object. These would be populated when the browser detects that there is a high-level driver claiming one of the device's interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant