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

Android: usb.getDevices() succeeds but serial.getDevices() fails #48

Closed
stewartoallen opened this issue Nov 26, 2022 · 3 comments
Closed

Comments

@stewartoallen
Copy link

Chrome on Android supports navigator.usb but not navigator.serial so I'm trying to use this polyfill to access a serial device that works from Chrome on Mac & PC.

The command that succeeds in finding and connecting to the device on all platforms, including Android:

navigator.usb.requestDevice({
    filters:[{
        vendorId: 0x0403,
        productId: 0x6001
    }]
}).then(p => console.log({p}))

I would expect the following to work, but it does not:

exports.serial.requestPort({
    filters:[{
        usbVendorId: 0x0403,
        usbProductId: 0x6001
    }]
}).then(p => console.log({p}))

the same command replacing exports.serial with navigator.serial on Mac and Windows succeeds. getPorts() similarly fails

@stewartoallen
Copy link
Author

stewartoallen commented Nov 27, 2022

turns out the device shows up as class 0, not class 2. not sure what to do with this knowledge because I know nothing about usb-serial. but that's the filter that prevented it from showing. the WebSerial implementations do handle this somehow. android, mac, windows all return the same info below.

Screen Shot 2022-11-26 at 7 15 45 PM

@stewartoallen
Copy link
Author

On PC, Mac, Android the device shows up as having only one interface which does not match the device class. So I presumed this could be used as both the transfer and control interface (seems this is anticipated in the code). I changed the serial.ts code to allow searching for devices with a different class code from the class code used later for interfaces. But then USBOutTransfer stalls trying to set line coding.

Screen Shot 2022-11-27 at 2 59 28 PM

@reillyeon
Copy link
Collaborator

Device class 0 means "check the interface class" and interface class 255 means "vendor specific". This is an FTDI device which means it uses a vendor-specific USB serial protocol rather than the standard USB CDC-ACM protocol support by this polyfill. Issue #8 tracks adding support for FTDI chips.

@reillyeon reillyeon closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2022
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