question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

As discussed in #401, we are considering merging the webusb library into node-usb in order to take advantage of a standardised USB API - the WebUSB API specification.

I’d like to consider bringing in and merging the webusb library wholesale, however this comes with some drawbacks:

Device

  • Potential loss of some of the lower-level usb details such as LIBUSB_* constants, extended descriptors, bus number, port numbers, kernel driver management, etc.
  • Potential loss of endpoint polling
  • WebUSB device loading would be heavier due to blocking functions needing to be called in order to build the device object. e.g. loading string descriptors.

My recommendation would be to adopt the WebUSB device as the shape of all USB device objects and consider unofficial extension points for features not supported above.

Discovery

  • Potential loss of the simple getDeviceList() and findByIds() interfaces, instead using the slightly more complicated requestDevice().

This could be mitigated by exposing two device selection interfaces - WebUSB and Classic, both of which return WebUSB device objects.

In order to keep the API as simple as possible, I’m keen to understand which features can be deprecated and which must be kept. Can we get away with just using the WebUSB specification, or will this break common use cases (as I suspect).

To help with the new API design, any ideas and thoughts are welcome.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
thegeckocommented, Aug 30, 2021

I’ve implemented my proposal above and re-released v2.0.0 for feedback:

npm i usb@alpha
4reactions
thegeckocommented, Jun 6, 2021

@busticated I think that’s worth looking into. As binaries are currently created manually for some targets, I think the challenge will be how to automate usage of prebuildify in CI.

@koush You raise some interesting points. Removal of hotplug support will break backwards compatibility (and personally I’ve had issues with node-usb-detection on Windows as it doesn’t always discover serial numbers correctly). I’m hoping this will be implemented in libusb and plan to switch to the main fork at that point.

We are looking for a solid API to use for this library moving forwards and adopting the webusb API seems the most sensible approach.

FYI, progress towards this can be seen here which includes a lot of the changes already outlined:

https://github.com/thegecko/node-usb/tree/v2

Still very much a work in progress.

Read more comments on GitHub >

github_iconTop Results From Across the Web

RESTful web API design - Best Practices - Microsoft Learn
Level 0: Define one URI, and all operations are POST requests to this URI. Level 1: Create separate URIs for individual resources. Level...
Read more >
Designing REST API with Open API Specification (OAS) v2.0 ...
Swagger / OAS v2.0 standard supports the Basic Authorization, API key based authentication through header or query parameter & OAuth 2.0 ...
Read more >
Official API Design Guide - Stoplight
Learn all there is to know about our API designs through our comprehensive guides, including the basics, API tooling, ... OpenAPI Versions v2.0...
Read more >
Best practices for REST API design - Stack Overflow Blog
In this article, we'll look at how to design REST APIs to be easy to understand for anyone consuming them, future-proof, and secure...
Read more >
API Design Guidelines - Ed-Fi Data Standard v2.0
The guidelines that follow are designed to make Ed-Fi REST API implementations intuitive and easy to use for programmers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found