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

getInfo method should not reject before opening the port #19

Closed
stylesuxx opened this issue Mar 22, 2021 · 3 comments
Closed

getInfo method should not reject before opening the port #19

stylesuxx opened this issue Mar 22, 2021 · 3 comments

Comments

@stylesuxx
Copy link

In the "real" Web Serial API one can query information about the available ports before opening a connection:

const ports = await serial.getPorts();
const info = await ports[0].getInfo();

But results in a rejection with the polyfill:

DOMException: The device must be opened first
@reillyeon
Copy link
Collaborator

The current implementation of getInfo() actually doesn't match the specification at all. It returns a SerialOptions rather than a SerialPortInfo. That's why it requires the device to be open, so it can read back the current device configuration. If it returned a SerialPortInfo that could be constructed only from attributes of the underlying USBDevice interface.

@stylesuxx
Copy link
Author

I understand. But in order to be closer to the Web Serial implementation, it should not reject. Otherwise I would need to again have checks in place if the polyfill or the real deal is used - which is not what I should be having to do when using a polyfill.

If device info is not available would it not be an option to simply return some dummy data for vendor and product id?

@reillyeon
Copy link
Collaborator

This was fixed in #21.

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

2 participants