Skip to content

Skip devices with unreadable descriptors during WebUSB selection and … - #96

Draft
thegecko wants to merge 1 commit into
mainfrom
skip-unreadable
Draft

thegecko wants to merge 1 commit into
mainfrom
skip-unreadable

Conversation

@thegecko

Copy link
Copy Markdown
Member

…filtering

Changes

Fixes

Checklist

Have you...

  • Tested the change acts as expected
  • Checked the change doesn't remove or change existing functionality
  • Considered how the feature impacts the product and tested around it (not just the happy paths)
  • Where possible, executed the hardware tests on multiple operating systems

@goncalomb

Copy link
Copy Markdown

Hi. I'm testing it, requestDevice no longer throws! But there is still some weird behavior. Code:

import { WebUSB, } from 'usb';

const wu = new WebUSB({
    allowAllDevices: false,
});

const dev_info = d => Array.isArray(d) ? d.map(dev_info) : [d.vendorId, d.productId, d.productName, d.serialNumber];

console.log('requestDevice', dev_info(await wu.requestDevice({ filters: [] })));
console.log('getDevices', dev_info(await wu.getDevices()));

1. (this may be a separate issue) with allowAllDevices: false, on this version, requestDevice selects one device but getDevices can't distinguish similar devices with the same specs and returns multiple:

requestDevice [ 3034, 21521, '4-Port USB 2.0 Hub', null ]
getDevices [
  [ 3034, 21521, '4-Port USB 2.0 Hub', null ],
  [ 3034, 21521, '4-Port USB 2.0 Hub', null ]
]
# lsusb
# ...
Bus 001 Device 002: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
Bus 001 Device 004: ID 0bda:5411 Realtek Semiconductor Corp. RTS5411 Hub
# ...

(on v2 I can't even select this 4-Port USB 2.0 Hub system device so I don't know the behavior)

2. (related to the original issue) with allowAllDevices: true, on this version, getDevices returns all devices (even the system ones that can't be open):

requestDevice [ 3034, 21521, '4-Port USB 2.0 Hub', null ]
getDevices [
  [ 3034, 21521, '4-Port USB 2.0 Hub', null ],
  [ 1193, 6418, 'LiDE 400', '47633C' ],
  ... (lists all devices) ...
]

On v2 getDevices returns only the valid devices (I think this is the intended behaviour):

requestDevice [ 1193, 6418, 'LiDE 400', '47633C' ]
getDevices [ [ 1193, 6418, 'LiDE 400', '47633C' ] ]

(the LiDE 400 is a paper scanner)

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants